Go Down

Topic: communication with arduino via seral from linux (Read 1 time) previous topic - next topic


I am attempting to play with the wifly shield. I have some code which I have loaded to the arduino, but now I have to communicate with it via "terminal" - this is a windows example. How do I do this in linux? (ubuntu)


Doesn't the serial monitor in the Arduino IDE work for you?
Or do you want to communicate through the terminal, if so search for Linux tty.


Sep 25, 2010, 07:38 pm Last Edit: Sep 25, 2010, 07:40 pm by stephen_t Reason: 1
I use bash scripting

Code: [Select]

stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -clocal
cat /dev/ttyUSB0|head -n 6|tail -n 3 >> /root/arduino  #

The above sets ttyUSB0 to 115200 baud and reads the last 3 lines of 6 lines read into a file 'arduino' in roots home folder.  

I have the arduino sending data out in space delimited lines of text in groups of 3 lines continuously.  It reads 6 and takes the last 3 in case it joins the conversation part way through and corrupts the first line.  

I send single character commands back to the arduino
Code: [Select]

echo 'Z' > /dev/ttyUSB0

If it resets the arduino each time (it may or may not depending on your computer) stick something like a 1 - 10uF capacitor across gnd and the reset pin to 'swallow' the DTR auto reset pulse.

I have it all running through cron every minute to produce :



something like,

screen /dev/ttyUSB0 9600

should work, may have it the wrong way round, and I can't remember the default escape character to close the connection...

Or, use cutecom if you want a gui :)


After the mentioned stty lines, I've been using the following:
Code: [Select]
tail -f /dev/ttyUSB0

That way the AVR doesn't reset with every "cat" line.

To get serial data in, I just use
Code: [Select]
echo -n "something" > /dev/ttyUSB0

...or leave off the "-n" if a carriage return is needed.

Go Up