arduino yun communication ( /dev/ttyACM0 )

Hello,

I am using Arduino YUN and Arduino Xbee Shield PRO ( with modem xbee series 2 - znet 2.5 )

Please see my Xbee Shield PRO : http://www.cutedigi.com/images/09063-03-L-Xbee_shield-1.jpg

I have tested 2 xbee radios. They work perfectly. They have been configurated with X-CTU correctly and tested with 2 Arduino UNOs.

My problem is that, while using arduino yun with xbee shiled on, the program x-ctu does not see xbee modem( not mentioned about problem with getting data from second xbee )

I have put a code to the yun, changed pin RX : 2 - 13 , TX : 3 - 5, started X-CTU program and I’ve got no response ! =(
the post with similar problem I was working with : http://forum.arduino.cc/index.php?topic=196606.msg1455320#msg1455320

#include <SoftwareSerial.h>
SoftwareSerial _serial(13, 5); // RX, TX
void setup(){}
void loop{}

Does anyone know how to configure my xbeeshield and yun to receive data from another xbee ?

so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

Thank You sonnyyu for your replay :slight_smile: :slight_smile:

I moved RX,TX to every available pin for RX,TX and no response.
It seems that Arduino Yun is not compatible with this xbee shield :frowning:

Question:
How can I create communication between YUN and UNO by using (YUN) USB HOST and (UNO) USB port ?

I would like to send/read data from UNO to YUN, then YUN will send it to http.

Please for direct instructions how to integrate this YUN port to read/send data.

Many thanks for any help !!! :slight_smile:

All you need is kmod-usb-acm and a program to use the data that comes in on /dev/ttyACM0.

To demonstrate, first upload the Communication->ASCII Table sketch to your Uno then ssh into the Yun and install kmod-usb-acm and picocom and when you plug the Uno into the USB host port you have a connection just like you plugged the Uno into a normal Linux box:

root@Arduino:~# opkg update
Downloading http://download.linino.org/dogstick/all-in-one/latest/packages//Packages.gz.
Updated list of available packages in /var/opkg-lists/barrier_breaker.
Downloading http://download.linino.org/dogstick/all-in-one/latest/packages//Packages.sig.
Signature check passed.
root@Arduino:~# opkg install kmod-usb-acm
Installing kmod-usb-acm (3.8.3-1) to root...
Downloading http://download.linino.org/dogstick/all-in-one/latest/packages//kmod-usb-acm_3.8.3-1_ar71xx.ipk.
Configuring kmod-usb-acm.
root@Arduino:~# opkg install picocom
Installing picocom (1.7-1) to root...
Downloading http://download.linino.org/dogstick/all-in-one/latest/packages//picocom_1.7-1_ar71xx.ipk.
Configuring picocom.
root@Arduino:~# picocom -b 9600 /dev/ttyACM0 
picocom v1.7

port is        : /dev/ttyACM0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Terminal ready
ASCII Table ~ Character Map
!, dec: 33, hex: 21, oct: 41, bin: 100001
", dec: 34, hex: 22, oct: 42, bin: 100010
#, dec: 35, hex: 23, oct: 43, bin: 100011
$, dec: 36, hex: 24, oct: 44, bin: 100100
%, dec: 37, hex: 25, oct: 45, bin: 100101
&, dec: 38, hex: 26, oct: 46, bin: 100110
', dec: 39, hex: 27, oct: 47, bin: 100111
(, dec: 40, hex: 28, oct: 50, bin: 101000
), dec: 41, hex: 29, oct: 51, bin: 101001
*, dec: 42, hex: 2A, oct: 52, bin: 101010
+, dec: 43, hex: 2B, oct: 53, bin: 101011
,, dec: 44, hex: 2C, oct: 54, bin: 101100
-, dec: 45, hex: 2D, oct: 55, bin: 101101
., dec: 46, hex: 2E, oct: 56, bin: 101110
/, dec: 47, hex: 2F, oct: 57, bin: 101111
0, dec: 48, hex: 30, oct: 60, bin: 110000
1, dec: 49, hex: 31, oct: 61, bin: 110001
2, dec: 50, hex: 32, oct: 62, bin: 110010
3, dec: 51, hex: 33, oct: 63, bin: 110011
4, dec: 52, hex: 34, oct: 64, bin: 110100
5, dec: 53, hex: 35, oct: 65, bin: 110101
6, dec: 54, hex: 36, oct: 66, bin: 110110
7, dec: 55, hex: 37, oct: 67, bin: 110111
8, dec: 56, hex: 38, oct: 70, bin: 111000
9, dec: 57, hex: 39, oct: 71, bin: 111001
:, dec: 58, hex: 3A, oct: 72, bin: 111010
;, dec: 59, hex: 3B, oct: 73, bin: 111011
<, dec: 60, hex: 3C, oct: 74, bin: 111100
=, dec: 61, hex: 3D, oct: 75, bin: 111101
>, dec: 62, hex: 3E, oct: 76, bin: 111110
?, dec: 63, hex: 3F, oct: 77, bin: 111111
@, dec: 64, hex: 40, oct: 100, bin: 1000000
A, dec: 65, hex: 41, oct: 101, bin: 1000001
B, dec: 66, hex: 42, oct: 102, bin: 1000010
C, dec: 67, hex: 43, oct: 103, bin: 1000011
D, dec: 68, hex: 44, oct: 104, bin: 1000100
E, dec: 69, hex: 45, oct: 105, bin: 1000101
F, dec: 70, hex: 46, oct: 106, bin: 1000110
G, dec: 71, hex: 47, oct: 107, bin: 1000111
H, dec: 72, hex: 48, oct: 110, bin: 1001000
I, dec: 73, hex: 49, oct: 111, bin: 1001001
J, dec: 74, hex: 4A, oct: 112, bin: 1001010
K, dec: 75, hex: 4B, oct: 113, bin: 1001011
L, dec: 76, hex: 4C, oct: 114, bin: 1001100
M, dec: 77, hex: 4D, oct: 115, bin: 1001101
N, dec: 78, hex: 4E, oct: 116, bin: 1001110
O, dec: 79, hex: 4F, oct: 117, bin: 1001111
P, dec: 80, hex: 50, oct: 120, bin: 1010000
Q, dec: 81, hex: 51, oct: 121, bin: 1010001
R, dec: 82, hex: 52, oct: 122, bin: 1010010
S, dec: 83, hex: 53, oct: 123, bin: 1010011
T, dec: 84, hex: 54, oct: 124, bin: 1010100
U, dec: 85, hex: 55, oct: 125, bin: 1010101
V, dec: 86, hex: 56, oct: 126, bin: 1010110
W, dec: 87, hex: 57, oct: 127, bin: 1010111
X, dec: 88, hex: 58, oct: 130, bin: 1011000
Y, dec: 89, hex: 59, oct: 131, bin: 1011001
Z, dec: 90, hex: 5A, oct: 132, bin: 1011010
[, dec: 91, hex: 5B, oct: 133, bin: 1011011
\, dec: 92, hex: 5C, oct: 134, bin: 1011100
], dec: 93, hex: 5D, oct: 135, bin: 1011101
^, dec: 94, hex: 5E, oct: 136, bin: 1011110
_, dec: 95, hex: 5F, oct: 137, bin: 1011111
`, dec: 96, hex: 60, oct: 140, bin: 1100000
a, dec: 97, hex: 61, oct: 141, bin: 1100001
b, dec: 98, hex: 62, oct: 142, bin: 1100010
c, dec: 99, hex: 63, oct: 143, bin: 1100011
d, dec: 100, hex: 64, oct: 144, bin: 1100100
e, dec: 101, hex: 65, oct: 145, bin: 1100101
f, dec: 102, hex: 66, oct: 146, bin: 1100110
g, dec: 103, hex: 67, oct: 147, bin: 1100111
h, dec: 104, hex: 68, oct: 150, bin: 1101000
i, dec: 105, hex: 69, oct: 151, bin: 1101001
j, dec: 106, hex: 6A, oct: 152, bin: 1101010
k, dec: 107, hex: 6B, oct: 153, bin: 1101011
l, dec: 108, hex: 6C, oct: 154, bin: 1101100
m, dec: 109, hex: 6D, oct: 155, bin: 1101101
n, dec: 110, hex: 6E, oct: 156, bin: 1101110
o, dec: 111, hex: 6F, oct: 157, bin: 1101111
p, dec: 112, hex: 70, oct: 160, bin: 1110000
q, dec: 113, hex: 71, oct: 161, bin: 1110001
r, dec: 114, hex: 72, oct: 162, bin: 1110010
s, dec: 115, hex: 73, oct: 163, bin: 1110011
t, dec: 116, hex: 74, oct: 164, bin: 1110100
u, dec: 117, hex: 75, oct: 165, bin: 1110101
v, dec: 118, hex: 76, oct: 166, bin: 1110110
w, dec: 119, hex: 77, oct: 167, bin: 1110111
x, dec: 120, hex: 78, oct: 170, bin: 1111000
y, dec: 121, hex: 79, oct: 171, bin: 1111001
z, dec: 122, hex: 7A, oct: 172, bin: 1111010
{, dec: 123, hex: 7B, oct: 173, bin: 1111011
|, dec: 124, hex: 7C, oct: 174, bin: 1111100
}, dec: 125, hex: 7D, oct: 175, bin: 1111101
~, dec: 126, hex: 7E, oct: 176, bin: 1111110

Thanks for using picocom
root@Arduino:~#

To exit picocom use <ctrl>a <ctrl>x

Thank You noblepepper for your replay !! :slight_smile:

I apologize for noob questions… I have never uploaded any of this code to the UNO/YUN :):slight_smile:

  1. Do I need any program to do it ?
  2. How can I install the kmod-usb-acm ?

In my example above, use the Arduino IDE to upload the sketch to the UNO, after that plug the UNO into the Yun's USB host port.

Opkg intalls things in Linino, to ssh into the Yun and use opkg, use PuTTY Download PuTTY: latest release (0.76) if you are on windows, on Linux you just use ssh in a terminal window. Once you are in a ssh session you execute the commands as I show above.

Thank You noblepepper for Your replay !!! :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:
Could You please check my steps before I mess up any of the arduinos boards :slight_smile: ?

  1. Step ONE , Uploading the ascii sketch to the UNO :
void setup()
 { 
  Serial.begin(9600); 
  Serial.println("ASCII Table ~ Character Map");
}
  int thisByte = 33; 
void loop() { 
  Serial.write(thisByte);   
  Serial.print(", dec: "); 
  Serial.print(thisByte);      
  Serial.print(", hex: "); 
  Serial.print(thisByte, HEX);     
  Serial.print(", oct: "); 
  Serial.print(thisByte, OCT);     
  Serial.print(", bin: "); 
  Serial.println(thisByte, BIN);   
  if(thisByte == 126){
    while(true) { 
      continue; 
    } 
  } 
  thisByte++;  
}
  1. Step TWO : Connecting Uno to the Yuns USB port.
  2. Step THREE : Upload arduino YUN sketch :
void setup()
 { 
  Serial.begin(9600); 
}
void loop() 
{
  if(Serial.available())
{
 Serial.println(Serial.read());
}
 }
  1. Step FOUR : Configure and run Putty ( Configuration is shown on attached pictures )
  2. Insert Commands using putty window :

root@Arduino:~# opkg update
root@Arduino:~# opkg install kmod-usb-acm
root@Arduino:~# opkg install picocom
root@Arduino:~# picocom -b 9600 /dev/ttyACM0

  1. Dance on the table ( if it works ) :slight_smile:

Thank You noblepepper , your solution worked !!!!!!! :slight_smile: :slight_smile: I can see my ascii table in Putty window.

Is it possible to implement this code in the Arduino IDE sketch ?

I tryed to run a ShellCommand and see in the serial monitor if I get any data from this usb - no response :frowning:

Please for quick sketch example how to SEND / RECEIVE data from this USB ...

In the first screenshot you show, PuTTY would connect to what ever is connected to COM1 on your windows box. You should select SSH in this dialog.

In the setup I describe the Leonardo part of the Yun would not be involved, you don't need any particular sketch there. The ssh connection will be to the Linino part of the Yun.

I would like to send/read data from UNO to YUN, then YUN will send it to http.

Once you have the Uno on /dev/ttyACM0 in linino you can go several ways to accomplish this, the most obvious is to modify the bridge code in linino to use /dev/ttyACM0 instead of /dev/ttyATH0, I don't know enough Python to help you there.

Thank You noblepepper for your replay

Could You please send me any example showing how to run the incoming data form UNO in the YUNs serial monitor ?

I have no idea how to initiate connection with lininio using arduino ide ...

many many thanks

You will need to put together a program for Linino that handles communications between the two serial ports. Linino is a miniature linux environement, you can find lots of information on writing Linux programs with google.

The arduino IDE is for programming the ATMEL processors that are used in the Leonardo and Uno, it is not designed to do general Linux programming.

Thank You noblepepper for your replay

The problems gets more and more complicated.
Putty reads very nice from the YUNs USB Host. Data flows very fast and it is nice and readable!

But why the hell I have this USB host in my YUN while I can not use any incoming data in my atmega ?? :~ :~ :~

While I use in my arduino YUN :

#include <Process.h>

void setup()
 {
  Bridge.begin();
  Serial.begin(9600);
  while (!Serial);
}

void loop()
 {
    if(Serial.read()=='A') 
    {
      runCpuInfo();
    }
}
void runCpuInfo() 
{
  Process p;	
  p.begin("picocom");
  p.addParameter("/dev/ttyACM0");
  p.run();

  while (p.available() > 0)
 {
    char c = p.read();
    Serial.print(c);
  }
  Serial.flush();
}

Serial print sends info : “filedes is not a tty” , so this is possible to write commands to lininio, but again problem.

I have also ethernet shield - would that be better to communicate over UDP with YUN ?

But why the hell I have this USB host in my YUN while I can not use any incoming data in my atmega ??

Maybe you can’t do it because you expect someone else to do it for you instead of learning how to do it yourself?

I have found the host port very useful for several things and if you look through the forum there are many examples of how people are using it AFTER they set up what they want.

I gave an example of how to connect the Uno to the Yun host port and picocom was handy to demonstrate, picocom is most likely not the best tool to set up a link from the Uno to the linino host port and then from the host port to the linino port to the Leonardo.

I expect you will need to learn how to program in Linux and set this up yourself. There are many tools available but many people here like to use Python, I don’t happen to be one of them. Python would definitely be up to the task and it is reputed to be easy to learn.

What you appear to be trying in your sketch can be accomplished by uploading the YunSerialTerminal sketch and executing picocom -b 115200 /dev/ttyACM0 in the serial monitor. This is actually connecting Uno->Linino->Leonardo->Your windows box, one more step that what you are griping about the Yun not being able to do.

Thanks for the lesson… :disappointed_relieved:
Everyone starts somewhere… :slight_smile: Nevertheless thank You for your help :slight_smile:

I can see the bridge is blocking me out from sending/reading the USB host port.
Withouth the bridge I can inciate reading from the usb by sending 1 → 2 ( sending ), 3 ( stop sending )

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
#include <Process.h>
YunServer server;

// variables and const
long lininoBaud = 250000;
boolean commandMode = false;
char d,c;
int pin;

void setup(){
  Bridge.begin();
  Serial.begin(115200);
  Serial1.begin(lininoBaud);
  server.listenOnLocalhost();
  server.begin();
}

void loop(){

// READ AND SAVE DATA FROM LININO
if(Serial1.available())	
{
  d = (char)Serial1.read();		
}

YunClient client = server.accept();

 if (client) 
  {
    //client.setTimeout(5);
    process(client);
    client.stop();
  }

}

void process(YunClient client){

  String command = client.readStringUntil('/');
  pin=0;

if (command == "mode"){   
    modeCommand(client);     
  }
}

void modeCommand(YunClient client){
  
  pin = client.parseInt();
  
  if(pin == 1)
  {     // open the usb terminal
	Serial1.println("picocom /dev/ttyACM0");	
  }
  else if( pin == 2){
	// send A using terminal ( sending begins )
 	Serial1.println("A");
  }
  else if( pin == 3){
	// send B using terminal ( sending stops )
 	Serial1.println("B");
  }
   else if( pin == 4){
	// show me the incoming data from USB
 	client.println(d);
  } 
}

Is there any option for Bridge.stop() and Bridge.start() despite the program limits ?
Or will I have to force linino to read from usb and wifi at once ?