Getting Started With NetDuino

After my previous foray into Arduino and XBee, I was hoping to be able to use Node.js as the “on-the-metal” OS of sorts for running the Atmel microcontroller. Unfortunately, Node.js (in it’s default configuration) is too big to run in the memory and program storage constraints of the Arduino uController. Not wanting to write my control applications in Arduino Sketch or C, I decided to switch over to using NetDuino as the central controller hub of my real world control project. This is the story of getting started down that path.

I already have a copy of Visual Studio 2010 Professional, which is more than enough to start writing NetDuino projects, but I did need to get the latest version of the .NET Micro Framework. As of this writing, that is version 4.2 RTM, available here on Microsoft’s CodePlex site.

I didn’t realize it, but I would need an SDK for the Netduino Plus itself – found that on the Netduino website here. They suggest installing the .NET Micro Framework 4.1, but I had already installed 4.2 so I decided to throw caution to the wind and try it anyway.

  • Project->New->Micro Framework->Netduino Plus – give it some name that you will inevitably regret later
  • Open program.cs, add some code like:
  • while(true)
    {

    }

    Ok, I did a whole bunch of stuff that I will document later, but I have a Netduino acting as central controller and an Arduino acting as a remote controller attached to some irrigation valves. I have a web server running on the Netduino and a simple web interface for turning my irrigation valves on and off. That’s my big accomplishment for the day.

Getting started with Arduino and Xbee (Part 2)

When we left our hero last, he was in rapture pressing the ‘H’ and ‘L’ keys and seeing an LED on a small electronic device turn on and off. We won’t deign to judge him based on what causes him rapture, but we will continue to explore this miracle of the keys and the lights. See Getting Started with Arduino and XBee (Part 1) for the beginning of this story.

The next step for me was to see if I could get two independent Arduinos talking to each other over XBee. At this point we had one connected to the computer and one running independently. So what was it going to take to make this happen? I would have to have the PhysicalPixel sketch running on the receiver (sender and receiver are arbitrary, but we will go with it) and some kind of sending sketch running on the sender (Duh!). The sender would send an ‘H’ upon some input from the user. That would mean I would have to have both Arduinos with XBee shields running independently. I ran into a bit of a problem here. I didn’t have a second USB cable to power both Arduino’s, so a quick trip to the Home Depot next door was in order.

Two XBees Talking

Two XBees Talking

Before I shot off to Home Depot, a quick perusal of my electronic kit bag turned up a 9V power adapter. Now Arduinos work swimmingly with inputs anywhere between 7V and 12V, so a 9V connected to VIN and GND would do the trick nicely. So at Home Depot I picked up a tiny USB hub and some 9V batteries. See previous post on why I needed a USB hub. Hooking everything up gave me what you see in the above picture. With PhysicalPixel running on the left, and a modified StateChangeDetection running on the right, I was able to send ‘H’, ‘L’ from the right Arduino to the left Arduino upon pressing a switch connected to GPIO2. The on-board LED on Arduino on the left would turn on and off in response to these ‘H’s and ‘L’s. This is what is called success, I now had two Arduinos talking to each other without the intervention of the mother computer. It was time for them to fly, but before they could fly, I needed to upgrade their OS’s. I wanted something a little more communicative and inter-operable than the Arduino sketch language – it was time to introduce Node.js. See the upcoming post on Arduino, XBee and Node.js for more fun and frivolity.

UPDATE: I had thought that projects like node-arduino and NoDuino were actually ports or cross compilations of the Node.js environment to the Arduino, but it turns out I was mistaken. They are, instead, ways to control your Arduino from the host computer using Node.js. Not what I wanted at all. I was hoping to have Node.js running natively on the Arduino like an OS. And, well, despite my few hours spent digging around I couldn’t find specs on the footprint of a typical Node.js compiled core. Seeing as it incorporates the Google V8 Engine, however, I’m not holding out very little hope that it will fit in the Arduino’s 32KBof flash storage, 2KB of memory and 1KB of EEPROM. Even the Netduino’s specs seem a little low, although the new Netduino GO might be just enough. Guess I’ll just have to ramp up development on my new Physical Computing Platform or Real World Computer.

UPDATE 2: I will be revisiting my desire to run Node.js as an “operating system” on these micro controllers. I may instead switch over to Netduino technology and use the .NET Micro framework.

