Monday, August 1, 2011

Wires? We Don't Need no Stinkin' Wires.

Finally. This was a long time comin' but as of last night, the robot is finally completely wireless.

I managed to add a serial port to my already 'enhanced' WRT54GL Linksys router, which is running the dd-wrt firmware. If you don't already know about this great firmware, check out the link... its basically a way to turn a cheap router into a priceless routing monster. To add the serial port, I used a Logic Level Converter to convert the 5V serial messages coming from the Arduino to 3.3V, which is what the router is expecting.

I used the BOB-08745 chip from SparkFun Electronics (A great deal for about $1.50). Took a a few days to get to my house, but once here, wired it up and it started working right away.

If you decide to go with the above chip (In place of the MAX232 chip most commonly used for Serial), pay close attention to the RXO / RXI / TXO / TXI. It is a bit confusing which wires go where on this chip since it's about the size of a dime and a bit hard to read. Basically, on the HV (High Voltage) side, connect ground and a 5V connection from the Arduino, on RXI, connect the TX from the Arduino. On the TXO, connect the RX from the Arduino. (Yes you understand correctly... RX to TX, and TX to RX... confusing much?). Then, on the LV (Low Voltage) side from the router, connect the 3.3V and Ground connections from the router, and then on TXI, connect TX from the Router, and on RXO, connect RX from the router.

Some more technical notes about which caused me a lot of pain in figuring out... Make sure to use a DD-WRT Firmware that supports JFFS. This is required so that you can install the very necessary ipkg to the router: setserial. Setserial is a command line tool that I needed to use in order to set the baudrate to 9600 for the serial port (/dev/tts/1) and set the irq to 3.

My very strong suggestion is to use this firmware in particular from (If using the WRT54GL v1.1 Router...):
DD-wrt Mini Generic V24 SP1

Once serial communication was working, I set out looking for a way to stimulate the serial interface on the router via network messages, rather than having to ssh into the routher and running Serial commands manually...

This is how I currently control the robot through the router:
Listinging to messages from robot:
#cat < /dev/tts/1

Sending Messages to the robot:
#echo 1E > /dev/tts/1

To set up the TCP interface, I am following the advice from Andrew Hazelden (here), which uses ser2net to map a TCP port to the serial interface on router boot up.

So long story short... I'm wire free.


  1. Now that you did all that awesome work I was wondering, did you consider using a pair of XBees to do the wireless link? They have a serial mode (or a DIO wireless relay) so you could send from an XBee connected to a PC (or other device) to the receiver XBee.

  2. I considered using a pair of xbees, but my goal was to reuse as much as I already had on hand as possible... since I had a wrt54g router sitting around unused, I decided to put it to use. :)

    What kind of range do the XBee's get? That was one of my concerns.