Arduino + WRT54GL Serial Communication Problem

Hello All,

I'm in the process of wiring a WRT54GL v1.1 to and Arduino Uno via serial tx/rx (digital 0, 1). I'm able to SSH into WRT; echo Occupy WRT > /dev/ttys/1 and read this in the serial monitor. Though I have been unable to receive anything but garbage from the following program using cat /dev/tts/1.

void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.write("Occupy WRT");
}

Perhaps this is a baud rate issue though I was under the impression the DDWRT WRT54gl runs at 115200.

I'm using a sparkfun logic level converter between the arduino and wrt54gl, wired like this;

WRT54G - Logic Level Converter - Arduino
1 - LV - HV - 5V
3 - RX0 - RXI - D0/RX
5 - TXI - TX0 - D1/TX
9 - GND - GND - GRND

Any thoughts or hints would be great!!

Still hacking away to no avail. I've tried setting the arduino serial.begin statement to 9600, 115200 and a number of others and still only receive gibberish. I've double checked my connections and given that wrt54gl -> arduino serial monitor works fine and i get gibberish going the other way it would seem the physical connections are good. And that the problem is software based. I imagine the problem is pretty obvious as connecting a wrt to an arduino is fairly well documented. Though I've gone through all the information I can find and I think I did everything correctly, though the problem remains. Thanks in advance for any help.

Also I'm running DD-WRT, it seems like many are using OpenWRT...is this maybe my problem?

The router probably gets a little confused after the first several thousand "Occupy WRT" messages. At that baud rate, you are probably sending a thousand login requests per second. Move the Serial.write("Occupy WRT") to the setup() rather than loop() for a test. That way it will send only one request.

Add: You should change that to
Serial.println("Occupy WRT");
or
Serial.write("Occupy WRT\r\n");

That will send a CR-LF.

Thank you SurferTim,

I had since put in a delay, however for the sake of your statement, I uploaded this;

void setup() {
  Serial.begin(115200);
  Serial.write("Occupy WRT");
}
void loop() {}

Still I get gibberish...out of the SSH session on the WRT via cat /dev/tts/1

Additionally, the gibberish only comes across when I upload to the Arduino. Though I get nothing on an Arduino reset, regardless if on external or USB power.

Doesn't the router need a CR-LF after the command? Serial.write() doesn't send a cr-lf unless you tell it to.

Serial.write("Occupy WRT\r\n");

Alright, so I'm using this code now:

void setup() {
  Serial.begin(115200);
  Serial.write("Occupy WRT\r\n");
}
void loop() { 
}

cat /dev/tts/1 results in:

ÿÿÿÿÿÁÁàþÿúññúþ:1R (though this result varies quite a bit)

Additionally, this result only occurs when I upload to the Arduino. Though it doesn't occur when I reset. Thanks again..

Alright, I've made some great progress. I have put aside using Digital 1 & 0 UART Interface and instead am using NewSoftSerial. The program should accept a "1" or "0" from the WRT and turn the LED (Pin13) ON and Off.

It seems, from WRT to Arduino works fine but from Arduino to WRT, echos on Arduino UART.

The serial monitor echoes everything sent to the WRT otherwise it seems to work pretty well.

The wiring is as follows:

WRT54GL Level Converter ARDUINO
======== ============== ========
Pin 3 TX(ttyS1) TXI TXO D Pin 2
Pin 5 RX(ttyS1) RXO RXI D Pin 3
Pin 1 (3.3v) LV HV 5v
Pin 10 (Gnd) GND GND GND
Pin 6 RX(ttyS0) RXO RXI
Pin 4 TX(ttyS0) TXI TXO

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);
int inByte;         // incoming serial byte

void setup()  
{
  Serial.begin(57600);
  Serial.println("Serial Monitor Occupied!");

  // set the data rate for the NewSoftSerial port
  mySerial.begin(9600);
  mySerial.println("NewSoftSerial WRT link Occupied!!");
  
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);   // set the LED off

}

void loop()                     // run over and over again
{

  if (mySerial.available()) {
      Serial.println((char)inByte);
//      Serial.print((char)mySerial.read());
     inByte = mySerial.read();
     if ((char)inByte == '1'){
       digitalWrite(13, HIGH);   // set the LED on
       mySerial.println("Light is On");
     }
     if ((char)inByte == '0'){
       digitalWrite(13, LOW);   // set the LED off
       mySerial.println("Light is Off");
     }
 
      
  }


}

Let me know your thoughts.