Wireless Projects over the Web: Digi Dia for Hackers Part 1
Suppose you want to log data from a group of sensors, like temperatures around the house, or turn lights on and off remotely via a webpage, and you want to do this wirelessly. You could use a WiFi shield for an Arduino, but they’re notoriously hard to set up and stay reliably connected.
My preferred way uses Digi XBee radio modules with the ConnectPort gateway, which connects a network of XBee modules with a LAN over ethernet. So far, easy: build your microcontroller project that sends and receives data via an XBee ZigBee module (using “Series 2” hardware), and the ConnectPort is your mesh’s coordinator.
Then the question becomes how to send and receive the data from the coordinator. If you had the coordinator plugged into a computer, you could write an interface however you liked. Lucky for us, the ConnectPort is basically a tiny computer that runs Python! So how do you access your project’s data via the ConnectPort over the web?There are two overall approaches: transmit to another webserver, or use the ConnectPort as a webserver itself. XBee fiend Rob Faludi and I developed a handy way to do the first approach, called the XBee Internet Gateway (XIG), and Digi mastermind Jordan Husney vastly improved it.
XIG’s one ability is simple but hugely useful: it allows your Arduino to retreive a URL from the Internet. Say you’re collecting temperatures from sensors via your microcontroller. With XIG, you can post the values to a web script on a server somewhere by sending this string to the ConnectPort: “http://my.server.com/myscript.php?val1=6&val2=10&etc=etc”. Your script can then optionally return some string for your Arduino to parse and use.
This is fast, easy, and effective! Its only downside is that you need an external webserver to get the data moving. For many of us, this is no problem, but wouldn’t it be nice to cut out the middleman?
Enter Digi’s Dia platform. Dia (Device Integration Application) is a Python program that runs on the ConnectPort that talks to your XBees and—the important part—runs its own web server so you can talk directly to the ConnectPort instead of using an external web server.
Now, Dia is a fairly new platform, and definitely designed for engineers more than hackers like ourselves. So I did a deep dive into the platform recently and have brought the results to you! Stay tuned for the next part!