1

Iam doing a project in which i need to read datas send from a ZIGBee through the serial port of raspberry pi. I have done removing that ttyAMA0 stuffs from /dev/cmdline.txt and commented that line in /etc/inittab . Then i reboot the pi. After that i connected the ZIGBee to the raspberry pi and the other ZIGBee to the pc from where I tried to check the UART communication through hyperterminal(in PC). I hav set the baudrate to 9600.

Now in the rpi side, the program I used to read the characters from the zigbee is given below:

import serial
ser=serial.Serial("/dev/ttyAMA0", 9600, timeout=3)
while True:
           read_byte=ser.read()
           print str(read_byte)
ser.close

But by running this program in rpi and typing something in the hyperterminal of PC, Iam getting some junk values in rpi. So, do i need to set the baud rate in some other ways?

2

To answer your question.

ser=serial.Serial("/dev/ttyAMA0", 9600, timeout=3)

will open the port at 9600 bits per second.

If you have any other questions it would be useful if you provide diagnostic information.

At the very least details of what you send and what you actually receive and details of how you have wired the connection.

  • K. Thanks joan. i'l provide the details. When i type A, its reading O For B, its ' for C, its N and for D, its reading some symbol, like that. About the connection, I have connected Txd, Rxd and ground pins of raspberry pi to the serial port of XBee base board. On the other end, sender XBee is connected to the serial cable which is connected to PC. – Rahul Ramesh Mar 17 '15 at 9:52
  • It would be helpful to others if you edit your original post and include any additional diagnostic information (like your comment above). I suggest you try my piscope. At the very least it will let you check the baud rate of received data (the shortest level change should be 1/9600 seconds or roughly 100 microseconds). – joan Mar 17 '15 at 15:15
  • Thank you joan. Its because, i hav a max232 in my zigbee baseboard in the rpi side. And i shudve connected it directly instead of connecting it via max232. Now when i tried to connect the Txd, Rxd and ground pin of rpi directly to the zigbee, its workking fine. Thank you for the concern :-) – Rahul Ramesh Mar 26 '15 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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