Presently I was working on serial communication between Raspberry Pi and PC via XBee Pros. I was able to send serial data correctly from Raspberry Pi. I confirmed this by minicom program

minicom -b 9600 -o -D /dev/ttyAMA0 command. But when I connect other XBee Pro to PC and start putty with same baud rate and all the settings same, I was reading garbage values when I sent any data from Raspberry Pi. Sample python script to send data through serial port

import serial

serr= serial.Serial("/dev/ttyAMA0", baudrate=9600)



But whenever I read data from XBee via putty in my PC I am getting garbage values(like latin)

What am I doing wrong?

2 Answers 2


Your bod rates don't match.

In your first example you have -b 9600 and in your snippet you have 115,200. These need to match and some crazy weird things can happen when they don't.

Bod is the speed at which data is transferred over the connection. If one is moving faster than the other you won't be able to correctly read/interpret the data being sent on either end of the connection.

  • SORRY .. I have edited the question. Baud rates were same BTW
    – nbsrujan
    Sep 4, 2013 at 17:23
  • @nbsrujan: What version of python are you using?
    – Jacobm001
    Sep 4, 2013 at 18:35
  • @nbsrujan: Also, I can't seem to figure out what library you're using. Do you have a link.
    – Jacobm001
    Sep 4, 2013 at 18:43
  • I didn't use idle 3(Python 3). I tried it out with idle. Library I am using is pyserial pyserial.sourceforge.net
    – nbsrujan
    Sep 4, 2013 at 18:50
  • And I assume you're using the 9600 baud?
    – Jacobm001
    Sep 4, 2013 at 18:58

I have spent a lot of time with XBees over the last few weeks and have found that "out of the box" they do need just a "little" tweaking to get right. The fact that you can see something is a bit odd*, but just check the following:

In the basic "transparent mode" (how they come), they are set up as a router. Some documentation said their PAN ID was something like 0x3232 but mine were all set to zero. It WILL work on zero, but if you statically assign it, you will run into less problems later (just ATID 1234 or something of your choosing). By default, they won't talk to each other UNLESS one is a coordinator OR they are set up to broadcast their transmissions (ATDL FFFF), OR you set the destination address (take the ATMY of one and program it into the ATDL of the other and vice versa--I HAVEN'T tried it this way myself, but in theory it should work. I use a coordinator and I also broadcast).

*When I say "odd" I just mean, I would expect that you would see it, or you wouldn't see it. Is there anything else happening on the serial port by anything else?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.