Getting started with Arduino and XBee (Part 1)

Arduinos, XBee Shields and Xbee Modules

Arduinos and Xbees

Just sat down today with a couple of Arduino UNO R2s (actually the link is for the R3s, R2s are no longer available) and a couple of XBee Shields from sparkfun.com and a couple of XBee S1 modules (again link is for newer model, the S1 isn’t available anymore) from www.digi.com and wanted to get them talking together.  Thought I’d record what I found and how I made it all happen.

I connected one of the XBee shields to one of the Arduino boards, plugged in the XBee module and fired up the Arduino IDE. I loaded File->Examples->Communciaton->Physical Pixel and made sure the switch on the XBee Shield was set to DLINE so the XBee module wouldn’t interfere with the serial communications between the computer and the Arduino. The XBee shield can either run connected to the GPIO of the Atmel chip or connected to the serial I/O lines of the Atmel chip. In this case you want to be able to program the Arduino, so you need to have those Atmel serial lines unmolested by the XBee shield. Set the switch to DLine. I then Uploaded the sketch to the Arduino and saw that the programming lights blinked and everything looked good. Its important at this point to flip that switch back to UART so that anything received by the XBee module gets output to the serial lines connected to the Atmel chip.  You won’t be able to program the Arduino while it’s set that way, but that’s ok.

Arduino with XBee Shield and Xbee Explorer

Xbee Explorer and Arduino-Xbee

I then connected the other XBee module to the XBee Explorer and plugged in a mini-usb cable that I had lying around. Windows complained that it couldn’t find the drivers for this little guy, so I went Start Menu, typed devmgmt.msc, enter (Device Manager) and told it to Update Drivers for this particular device. It seemed to find a working set of FTDI USB drivers and my XBee Explorer was listed as a USB Serial Converter and marked as working device in Device Manager. Now I needed some software to communicate with it. The program of choice seems to be Digi’s X-CTU software (the makers of the XBee module), but all the links that were listed on Sparkfun were broken. I finally ended up at Digi’s XBee Development Kit, and clicked through to X-CTU Installer to download the X-CTU software for Windows 7 (32 bit, but it works). BTW, my Macbook Pro has only 3 USB ports, so at this point, with an external mouse and keyboard I was forced to keep switching devices to make this all happen. Note to self: make sure to buy a small USB hub. I cannot stand chiclet keyboards and touch pads, so I always carry my TrulyErgonomic keyboard and MS wireless mouse around with me. Yet another side note – with the two XBee modules powered up and talking to each other, my wireless mouse stopped working, so I’m guessing they are both trying to use the 2.4 GHz open frequencies for communication. I’ve heard that this is a problem with XBee stuff in a residential setting where it interferes or gets interfered with by consumer wireless devices. We will see.

After waiting for the 40-some-odd MB of the X-CTU Installer to download, I installed it and everything went fine. With the XBee Explorer still connected I fired up X-CTU and it discovered my XBee module right away. With my Arduino already connected, to COM3, the Explorer came up on COM4 and I selected that under the PC Settings tab of the X-CTU app. I poked around and could see all the Configuration settings for my XBee module and saw a Terminal window, which I assumed would try to send characters out over the XBee. Now it was time for the magic.

So with both XBees now powered up and running, one connected to an Arduino and one connected to the XBee explorer module, and with the PhysicalPixel sketch running on the Arduino XBee and the X-CTU software running and connected to the XBee Explorer module I surmised that if I typed a capital ‘H’ in the Terminal window of X-CTU then the Arduino should receive a capital ‘H’ from it’s XBee module and turn on the on-board LED (this is what the PhysicalPixel sketch does – turns ON the LED when it receives ‘H’ on serial and turns OFF the LED when it receives ‘L’ from the serial port). So I typed ‘H’ in the X-CTU.

Miracle of miracles! The LED on the Arduino turned on! I was almost breathless with excitement, I could not wait for the next sign from God. I typed ‘L’ in the terminal window of the X-CTU app and Lo and Behold! The LED turned off! Ok, enough exclamation points, the tutorials and getting started guides told me that this is what should have happened so I was relieved that things worked the way they should. They rarely seem to do that for me the first time, so this is indeed a small blessing.

Now on to Arduino and Xbee Part 2