Newbie needs some help getting XBee pro comm in API mode to work

Hi there,
As you can read in the title I’m new to arduino and XBee communication. Bu I do have a lot of java programming experience

I’m trying to build a wireless comm network between 9 arduino’s.

I understood that I need 1 Xbee coordinator and 8 XBee endpoint’s here to get the job done.

I started out simple with 1 Coordinator and 1 endpoint… but even that I couldnt get to work. (That’s were you guy’s hopefully come in)

So for my hardware setup : 2 arduino mega 2560 units both with XBee shield and XBee pro s1 module.

The Xbee pro module are updated with the latest firmware (XBP24, XBEE PRO 802.15.4 v 10ef)
and bothe are on Baud rate :` 9600
Parity : no
Stopbit : 1
Databits : 8

The coordinator module is configured as follows:

• ID - PAN ID – 7421
• DH – Destination Address High – 0
• DL – Destination Address Low – 1
• AP – API Enable – 2
• CE –coordinator Enable - Coordinator[1]
• EE – Encryption Enable – 0
• KY – Encryption Key - N/A
SH - 13A200
SL - 403D904D

The endpoint module is configured as follows:

• ID - PAN ID – 7421
• DH – Destination Address High – 0
• DL – Destination Address Low – 0
• AP – API Enable – 2
• CE –coordinator Enable - Enddevice[0]
• EE – Encryption Enable – 0
• KY – Encryption Key - N/A
SH - 13A200
SL - 406B6400

All these seting are written to the modules with XCTU.

My code for the arduino is this :

#include “Arduino.h”
#include <ArduinoJson-v5.13.2.h>
#include <XBee.h>

XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();

// mac addr coordinator DH 13A200 DL 403D904D
XBeeAddress64 macCoordinator = XBeeAddress64(0x13A200, 0x403D904D);

// mac addr end point 1 high 13A200 low 406B6400
XBeeAddress64 macEndpoint1 = XBeeAddress64(0x13A200, 0x406B6400);

void sendMsg(XBeeAddress64 destiny, String sample) {
uint8_t* pointer = (uint8_t*)sample.c_str();
int length = sample.length();

ZBTxRequest zbTx = ZBTxRequest(destiny, pointer, length);
xbee.send(zbTx);
}

void checkIncommingMsg(String who) {

xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
Serial.println(who+=" incoming…" );
Serial.println(xbee.getResponse().getApiId());
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
xbee.getResponse().getZBRxResponse(rx);
String sample;
for (int i = 0; i < rx.getDataLength(); i++) {
sample += (char)rx.getData(i);
}
Serial.println(who+=sample+=" received");
}
} else if (xbee.getResponse().isError()) {
Serial.println(who+=" Error reading packet. Error code: ");
Serial.print(xbee.getResponse().getErrorCode());
}
}

// The loop function is called in an endless loop
void loop()
{
sendMsg(macEndpoint1, “msg from coordinator”);

//checkIncommingMsg("Endpoint ");

delay(250);
}

//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
xbee.setSerial(Serial);
}

where the coordinator arduino does only call sendMsg(…) and
the end point anly calls checkIncommingMsg(…) in the loop function.

Upload of code has succeeded for both arduino’s.

Both arduino’s are connected to my PC (using com10 for coordinator and com 12 for endpoint.

When checking the serial monitor in Sloeber I see no err’s when the coordinator send data, but the endpoint is not receiving any data from the xbee!!!

Q1: does the xbee comm work when the arduino’s are connected to my pc using USB cable ??
Q2: what am I doing wrong here?? I tried it with the XBee shield USB/XBee switch in both way’s (they should be in XBee mode normally??)

Any help is greatly appreciated,

Jan van de Klok