Pages: [1]   Go Down
Author Topic: communication with arduino via seral from linux  (Read 1093 times)
0 Members and 1 Guest are viewing this topic.
Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Java Devloper. Building my 2nd bot (1st arduino)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Stockholm
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I use bash scripting

Code:
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:
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 :

http://pluggy.is-a-geek.com/
« Last Edit: September 25, 2010, 12:40:29 pm by stephen_t » Logged


UK
Offline Offline
Full Member
***
Karma: 1
Posts: 131
mini mini mini
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

DFW, Texas
Offline Offline
Newbie
*
Karma: 0
Posts: 15
we are all borg
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

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

Pages: [1]   Go Up
Jump to: