Pages: [1]   Go Down
Author Topic: Serial message between 2 Arduinos using xbees - receiving garbage  (Read 472 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int MeasurementID = 1;
...
Serial.print("<");               // Start Char
Serial.print(MeasurementID);
Serial.print(">");           // end char
MeasurementID++;
...

The receiving Arduino is using this code:
Code:
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?
« Last Edit: January 26, 2013, 03:06:27 pm by caliph » Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9636
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

probably best to post all the code for both. Is MeasurementID possibly a non printable value?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are using software  serial port?

Is it running at 57600? That is too fast for software  serial,if you are doing it.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My most recent test over a year ago was 38400. YMMY
Logged


Pages: [1]   Go Up
Jump to: