Wireless Arduino programming

That was really cool.

There are times when you end up doing something hardcore and not realizing it until it happens. There are other times when you set out to do something hardcore, and you are just amazed when it all works.

This one was of the second variety.

A part of the bathroom scale hack, I wanted to get the circuit as small as possible, and also enable it to send data wirelessly. After much deliberation, I decided on XBee as the wireless protocol to use. I had heard a lot of good things about XBee, and wanted to give it a try.

The first cool part was that when I finally got around to ordering, the goods were on my doorstep the very next day. But I am skipping ahead a little.

When I go looking for new Arduino parts, my first stop is Adafruit. They have great descriptions and tutorials, and their gear is top notch. Unfortunately, they were sold out of XBee gear when I stopped by. So I was forced to look around. It turns out that one of their distributors, Solarbotics, had Adafruit XBee boards in stock. That is happiness. I did a little more digging, and found that Adafruit’s board is compatible with the FTDI USB cable that I am so fond of, but in the course of figuring this out, I realized that the Sparkfun XBee Explorer board has its RX and TX lines swapped, so while it’s incompatible with the FTDI cable, it’s directly attachable to anything that is, in particular, it can be piggybacked directly onto an Arduino Pro Mini! I ordered a couple of Adafruit boards, a couple of Sparkfun boards, a couple of XBees, and a couple of Minis.

When they turned up, it surprised me how tiny the stuff is. The Explorer is about an inch square. It’s bigger than the Arduino Mini. I did some breadboard tests, and the pins did in fact line up properly.

I was just about to solder the whole thing together when I realized that I might have trouble programming the Arduino with the XBee board soldered on. So I decided to look into using the XBee to wirelessly program the Arduino. Back to Adafruit, and I read her tutorial. Looked pretty simple, but it was going to require a couple of extra parts; a transistor, a cap, and a resistor. I didn’t want to build a daughter board for that, so I decided to see if I could construct the little circuit deadbug style. I bread boarded it out first, and got the Arduino IDE to send the code via XBee. That was pretty satisfying.

Then, I went to work on one of the Explorer boards. Dead bugging a circuit into an existing one is one of those “you only get one shot at this” moments, so I went as slowly as I needed to in order to make sure that I wasn’t missing anything. The most interesting part of the build was when I needed to use one of the standoff holes in the board to jump across to the Arduino. I got it all soldered together without any problems. The hardest part was getting the two boards parallel. I plugged back into a power source, and fired it up, and it worked on the first try! I was able to download code across the XBee into the Arduino. To say that this was a cool feeling is a gross understatement.

Of course, five minutes later I realized that I really had wanted one more pin exposed on the XBee. And of course that was one of the only two pins that was completely blocked by the deadbug circuit. But in a fit of soldering machismo, I was able to solve even that problem, so I now also have access to the XBee sleep pin, so I can throw everyone in powersave mode if I need to.

The XBee and Arduino are soldered together using straight header. It’s a very sturdy and compact setup, but it is also very permanent. Those two boards are going to live together forever now. I am really glad they still work properly, and I am really glad I have spares. 🙂

I need to figure out sleep mode for the Arduino and XBee. That is going to require some pin shuffling in the code again, since the Arduino can only do wake up interrupts on particular pins, and I’m using them both right now. I’ll need to allocate a pin to wake up the XBee also, unless I can figure out a way to trigger both circuits off the same pin. We shall see.

Once I figure that part out (I can do testing on a board that’s not all soldered together), I am ready to solder the output wires from the scale into place, and then mount the new little unit somewhere inside the case. I need to get the computer-side server software written, too. I don’t know how to make a Mac listen to an XBee. I’ll get there.

In case it wasn’t entirely clear, let me just say it: XBee is very, very cool stuff. I should not have waited this long to try it out. My mind is awhirl with projects that involve permanently mounted mini Arduinos all over the place, and a central command center that can push software updates or receive sensor data or… W00t!

This entry was posted in Electronics, Making and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *