As I mentioned in a previous post, I am setting up an Arduino-based wireless sensor network at home, and evaluating a few different wireless communication options in the process. This past weekend, I completed the first phase of my project — assembling and end-to-end wireless sensor network that uploads air particulate readings, temperature, and light level readings to Xively. In this post I’ll walk through how I set this up.
I chose Cisceco’s lineup of “XRF” radios for my initial communication platform. I’ve really loved the idea of their products since I first read about their XBee replacements. Ciseco offers a really great premise — a whole lineup of well-tested XRF devices that make the “radio” work as simple as possible. I like the primacy facia simplicity — each XRF device “transparently” relays everything it hears to all others. CRC checking and packetization is taken care of for you. Even better — it supports Ardunio compatible “over the air” updates nearly out of the box, meaning you can upload new sketches to a remote node over the wire. All communication back to the microprocessor is done using a serial interface, one of the very simplest interfaces to use on nearly any embedded device.
I have to admit that I really fell in the love with the idea of Ciseco products after doing a lot of on-line research — so much so that I went ahead and ordered quite a few components. Cisceo has has a solid lineup of different form factors for their radios. The XRF is an XBee replacement. The ERF is a FTDI replacement. The SRF is intended for surface mount. I love their URF module which is a radio + a USB interface — this makes it dead simple to observe what is being transmitted using a PC. This capability invaluable in troubleshooting and a really brilliant move on their part.
For my project, I used a combination of their tools including a URF usb serial relay (for laptop monitoring), a RFu arduino to take readings and a ERF module to relay readings to a Arduino Yun that uploads them to Xively. The integration of the Arduini compatible AVR chip and the XRF radio onto a single device is very attractive. In theory it means that you could create a wireless sensor or device with very little additional components.
My setup begins with my sensor board shown below using the Ciseco RFu to share light levels. As you can see there is quite a bit of integration components needed to get it working. The Rfu is placed on a Sparkfun Xbee breakout board to make it breadboard friendly. On the right is logic to make it talk to an FTDI connector. On the left side is an LED to visually check the “heartbeat” and a power regulator to provide 3.3 volts. The TSL2651 light sensor is mounted in the middle.
When the sensor node powers up it starts transmitting LLAP messages every few seconds. Every message is exactly 12 bytes and contains a two letter node name, a three letter sensor name and the reading. You can see this message pattern here through the serial monitor on my laptop, fed via a URF USB radio.
On the Yun, I soldered together a shield to connect the ERF radio to the Yun in a tidy way. Ciseco does make a shield for this purpose but it assumes it will talk to the Arduino using D0 and D1, which are “reserved” on the Yun. (D0 and D1 are actually the conduit between the linux distribution and the AVR.) My shield remaps the TX and RX to D10 and D11, and the sketch reads via the SoftwareSerial library.
The Yun runs a very simple sketch the receives LLAP messages and invokes a command to upload to Xively using a CURL unix command. It was a fairly simple task to integrate the existing Yun demo sketch for Xively to the LLAP demo sketch. I just had to add some glue to parse the sensor name out of the LLAP message:
strncpy( sensor, cMessage + 1, 5 ); sensor = 0; // last value guard to null strncpy( value, cMessage + 6, 6 ); value = 0; // make sure last value is null for( int i = 0 ; i < 6 ; i++ ) if( value[i] == 0x2d ) value[i] = 0; Serial.print( "Sensor: " ); Serial.print( sensor); Serial.print( " Value:" ); Serial.println( value );
Despite everything now being assembled, not all is rosy. First of all, somehow I have managed to fry two of my Ciseco parts; I’m not sure exactly the cause but I did have quite a lot of difficulty figuring out how the pins were mapped. Secondly, the Yun experiences numerous hangs writing to Xively — basically timeouts either in the network or the bridge protocol. I think I need to create a new infrastructure that saves the sensor readings into a local log format.
Ciseco’s radios worked well, but I’m starting to feel that the technology may not be as tuned as I’d like it for sensor networks. More on this later.