«

»

Feb 25

Print this Post

DD-WRT Serial and Arduino

Today I’m sharing my latest experiment with DD-WRT along with Arduino.
For those who are not familiar with DD-WRT, it is a custom firmware for a large range of different routers, that allows to unleash some features that they don’t seem to have with stock firmware.

For this experiment, I used a Buffalo WHR-G300N, because it is cheap enough to burn if anything went wrong.

Flashing DD-WRT into Buffalo WHR-G300N

I’m not going to explain how this (long) step is done, so if you are looking for this information, please follow this link: http://www.dd-wrt.com/wiki/index.php/WHR-G300N

After having DD-WRT inside my router, I configured it as a client, connected to my home’s primary router, just like any other computer – my primary router would assign it an IP address, so I could access it through WEB/SSH/TELNET.
To configure all these services, I needed to connect an ethernet cable and do it locally. Then reboot the router, disconnect the cable and it should was connected to my primary router.

Serial Interface

Inside the G300N there is a Serial port, pleading to be hacked… :) See the following picture:

I just cut part of an old IDE drive cable (4 rows) and soldered 4 ends on the board and left the other 4 ends with standard 0.1″ male headers, so I could make some tests with a breadboard.
Here is it’s look after the mod:

Connecting router to Arduino

Pretty simple circuit:
Router — Arduino Board
GND — GND
TX — TX

This connections will allow Arduino to receive data from the router’s serial port.

Preparing Arduino

Well in this first test, I just “ignored” the micro-controller and made use of the FTDI chip on Arduino.
So I uploaded dummy program for test purposes:

void setup(){ }
void loop(){ }

After uploading, open Serial window of Arduino IDE and chose 57600 baud from the dropdown list (may be different if you use a different router – please search dd-wrt site form more information).
At this point, anything the router sends to its serial output will appear on this window.
Now let’s turn our attention to router.

Sending data from your computer to the router’s serial port

As I use a UNIX system, I prefer using an SSH connection. You can also use TELNET, as long as you have it configured in the router.
To open an SSH connection to router, open your Terminal/Console and type:

ssh root@

then enter your DD-WRT password.

Please note that the IP address you use depends on the connection you have to the router. If your router and you are both connected to the primary router, then you should use it’s client IP (assigned by the primary router). You can see this above on the Web GUI, on the right, search for “WAN IP:”. There it is! :D
On the other hand, if you have a direct connection to the router, it must be the local IP (192.168.1.1, or 192.168.2.1, or whatever you defined on basic setup as your Local IP).

We are now INSIDE the router. :D Whatever command you type will no longer be interpreted by your computer. Instead, will be sent directly to the router.
So for example, you can use the never old “ls” comand to list the main directory contents, for example:

ls /

Using the serial connection

To send an “hello world” to Arduino, just type:

echo hello world > /dev/tts/1

You should now see the message you just sent in the Arduino IDE’s Serial Window.
As simple as that.

Now realize I could have a Wi-fi controlled robot, for example. Hmmm… ;) See you.

About the author

Ricardo Dias

Ricardo Dias was born in Entroncamento, Portugal and is studying Electronic and Telecommunications Engineering at University of Aveiro. He is a researcher in robotics and is currently the Team Leader of CAMBADA@MSL team. As a hobby, he is also a freelancer Stage Lighting Designer.

Permanent link to this article: http://ricardo-dias.com/2011/02/25/dd-wrt-serial-and-arduino/

2 comments

  1. James Devine

    Great post! Very simple implementation. Keep up the good work.

  2. arssant

    Viva.
    Gostei, em particular da parte descritiva. Fui um pouco mais longe com a interactividade, dd-wrt e arduino, mas superas de longe a descrição do teu trabalho.

Leave a Reply

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