XBee Pro S3B with Raspberry Pi 2

Hello,

We got one of your XBee-PRO® 900HP Development Kits and the XBees work great when connected to PCs and using XCTU. I then tried to connect them to a couple Raspberry Pis to see if I can connect with them.

The information I’m getting from the net is that You should be able to read and write to the serial and access them this way. I hooked the hardware up this way:

https://sonyarouje.files.wordpress.com/2014/12/connection_diagram_bb.jpg

The Python code for the receiver is below:

#!/usr/bin/python

import serial

serialport = serial.Serial(“/dev/ttyAMA0”, 9600)
while 1:
x = serialport.readline()
print “%s” % (x)

The Python code for the transmitter is below:

#!/usr/bin/python

import serial

serialport = serial.Serial(“/dev/ttyAMA0”, 9600)
while 1:
serialport.write(‘L’)

I’m new to Python, so I might have done something dumb here. If anybody has any suggestions on code or hardware I would appreciate it. A working example would be great too.

Thanks

Hello,

You have written x = serialport.readline(), which could receive the data until ’
’ or EOL is received on the XBee receiver module.So from Transmitter side you must have provision for EOL(end of line) character. Or you could specify the length of string in the argument.

Try for x = serialport.read(size=1) in this case to receive character ‘L’ from the transmitter.

Thank you.

Thanks for your response. I did try that after I posted the question, but I’m still not getting any communication.

Do you have any other suggestions?

I got it to work with the USB, but my boss wants me to use the GPIO to interface with the XBee, which is still giving the same result. Does anyone have any other suggestions?