asus - arduino serial communication touch.n.go problem
asus - arduino serial communication touch.n.go problem
after installing openwrt on the router as per jeff's excellent instructions, communication with my arduino through ser2net or /dev/tts/0 works perfectly ... well sort of - sometimes after a cold reboot ... the arduino and router stop communicating through the serial (or networked) port.
i usually read and log the arduino console messages through the port using 'cat /dev/tts/0 >/tmp/logfile' and send messages to the arduino using ser2net in the form 'echo deviceOn >nc localhost 3008' or using telnet. vis versa works as well ... logging through ser2net and echoing messages to /dev/tts/0 directly. some cold reboots(un/plug power) result to the no data to or fro the arduino symptom. power cycling a few times seems to work when this problem randomly.
i have tried this with two different setups .i.e. different routers, shields n arduino setup. when i use my development usb on the arduino the sketch works consistently.
i have attached schematics (excuse the rat nest from my favorite program fritzing). the potential dividers are for sensor inputs with pull up/down resistors. the transistors are open collector drivers for relays. the arduino rx/tx on pins d0/1 are connected directly to the router tx/rx using a ribbon cable that is < 3'" through the shield.
in the attached picture, shown are the asus router, arduino(under the shield), shield, relays. the wires are for sensors and enclosure led's.
typical data from application can be seen at:
live data - http://kijanigrows.com/smartAquaponics
test alerts - http://twitter.com/#kijanigrows_tst
thanks in advance.
i usually read and log the arduino console messages through the port using 'cat /dev/tts/0 >/tmp/logfile' and send messages to the arduino using ser2net in the form 'echo deviceOn >nc localhost 3008' or using telnet. vis versa works as well ... logging through ser2net and echoing messages to /dev/tts/0 directly. some cold reboots(un/plug power) result to the no data to or fro the arduino symptom. power cycling a few times seems to work when this problem randomly.
i have tried this with two different setups .i.e. different routers, shields n arduino setup. when i use my development usb on the arduino the sketch works consistently.
i have attached schematics (excuse the rat nest from my favorite program fritzing). the potential dividers are for sensor inputs with pull up/down resistors. the transistors are open collector drivers for relays. the arduino rx/tx on pins d0/1 are connected directly to the router tx/rx using a ribbon cable that is < 3'" through the shield.
in the attached picture, shown are the asus router, arduino(under the shield), shield, relays. the wires are for sensors and enclosure led's.
typical data from application can be seen at:
live data - http://kijanigrows.com/smartAquaponics
test alerts - http://twitter.com/#kijanigrows_tst
thanks in advance.
-
- Posts: 109
- Joined: Sat Feb 13, 2010 4:27 am
- Location: Eindhoven, the Netherlands
Re: asus - arduino serial communication touch.n.go problem
You are apparently more knowledgeable about electronics than I am, but the first thing I though was an issue with voltage levels. As far as I know, the Asus routers have a 3.3V serial port, and the Arduino 5V. So at least between the Arduino TX and Asus RX pins, you would need some kind of level conversion. Jeff (and, therefore, me) does this with a simple voltage divider, but you can also use a dedicated level conversion chip such as the MAX232.
Could that be your issue?
Jeroen
Could that be your issue?
Jeroen
Re: asus - arduino serial communication touch.n.go problem
i am flattered ... much obliged Jeroen
i think i can see how the lack of signal conditioning could be a potential source for the intermittent problem on the tx/rx lines.
it had not occurred to me as the bread board prototypes worked without this symptom - perhaps the serial port wiring attenuated the 5v signal sufficiently.
i will try the fix you recommend and let you know what i find.
i think i can see how the lack of signal conditioning could be a potential source for the intermittent problem on the tx/rx lines.
it had not occurred to me as the bread board prototypes worked without this symptom - perhaps the serial port wiring attenuated the 5v signal sufficiently.
i will try the fix you recommend and let you know what i find.
-
- Posts: 109
- Joined: Sat Feb 13, 2010 4:27 am
- Location: Eindhoven, the Netherlands
Re: asus - arduino serial communication touch.n.go problem
I actually managed to blow up one of the serial ports on the Asus WL-500g by wiring it directly to my 5V breadboard. It became unreliable, and I was very happy the 500g has 2 serial ports, so at least I had the option of switching to the other one (which still works fine) as opposed to buying another router
Jeroen
Jeroen
Re: asus - arduino serial communication touch.n.go problem
much respects, jeroen - you suggestions i believe fixed the intermittent serial communication problem.
the 3.3v from the asus and 5v from arduino required logic level shifting. for some reason this problem did not appear while bread boarding.
i used the sparkfun logic level converter http://www.sparkfun.com/products/8745
just be sure to disregard the instructions and use the bidirectional mofet connections ... http://trandi.wordpress.com/2011/01/03/ ... o-arduino/ .... as the resistors are incorrectly biased.
the 3.3v from the asus and 5v from arduino required logic level shifting. for some reason this problem did not appear while bread boarding.
i used the sparkfun logic level converter http://www.sparkfun.com/products/8745
just be sure to disregard the instructions and use the bidirectional mofet connections ... http://trandi.wordpress.com/2011/01/03/ ... o-arduino/ .... as the resistors are incorrectly biased.
-
- Posts: 109
- Joined: Sat Feb 13, 2010 4:27 am
- Location: Eindhoven, the Netherlands
Re: asus - arduino serial communication touch.n.go problem
Excellent! Glad to be opf help.
Re: asus - arduino serial communication touch.n.go problem
greeting jeroen ... so my problems with the router and arduino loosing communication after reboot persisted. the logic level shift between the arduino and router never really helped.
the other problem i was having is that the arduino would do a soft reset for no reason at random times but consistently.
i was about to give up on this but my friend took a look at my code, suggested a fix ... and viola ... the arduino is not resetting, neither are the problems with the mis-communications happening.
the issue was solved by keeping an input bound check for makeSerialStringPositon preventing a stack/buffer overflow.
the other problem i was having is that the arduino would do a soft reset for no reason at random times but consistently.
i was about to give up on this but my friend took a look at my code, suggested a fix ... and viola ... the arduino is not resetting, neither are the problems with the mis-communications happening.
the issue was solved by keeping an input bound check for makeSerialStringPositon preventing a stack/buffer overflow.
Code: Select all
while (inByte != terminatingChar && Serial.available() > 0){ // As long as EOL not found and there's more to read, keep reading
serialReadString[makeSerialStringPosition] = inByte; // Save the data in a character array
////makeSerialStringPosition++; //Increment position in array
===> if (++makeSerialStringPosition > 20) break; //Increment position in array <===
//if (inByte > 0) Serial.println(inByte); // Debug line that prints the charcodes one per line for everything recieved over serial
inByte = Serial.read(); // Read next byte
////Serial.println(inByte);
}
Re: asus - arduino serial communication touch.n.go problem
the last post was actually the solution ... an input bound check on the serial line. -
the two problems were
-loss of communication during boot between arduino and assus
-arduino doing soft resets for no reason (uptime was never more than 8hrs)
i sniffed the the tx (arduino rx) output from the router further using an fdti cable.
the asus router sends strings of crap through the serial line when powering up ... the size is larger than my buffers and caused a buffer over on the arduino
the router further sends some funny DQ5 messages every so often - randomly. these where longer than my input string lengths .. again causing a buffer overflow on the arduino in the middle of operation. these come from the openwrt kernel. my serial console is disabled in inittab.
see attached pic's.
the scrolling commands are my test program trying to recreate the issue (i don't think it is tied to me).
asus router tx sniff on boot: assus router DQ5 messages from the kernel:
Code: Select all
if (++makeSerialStringPosition > 20) break; //Increment position in array
-loss of communication during boot between arduino and assus
-arduino doing soft resets for no reason (uptime was never more than 8hrs)
i sniffed the the tx (arduino rx) output from the router further using an fdti cable.
the asus router sends strings of crap through the serial line when powering up ... the size is larger than my buffers and caused a buffer over on the arduino
the router further sends some funny DQ5 messages every so often - randomly. these where longer than my input string lengths .. again causing a buffer overflow on the arduino in the middle of operation. these come from the openwrt kernel. my serial console is disabled in inittab.
see attached pic's.
the scrolling commands are my test program trying to recreate the issue (i don't think it is tied to me).
asus router tx sniff on boot: assus router DQ5 messages from the kernel:
Re: asus - arduino serial communication touch.n.go problem
I'm not sure what the DQ5 messages are, but the crap you get on start are all the bootup console messages. They are output at a different baud rate so all you get is a bunch of crap. I think boot messages on the serial port can be disabled, but then you are out of luck if something goes wrong and you need to debug.
Jeff Keyzer
http://mightyohm.com
http://mightyohm.com