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.
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");
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.
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.
#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");
}
}
}