Posts Tagged ‘robot’

I have been working on modifying a Linksys router (WRT54G) that I picked up at Goodwill into a controller for an electric wifi controlled wheelchair robot. Along the way I found a cheap way to control an LCD remotely. Enjoy!

My parts list is:
(1) Blue, 4×20 LCD w/ LCD117 from Modern Device
(1) RBBB Arduino Clone from Modern Device
(1) Linksys WRT54G V2 from Goodwill running DD-WRT
*This tutorial will include the use of a Linux machine running Ubuntu 10.10. If you’re using a non Linux machine you’re on your own…. Sorry.

Why don’t you see a level shifter in the mix? The ATMega328P in my Arduino clone is fine with reading 3.3V logic on the RX pin. On side note, the chip is fine running at 3.3V source as well. This has been demonstrated by JeeLabs for a few years now.

So let’s begin……

The LCD wiring is as follows –
*This will work with the liquid crystal library as well if you don’t have an LCD117 board.
LCD power (LCD117) comes from one of the RBBB pins labeled as 5V.
LCD ground (LCD117) comes from one of the RBBB pins labeled GND.
LCD RX (LCD117) comes from the pin labeled PIN 9 on the RBBB.

The WRT54G wiring is as follows –
*You’ll have to verify the pin out of your specific router. This is documented on line pretty well. On my V2 the serial port is the 20 pin connector on the right front of the board.
RBBB GND pin to pin 9 on my router’s serial port.
RBBB RX pin to pin 3 on my router’s serial port.
This is it! I soldered female header to my router’s serial port in lieu of wire.

** I added an external 2.1mm power jack to my router so I can connect my clone to the router’s 12VDC supply. This is pretty wasteful but it saves me a few parts when the router is running on battery power.

Here’s the specific Arduino sketch I’m using to hand characters from the router, through the Arduino to the LCD. I guess in this example I’m using the Arduino as a level shifter that can do other stuff.

#include
#define txPin 9
int incomingByte = 0;
SoftwareSerial LCD = SoftwareSerial(0, txPin);
void setup()
{
Serial.begin(9600);
pinMode(txPin, OUTPUT);
LCD.begin(9600);
LCD.print(“?G420”);
delay(500);
LCD.print(“?Bff”);
delay(1000);
LCD.print(“?s6”);
delay(1000);
LCD.print(“?f”);
delay(10);
LCD.print(“?c0”);
delay(300);
LCD.print(“routerBot ACTIVATED?n”);
LCD.print(“?n”);
LCD.print(“root@192.168.2.1?n”);
LCD.print(“echo ## > /dev/tts/1”);
}

void loop()
{
if (Serial.available() > 0) {
incomingByte = Serial.read();
LCD.print(incomingByte,BYTE);
}
}

Download the sketch to your Arduino board.

Next, in your router’s admin page enable SSHD. Again this is documented on line pretty well.

Now let’s SSH in to the router-
Here’s how I do it.
Connect to your router via WiFi or an ethernet cable.
Open up a terminal. (CTL+ALT+T)
Type “ssh root@192.168.2.1”. This is my router’s IP address. Yours may be different.
You may have to type “yes” next.
Now enter your router’s admin password.

Once you’re able to open up an SSH session with the router let’s slow down the serial port comm speed.
Type “stty -F /dev/tts/1 9600.”

If you’ve wired everything correctly reset the Arduino and you should see a message on the LCD. If it doesn’t work try resetting the board and waiting a few seconds.

Now, if we’ve done everything correctly to this point we can send a few characters over.
Type “echo ?f > /dev/tts/1”
This should clear the LCD. Replace the “?f” with whatever text you like now. “?n” will get you to the start of the next line on the LCD.