Last time, I installed OpenWRT on the TL-MR3220 router and added a connector for it’s serial interface. Today, I wanted to try and connect this interface to an Arduino to make the two communicate. The router’s interface operates at 3.3V while the Arduino’s UART operates at 5V, so we need to convert between those levels. The cheapest way to do this that I could find is described here. It involves using a 74LS04 hex inverter chip to convert the 3.3V signal up to 5V and two resistors for a simple voltage divider to convert the 5V signal down to 3.3V.
The hardware setup and wiring is shown in the picture above. To test the connection, I uploaded a simple sketch to the Arduino that will let the pin 13 LED blink and that transmits the LED status over the serial interface:
static int count = 0; void setup() { pinMode(13, OUTPUT); Serial.begin(9600); } void loop() { Serial.print("Turn #"); Serial.println(++count); digitalWrite(13, HIGH); Serial.println("LED ON"); delay(1000); digitalWrite(13, LOW); Serial.println("LED OFF"); delay(1000); }
On the OpenWRT based router I first disabled the serial console by commenting it out in /etc/inittab. (Make sure that you have other ways ready to connect to the router like SSH before you do this!)
::sysinit:/etc/init.d/rcS S boot ::shutdown:/etc/init.d/rcS K shutdown # Disabled serial console. #ttyS0::askfirst:/bin/ash --login
Then I installed screen as a terminal software using opkg and I was able to listen to the status reports sent by the arduino.
root@tplink:~# opkg update root@tplink:~# opkg install screen root@tplink:~# screen /dev/ttyS0 9600
Pingback: Wifi Enabled RGB Matrix Wall Light, Part 1 | hackup.net
Very nice project, congratulations. Why haven’t used the mr3220 usb port to communicate with arduino?
I was prototyping the connection for an Arduino compatible board called Rainbowduino which does not feature an USB port. Also, I wanted to save the router’s USB port for a flash drive.