Arduino, BeagleBone and XBees - Oh My!

Sorry, I couldn’t find a better blog post title :-(

This blog post is actually something like a mix of my two previous blog posts.

I’ve enhanced the previous RGB Led Strip project controlled by an Arduino in order to send temperature readings via XBee to another XBee node.

The reason why I want to do this is that I want to control some RGB Led Strips in my home with various intelligent modes (like the example one based on temperature). But as I need some sensors for this intelligence, I thought this was an interesting opportunity for building some Home Automation right there and gather sensors data from those lighting nodes to a gateway one which would keep all the data in a central place and provide a way to interact with all the various nodes.

Now in order to communicate sensors data from the lighting nodes to the gateway, there is a need for a link between thoses nodes. For obvious reasons I want some wireless links.

There are many wireless solutions available for doing such things. I’ve choosen to use some XBee for various reasons I’ll talk about in another blog post (this may sound overpriced for this project).

The Arduino Side

Image from SparkFun Electronics

So the idea of this project is to enhance the previous one by adding an Arduino XBee Shield and plug a XBee in it. This XBee Module is configured so that it sends data to another one (DH and DL settings).

The other one happens to be a XBee module interfaced with a BeagleBone.

I’ve modified the Arduino sketch in order to send the temperature readings every minute over XBee (complete Arduino sketch available if you want it). The relevant code looks like this:

XBee xbee;
XBeeAddress64 gateway = XBeeAddress64(0x13A200, 0x4080BF72);
...
// send temperature value over XBee - once per minute
if ((millis() - last) > XBEE_REPORTING_FREQ) {
  char tempData[30];
  ftoa(tempData, temperature, 2);
  Tx64Request tx = Tx64Request(gateway, (uint8_t *) tempData, strlen(tempData));
  xbee.send(tx);
  digitalWrite(13, HIGH);
  last = millis();
} else {
  digitalWrite(13, LOW);
}

I’m basically setting up the address of the XBee module to where the data should be sent (SH and SL settings of the remote XBee module) and based on elapsed time, if more than a minute has gone, then I create a string that will contain the data to be sent and simply use an Arduino XBee Library in order to send this data to the remote XBee module.

The BeagleBone Side

The BeagleBone actually runs a custom Java program relaying received XBee data to COSM. Basically what this program does is to listen for serial events, parse the XBee data (both XBee modules are in API mode) and relay it to COSM via their APIs.

A public feed (not always live) is available if you want to see this in action: https://cosm.com/feeds/98803.

Video Recap

Here is finally a video of the complete setup.

comments powered by Disqus