I'm trying to send a character, in this case the letter 'H', via Xbee through a Raspberry Pi with an Xbee USB explorer attached to it and receive the response "Hello" from an Arduino with an Xbee attached to a wireless proto shield.
Code on Raspberry:
from xbee import ZigBee
import serial
ser = serial.Serial('/dev/ttyUSB0',9600)
xbee = ZigBee(ser)
xbee.send('tx',dest_addr_long=b'\x00\x13\xA2\x00\x41\x49\x69\xD6',
dest_addr=b'\xFF\xFE',data=b'H')
while True:
try:
print(xbee.wait_read_frame())
except KeyboardInterrupt:
break
ser.close()
Code on Arduino:
#include <SoftwareSerial.h>
// We'll use SoftwareSerial to communicate with the XBee:
SoftwareSerial Xbee(0, 1); // RX, TX
int incomingByte;
void setup() {
// Set up both ports at 9600 baud. This value is most important
// for the XBee. Make sure the baud rate matches the config
// setting of your XBee.
Xbee.begin(9600);
Serial.begin(9600);
}
void loop() {
if (Xbee.available()) {
// If data comes in from serial monitor, send it out to XBee
incomingByte = Xbee.read();
if(incomingByte == 'H') {
Serial.write("Hello");
}
}
}
The issue is when I run the code I only receive the transmit status on the Raspberry Pi, and not the packet with the "Hello" response in it.
Running code on Raspberry Pi:
I checked this by running the same scenario using XCTU tool and I do receive a response packet with the "Hello" message in it. So how can I get the Raspberry Pi to detect the response packet?