Hi,
I am trying to read from Arduino which is a TTL board into a router that works on LVTTL (3.3v) called WRT54GL, with max3232.
I've first done these tests:
Connected TX of serial port of the router to Arduino directly, and issued commands, and all work fine.
I shorted TX and RX of the router to test if the port is working properly. I issued "echo hello" from TX and I had it right from RX back to the router. So this also worked fine.
Next, I used a schema I found online to connect them via max3232. I repeated the above test #1, but with the max3232 added in the middle, and it failed to work. I checked things more than 15 times, but no result. I'll provide the schema I used here, please give some ideas to help!
You don't need (or want) a max232; both the Arduino and the router are operating at digital signal levels. Now, the router has 3.3V signals and the Arduino has 5V signal levels, but a max232 is not the right chip to interface them (I guess you COULD use two - one to convert the arduino to rs232 levels, and one to convert the router to rs232 levels, but that seems excessive.)
You may be able to connect them directly. Sometimes 3.3V chips are "5V tolerant." Otherwise, the router output is compatible with the arduino input, and the arduino output could use a simple voltage divider to connect to the router input.
You are right, I corrected the RX, TX locations on the photo, but still I receive no input in the router, or strange characters! If I send "hello world" from Arduino to the router, sometimes I get some wild characters, sometimes nothing!
//test wrt54gl router serial communication
//worked_ok
char val = 0;
int RedPin = 10;
int GreenPin = 8;
int BluePin = 9;
int HelloPin = 4;
void setup()
{
Serial.begin(115200);
pinMode(GreenPin, OUTPUT);
pinMode(RedPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(HelloPin, INPUT);
digitalWrite(GreenPin, LOW);
digitalWrite(RedPin, LOW);
digitalWrite(BluePin, HIGH);
delay(5000);
}
void loop()
{
if(digitalRead(HelloPin)==HIGH)
Serial.println("hello");
while (Serial.available())
{
//digitalWrite(GreenPin, LOW);
val = Serial.read();
if ((char)val == 'A')
{
digitalWrite(RedPin, LOW);
digitalWrite(GreenPin, HIGH);
delay(5000);
}
}
}
and I've got some output that shows the serial connection indeed exists, but it is somehow "noisy" or has errors.
When I put HIGH on my 4th pin, I get a strange repeating character chain, in place of "hello\n\r". Then, after I just remove the pin, I get lot of strange characters too, but repetition is stopped. The behavior is regular: when I connect HIGH to the 4th pin the repetition starts and by disconnecting, it stops. I provide a shot screen here. The upper side are what I receive in place of "hello", which is regular repetition, and the second part is the strange unwanted characters.
Any ideas?!
hmm.
very confusing, looked at the characters recived and I concluded this...
sending hello
in binary 0110100001100101011011000110110001101111
recived /5''!
in binary 0010111100110101001001110010011100100001
shift bits 1 bit to right (highlighted by *) you get the inverse of what it should be
0010111100110101001001110010011100100001 - you received
*0010111100110101001001110010011100100001 - shifted
0110100001100101011011000110110001101111 - should be
Over the chrismas holidays last year I was trying to do exactly what you want to do, namely hook up an arduino to the serial port and use firmata on the Arduino to allow me to put the WRT54GL to better use than its current job.
As westfw says don't use a max 232 because you will blow the Arduino for sure. The arduino and any other microcontroller is ideal to interface with WRT54GL because they both have serial ports running at logic levels and there is no need to worry about drivers like the 232. What you will need is a level translator something simple like this http://www.daycounter.com/Circuits/Level-Translators/Level-Translators.phtml is what I was going to use.
I never proceeded with the project because I was struggling with getting a working Openwrt toolchain so that I can compile my own programs. I suspect the problem was because I was running Linux under windows, but I was getting lots of little compile time errors which I was combating but it to much time. I didnt have the time to back up my hard drive and install a proper linux install so that I could do it natively under linux.
At present the WRT54GL is sitting gathering dust but I plan to go back to this project. But for me its useless unless I can compile my own code to run on the WRT54GL, but I might just go back to that project again now.
Matrixis!
Many thanks for your calculations!
Now I am very tired, but after some rest I will try to write a program that does the conversion you suggest in Arduino, and then send serial to the router. I think it will be the solution! (hope)
Zageek!
Many thanks for the suggestion!
Indeed as I explained in posts before this, I tried all the various implementations I could find over the internet, including transistor solution you mentioned. None of them gave ANY data I could work on! This max3232 is not exactly max232! It is different and exactly used for both 3.3v<->RS232, AND, 3.3v<5v logic conversion. So I will hold on it and try to interpret this output I have. Actually, my main purpose is to use a motor controller called ssc-32 with the router, which has the same problem now, and Arduino is a test-tool here.
Tell me your configuration. Better: draw a block-diagram, or post a photo, and I'll try to help! Commands to ssc-32 must contain #, as this is telling the position of motors to the controller.
It's a very simple connection to make between the two. I have already been able to send an ASCII table (one of the Example Sketches in Processing) from my Arduino to my router.
I have dd-wrt installed on it and listened to the serial input by typing:
cat < /dev/cua 1
and I saw the whole ASCII table streaming in, which was nice
I can't get the communication to work in the other direction though.
This is the sketch I uploaded into the Arduino:
Then I typed the following in the ssh session on my router:
echo Hello > /dev/cua/1
I get no response in my serial port monitor on the arduino side... I think the problem may be in the arduino code, maybe I have to tell the arduino not to listen to the hardware serial port (USB) but to the Rx Tx pins (0 and 1)?
My problem is not the hardware connection between Arduino and WRT router. I think I've got that part right (I can send serial data from the Arduino to the router).
I just don't know if I make the Arduino listen to the router serial output the right way.