Xbee in API mode for digimesh

I want to connect some arduinos mega with Xbee DigiMesh 2.4 in a mesh network.

At this moment i try to connect 2 of them, one sender and one receiver, thats the code that i have on them:

Sender:

#include

// create the XBee object
XBee xbee = XBee();

uint8_t payload[] = { 0, 0 };

// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x40E73B5E);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();

int pin5 = 0;

void setup() {
Serial.begin(9600);
xbee.setSerial(Serial);
}

void loop() {
payload[0] = 0x34;
payload[1] = 0x76;

delay(3000);
xbee.send(zbTx);

}

Receiver

#include

XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
// create reusable response objects for responses we expect to handle
ZBRxResponse rx = ZBRxResponse();
ModemStatusResponse msr = ModemStatusResponse();

void setup() {
// start serial
Serial.begin(9600);
Serial1.begin(9600);
xbee.begin(Serial1);
}

// continuously reads packets, looking for ZB Receive or Modem Status
void loop() {
xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
// got something
Serial.println(“got something”);
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
// got a zb rx packet
Serial.println(“got rx packet”);
// now fill our zb rx class
xbee.getResponse().getZBRxResponse(rx);
// I check both bytes (or)
if (rx.getData(0) == 0x34 || rx.getData(0) == 0x76 ) {
digitalWrite(8, HIGH);
}
}
}

With this code i connect Serial1 to the Xbee. And i have on the hardware selected API(1) mode.

I dont know the reason why i can`t comunicate, if i need to use other libraries or what.

Thanks.

I don’t know what lib you are using as there are several out there but I would suggest using API mode 2 as most of them use this mode and I would also suggest a book called Creating Sensors Networks by Rob Faluti.

Hi PejaMar, Have you got your application working? If yes, would you please share the Arduino code. Thanks