Hello,
I have an issue to read packets sent from end node to the coordinator. The packet is well sent. I can see it when I connect the xbee to XCTU. When I place it on the xbeeshield, I have an issue to get the packet in the arduino.
At the coordinator, when the data is sent, on the xbeeshield, the RSSI is on and the DOUT is blinking. On the monitor, I get Error code:3.
Any idea what is wrong?
Thanks!
Code at End Node: (CH E, ID 3332, DH 0, DL 1, MY FFFE, CE 0, A1 4, A2 0, BD 9600, AP 1)
#include <XBee.h>
XBee xbee=XBee();
Tx16Request tx;
uint8_t buffer[12];
byte size;
void setup() {
Serial.begin(9600);
xbee.setSerial(Serial);
}
void loop() {
size=0;
buffer[size++]='H';
buffer[size++]='i';
tx=Tx16Request(0x01, buffer, size);
xbee.send(tx);
delay(3000);
}
Code at Coordinator: (CH E, ID 3332, DH 0, DL FFFF, MY 1, CE 1, A1 0, A2 4, BD 9600, AP 1)
#include <XBee.h>
#include <SoftwareSerial.h>
SoftwareSerial XBeeSerial(2, 3); // RX, TX
XBee xbee=XBee();
Rx16Response rx16=Rx16Response();
void setup() {
Serial.begin(9600);
XBeeSerial.begin(9600);
xbee.setSerial(XBeeSerial);
Serial.println("ready");
}
void loop() {
xbee.readPacket(100);
if(xbee.getResponse().isAvailable()) {
if(xbee.getResponse().getApiId()==RX_16_RESPONSE) {
xbee.getResponse().getRx16Response(rx16);
Serial.print(rx16.getRssi());
for(int i=0; i<rx16.getDataLength(); i++) {
Serial.print(rx16.getData(i), HEX);
}
}
} else if (xbee.getResponse().isError()) {
Serial.print("Error code: ");
Serial.println(xbee.getResponse().getErrorCode());
}
}