Go Down

Topic: Serial message between 2 Arduinos using xbees - receiving garbage (Read 748 times) previous topic - next topic

caliph

Jan 26, 2013, 09:03 pm Last Edit: Jan 26, 2013, 09:06 pm by caliph Reason: 1
Ladies and Gents,

I am stuck with this little issue and searching could not help either.

I have a setup of 2 Arduinos connected with xbees.
The sending Arduino is sending this message every 5 seconds:
<1>
<2>
<3>
etc.

Code: [Select]
int MeasurementID = 1;
...
Serial.print("<");               // Start Char
Serial.print(MeasurementID);
Serial.print(">");           // end char
MeasurementID++;

...

The receiving Arduino is using this code:
Code: [Select]
void setup() {
  Serial.begin(57600);    
  mySerial.begin(57600);}

void loop() {
 while(mySerial.available() > 0) {
   char inChar = mySerial.read();
   Serial.print(inChar);
 }
}


On the serial monitor I receive this:
<????
<<±???
etc.
Basically the first char of the message is correct then I receive garbage.

Can anybody tell me why I recieve this?

zoomkat

probably best to post all the code for both. Is MeasurementID possibly a non printable value?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

liudr

You are using software  serial port?

Is it running at 57600? That is too fast for software  serial,if you are doing it.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

caliph

Thanks for your hint on checking the baudrate.

In the Softwareserial description I found:
" It is possible to have multiple software serial ports with speeds up to 115200 bps."
So I thought I was ok... but:

Nevertheless I changed by baudrate down to 9600 and it solved my problem. Strange though.

liudr

Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy