Hi everyone,
I am working on Xbee (XB24-Z7UIT-004) nowadays. I got 3 xbee, 3 arduino. I want to send a massege from one arduino to the others.
When I configured the coordinator as "Coordinator AT" and the other as "Router AT", everything is OK.
But when I configured them "Coordinator API" and the other as "Router API", it is not OK. After all, I configured the other arduino as "End Device API". But I failed again.
I can see the comminication between 3 arduinos as below. But I could not send message.
Is there anybody who can help me?
You can see the code below
// TRANSMITTER
#include <XBee.h>
XBee xbee = XBee();
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial.flush();
xbee.setSerial(Serial);
xbee.begin(Serial);
}
void loop()
{
// Create an array for holding the data you want to send.
uint8_t payload[] = { 255, 128 };
// Specify the address of the remote XBee (this is the SH + SL)
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x40BAA50C);
// Create a TX Request
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
// Send your request
xbee.send(zbTx);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
// RECEIVER
#include <XBee.h>
XBee xbee = XBee();
ZBRxResponse ZBRx16 = ZBRxResponse();
#define MAX_FRAME_DATA_SIZE 110
bool toggle = false;
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial.flush();
xbee.begin(Serial);
}
void loop()
{
xbee.readPacket();
if (xbee.getResponse().isAvailable())
{
toggle = !toggle;
// got something
xbee.getResponse().getZBRxResponse(ZBRx16);
//if (ZBRx16.getData(1) == 255)
digitalWrite(13, toggle);
}
}