Monday, December 10, 2012

Netduino Serial Demo Sample

Last month we ran out of time in our meeting before I could finish up my serial data demo. At that time I promised to get some sample code out there…all I can say is I’ve been very busy and better late than never.

The demo program I created which was called SerialIODemo is a very simple mechanism to send commands and arguments from the desktop down to the Netduino via a via a FTDI USB Serial port.

Then of course you’ll need to connect both of these to your computer via USB. The following picture should give you a good idea of how this should look. Note the green wire is in the pin closes to end of the connector.

Fully Connected

Connection to FTDI

Connections on Netduino

After you have made your connections and plugged in the USB connections to your computer, you’ll need to check the Serial Port the FTDI is connected to. this can be done via the Device Manager under ports. In my case, I’m on COM1

You’ll need to modify the code to connect to this port (TODO: Could have this configurable through the UI). This needs to be done in MainWindows.xaml.cs in the DesktopApp project

Once you’ve done this you should be ready to go!

To use the app, simply make sure both programs start. This can easily be done by right mouse clicking on the solution node SerialIODemo and setting both projects to startup.

Now start your program, give the Netduino a few seconds to warm up and press Connect. When you do so, the Netduino should respond back as in the screen below. If you don’t see this give the Netduino a little longer to start.

Extending the App

The idea behind this application is to invoke different commands by sending a string from the computer to the device. The string will be in the format “command=arg”. A switch statement in the device code will handle different commands and the args can be used to make those commands work with different “stuff” on the device.

Hope this gets you started on controlling your Netduino with your computer!