Testing connection arduino with wrt54gl

Hi ,
Sorry i'm still a beginner to arduino. I'm trying to make a wifibot like the one on this site: Wifi Robot - JBProjects.net

I connected the arduino to wrt54gl through max3232 similar to this: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1268245421/all

Now i'm trying to test the connection. I ssh to the router and am typing this command: echo 'hello' > /dev/tts/1
I'm trying to read the word hello through my serial monitor of the arduino. If i had connected the router to pin 0 (Rx) and pin 1(Tx) of the arduino, could I connect the usb to the pc and follow through the serial monitor, or i have to use softserial just for testing this?

Thanks alot, and sorry for wasting your time

Can you post your Arduino code as I have too little information to give advise.

echo 'hello' > /dev/tts/1

Have you set the same baudrate?
Is the router's serial port TTL level? (the arduino is? OK the max2323 should fix, is it needed BTW)

When you do the echo thing, are there any transmission leds or so to confirm the data?

Thanks for the reply. Yes they have both the same baud rate set at 9600.

My arduino code:

int number = 0;

void setup() {
	Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
        pinMode(13, OUTPUT); 
        
}

void loop() {

	// send data only when you receive data:
	if (Serial.available() > 0) {
		// read the incoming byte:
		number = Serial.read();
                
                if (number == '55') {
                    digitalWrite(13, HIGH);   // set the LED on
                    delay(1000);              // wait for a second
                    digitalWrite(13, LOW);    // set the LED off
                    delay(1000);  
		}
	}
}

line inputted on putty:

root@OpenWrt:~$ echo '55' > /dev/tts/1

echo '55' wil write two char's to the serial bus

modded your code a bit, to test a single char at a time

void setup() 
{
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  pinMode(13, OUTPUT);    
}

void loop() 
{
  char c;

  // send data only when you receive data:
  if (Serial.available() > 0)
  {
      c= Serial.read();
      if (c == '5') 
      {
        digitalWrite(13, HIGH);   // set the LED on
        delay(1000);              // wait for a second
        digitalWrite(13, LOW);    // set the LED off
        delay(1000); 
      }      
      if (c == '1') 
      {
        digitalWrite(13, HIGH);
        delay(100);              
        digitalWrite(13, LOW);    
        delay(100); 
      }
   }
}

Then try this
try echo '51515' > /dev/tts/1

A serial port transfers a byte a the time.
It is upon the sender/receiver to interpret it as a char, a (part of a) number, or anything.
Sending chars and expecting numbers or otherwise causes errors unless done on purpose.
In this latter case one must reassemble the number from char's by a function like atoi(),

Rob

Thanks for spending some time to help me :slight_smile:
But it didn't work either :frowning:

root@OpenWrt:~$ ls -l /dev/tts
crw------- 1 root root 4, 64 Jan 1 02:32 0
crw------- 1 root root 4, 65 Jan 1 02:38 1

the serial port is detected, but i don;t know y it is not working

Could it be:

dmesg | grep tty
ttyS00 at 0xb8000300 (irq = 3) is a 16550A
ttyS01 at 0xb8000400 (irq = 0) is a 16550A

serial is not set to irq 3?

I tried connecting the router directly with arduino.
Arduino code:

void setup() {
   Serial.begin(9600);
}
   void loop() {
      Serial.write("Hi, I am alive!");
   }

Router output using cat /dev/tts/1

