Friday, February 21, 2014

Netduino 2 Getting Started

While I'm waiting for my other parts to come in, I got one of these Netduino's a while back to try out. After all, most of my programming experience is in .Net, not C! So for $35 I figured this board is worth a try. The board touts an ARM 7 processor with multi-processing capability and a form factor that almost exactly matches the Arduino Uno. So all the Uno proto shields can be used with this board. You can write code for it using Visual Studio and C# which is pretty sweet.

Getting started is pretty simple, especially if you already use C#.Net for other programming projects.
You'll need to install 3 things to get going:

http://www.netduino.com/

  1. MS Visual Studio C# Express 2010
  2. Net MicroFramework 4.2 SDK
  3. Netduino SDK v4.2.2.0 (32-bit) or Netduino SDK v4.2.2.0 (64-bit)

And of course.. you need a Netduino 2 ($34.95)

To create a new Application for the Arduino 2, open Visual Studio and create a new project.
When the dialog comes up select Micro Framework and Netduino 2 Application.



I want to debug on the real hardware, not using the Emulator. To do this I'm going to set the Project properties for the .Net Micro Framework:

  1. Make sure the Netduino is plugged into the computers USB port so it will show up in the device list.
  2. Change the Transport to USB and select Netduino2_Netduino as the device.

That's all it takes to be able to debug your code on the hardware. I can now run my code in debug mode, directly on the Netduino 2!

Now just write a little code to blink the blue on board LED (to the right of the board) in program.cs. Here is some code:

namespace NetduinoApplication1
{
    public class Program
    {
        public static void Main()
        {
            // Create an Output port for the Onboard led pin and set it to false.
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            // Blink the LED
            Blink(led);
        }

        // Blink the LED at 250ms on/off intervals
        public static void Blink(OutputPort led)
        {
            while (true)
            {
                led.Write(true); // turn on the LED
                Thread.Sleep(250); // sleep for 250ms
                led.Write(false); // turn off the LED
                Thread.Sleep(250); // sleep for 250ms
            }
        }

    }
}

Press the run button to start debugging, the blue LED will blink..  Hello World Netduino!

More information about the Netduino can be found at Netduino.com.

Sunday, February 2, 2014

Trinket-izing the 434Mhz RF Transmitter


434MHz RF Transmitter with the Trinket
The transmitter side of the 434mhz RF Transmitter/Receiver with the Arduino Micro  doesn't really do much processing. It doesn't really need all of the functionally of the Arduino Micro just to collect a little temperature reading and send it the RF Transmitter! The Adafruit Trinket has plenty of power and space for the processing needed, with the added benefit that it shrinks the size and the cost of the project!

Parts List


Temperature Sensor and RF Transmitter:
RF Link Transmitter - 434MHz ($3.95)
Adafruit Trinket 3V Logic   ( $7.95)

Total Cost  $14

Click here to get the code for this project ...

Serial Communications on the Trinket
The Trinket doesn't have is a serial interface like most Arduino boards have. Fortunately there are ways around it! With a little research, I found there are three main methods being used to get serial communications with the Trinket:

  1. Use Virtual Wire to simulate it. I tried a couple of versions of this but I could not get this to compile. Some people also seem to write their own implementation of this.
  2. Use Software Serial to turn a couple of pins into an RX/TX. The plus side of this is that it works! The downside is that it takes a lot of memory so you may not have much room left for other stuff if you use this. Pulling in the Software Serial put the size of the Transmitter/Temperature reading sketch up to 5,058 bytes, which still fits on the Trinket!
  3. Another option - use the UsiSerial library posted by Frank Zhao to implement a hardware serial port. The upside of this is a much smaller foot print! Using the UsiSerial, my compiled sketch is only 3,666 bytes! Plenty of room left! Unfortunately, while this compiled and loaded, it didn't work. Maybe because I am using the 3 Volt Trinket? The notes say it was tested on the 16MHz trinket which I believe is the one with 5 Volt Logic.

Circuit Setup


434MHz RF Transmitter Connections:
GND  -> Ground on Trinket
DataIn -> Software Serial TX pin 1 on Trinket
Vcc     -> 3V from Trinket
ANT   -> 13 cm wire used as an antenna

TMP36 Connections:
Vcc  -> 3.3V on Trinket (TMP36 Pin 1 on left when looking at flat side of sensor)
Vout -> Pin 2/AnalogRead(1) on Trinket (TMP36 Center Pin)
Gnd  -> Ground on Trinket (TMP36 Pin 3 on right when looking at flat side of sensor)


Trinket Transmitter Temperature Sensor Circuit