root@OpenWrt:~$ cat /dev/tts/1
I am alive!Hi, I am alive!Hi, I am
P( R                                                                           )P$AHI                                                                          )P$X@¤!@%!
         PR¸PJ)VXPuTTYAÂ        J(V H@PuTTYPuTTYi a!H$@
                                                        P,@PuTTYaPJ(@-HP´@PuTTYa@Ò
R¬AP¥Q
       ¤aAaiaÒJ(B)Hi%PuTTYPuTTY
 P-@X
     iPB!
P)PuTTY@XBaia@i IWP @ZI AiAÐ¥!Z
H


B       Pih$ai a (i!H
)V PuTTYXiaH(I +@$PZ@
J

E!P$B¤@aa$aB¡R !h       pEI

P$@aA@%
UR(ZaH(@H
J
PuTTYPuTTY
                P)@X@Ahp!HPuTTY(
J*
        P)@@ZÐ(
        P)PuTTY@HZi a
)@¤@i!!!P
 P-@X

BP@XhB!BJ(V%PuTTYPuTTYPuTTY@ 
B
 aPuTTYPuTTY ia¡
P hApÒR
       PÐ
"
BPHH!@à

"%PuTTYPuTTY@RiÒ


 i i!!!PJ(P-@Hi aPuTTPJ(V!X*PuTTY%@@aa@

¤@PuTTYPuTTYa hÂB
                 RPuTTYPuTTYa    Ah$                                           @)@PZ!à

B¤@A%
B +  PuTTY I@B

¤RPuTTYPuTTY    @

@ V PI +@I!Ò

+ XH
    AP
)P-@X   ÂB
         R)RPuTTYhÂB¤@aE !hPuTTYÂ       PH@Z!hAPuTTYaH(@
)¨¸PuTTY
R ZaIpEPuTTYPuTTYi
E

@@
+¤HH J(PPuTTY-@X
                PuT@)@HZaiA!i(

R,P¸"
P¬@PuTTYa

 P!PuTTYH!
                                                                               P)HPuTTYXAP¥Q
@RH
`@È aH  È  a"
              @ @` ( @
J
a@@`  r @ @a
0@a   PuTTY (@
 ÂH
`
 
   @@
@
À @
P@@ H¡(`È`H$PuTTY   äP` `J       @
¤B      `PuTT H!`@C
                    ( @À`DÂ @
@À
0"
  `@   a@0À`H``@
 `È `
 @ `@@`
      ÀÀ
` À
ÈB` ``È $P0@
 `@@@0À` `À `
0@À
0"À@ r`I am alive!Hi, I am alive!Hi, I am
P( R                                                                           )P$AHI                                                                          )P$X@¤!@%!
         PR¸PJ)VXPuTTYAÂ        J(V H@PuTTYPuTTYi a!H$@
                                                        P,@PuTTYaPJ(@-HP´@PuTTYa@Ò
R¬AP¥Q
       ¤aAaiaÒJ(B)Hi%PuTTYPuTTY
 P-@X
     iPB!
P)PuTTY@XBaia@i IWP @ZI AiAÐ¥!Z
H


B       Pih$ai a (i!H
)V PuTTYXiaH(I +@$PZ@
J

E!P$B¤@aa$aB¡R !h       pEI

P$@aA@%
UR(ZaH(@H
J
PuTTYPuTTY
                P)@X@Ahp!HPuTTY(
J*
        P)@@ZÐ(
        P)PuTTY@HZi a
)@¤@i!!!P
 P-@X

BP@XhB!BJ(V%PuTTYPuTTYPuTTY@ 
B
 aPuTTYPuTTY ia¡
P hApÒR
       PÐ
"
BPHH!@à

"%PuTTYPuTTY@RiÒ


 i i!!!PJ(P-@Hi aPuTTPJ(V!X*PuTTY%@@aa@

¤@PuTTYPuTTYa hÂB
                 RPuTTYPuTTYa    Ah$                                           @)@PZ!à

B¤@A%
B +  PuTTY I@B

¤RPuTTYPuTTY    @

@ V PI +@I!Ò

+ XH
    AP
)P-@X   ÂB
         R)RPuTTYhÂB¤@aE !hPuTTYÂ       PH@Z!hAPuTTYaH(@
)¨¸PuTTY
R ZaIpEPuTTYPuTTYi
E

@@
+¤HH J(PPuTTY-@X
                PuT@)@HZaiA!i(

R,P¸"
P¬@PuTTYa

 P!PuTTYH!
                                                                               P)HPuTTYXAP¥Q
@RH
`@È aH  È  a"
              @ @` ( @
J
a@@`  r @ @a
0@a   PuTTY (@
 ÂH
`
 
   @@
@
À @
P@@ H¡(`È`H$PuTTY   äP` `J       @
¤B      `PuTT H!`@C
                    ( @À`DÂ @
@À
0"
  `@   a@0À`H``@
 `È `
 @ `@@`
      ÀÀ
` À
ÈB` ``È $P0@
 `@@@0À` `À `
0@À
0"À@ r`@

What do the other symbols means?

Thanks for helping!

It can mean several things:

  1. the data comes in too fast for the serial port. As you run 9600 baud this is not likely to be the cause.,
  2. It might be that another process is communicating with the same port on another baudrate (or even same baudrate) as I see the name PUTTY a well known serial application.

If you connect the Arduino to a normal PC does it work?
If you connect the WRT to a normal PC does it work?

I short-circuited the router tx with rx, and listened to it, it worked well.

Could someone please help? I've been searching d net for ages without finding any concrete answers :frowning:

From your first post

If i had connected the router to pin 0 (Rx) and pin 1(Tx) of the arduino, could I connect the usb to the pc and follow through the serial monitor, or i have to use softserial just for testing this?

yes should work,

I don't have an openWrt so I can't repeat your experiments.

Does "ps " gives info about other processes using the tty port?

I managed to get the communication up and running correctly. However i connected the rx of arduino with tx of router and viceversa. Is it a problem, that arduino tx and rx are at 5V and routers tx and rx are at 3.3V. Should i regulate the voltage, or there's no harm if i leave it like that? The Max3232 connection i showed on first post seems it doesn't work.

Thanks for your interest in helping me sir, i really appreciate it :slight_smile:

Serial should always be wired Tx->Rx (transmitting to receiving). As for the different logic levels, your only risk is to the router. It all depends on if it is 5v-tolerant. If you are concerned, just use a simple voltage divider on the arduino tx/router rx line.

Good luck!

I managed to get the communication up and running correctly.

please post a drawing/picture for futher reference.

Should i regulate the voltage, or there's no harm if i leave it like that?

see bilbo's answer. You might check this on a openwrt forum on this one.

newbiestudent:
I managed to get the communication up and running correctly. However i connected the rx of arduino with tx of router and viceversa. Is it a problem, that arduino tx and rx are at 5V and routers tx and rx are at 3.3V. Should i regulate the voltage, or there's no harm if i leave it like that? The Max3232 connection i showed on first post seems it doesn't work.

Thanks for your interest in helping me sir, i really appreciate it :slight_smile:

Hi, please follow this and find the "voltage divider" technique that is used there between WRT and SSC-32 motor controller. Do the same between Arduino and WRT. I remember I did it this way and everything was fine. Hope this helps :slight_smile:

10x alot for the replies.
10x ironbot, the link you gave me is very helpful :slight_smile:

Hopefully i won't annoy more :smiley: hehe

I used the LD1117V33 regulator with capacitors attached as can be seen here: http://www.kobakant.at/downloads/stencils/9V-3VRegulator.pdf

It worked... however i think i had some bits shifted since there was some delay created by the capacitors.
As soon as i removed the capacitors, the message i was writing appeared correctly. So now i'm able to communicate between the router and the arduino. The advantage of this is that is bi-directional :slight_smile:

Tks ironbot for the intereset in helping me :slight_smile: