XBee Pro S2B Problem transmitting when Arduino is unplugged and plugged in agai

I am working on a project with a friend to try to create a wireless mesh network using Arduino devices and XBee radios. Basically, we are trying to make a more efficient routing algorithm that will allow the data to be sent at a quicker rate and eliminate confusion between the devices that are being sent… Any-who, right now we are stuck with a problem that does not make any sense to us at all. We are trying to send data from a router in API mode to a Coordinator in API mode. When we first upload our code it works automatically, and there are no problems for the coordinator to receive the RSSI transmit; however, the problem is when we try to unplug the arduino to test the RSSI transmit at a different location, and we plug the arduino back in with the XBee still attached of course. The program of the coordinator and router are still running properly, but the code no longer says success like it did before the Router was unplugged. Instead, it gives us an error message, which means that the transmitting failed. We checked the API mode before and after the Arduino with the command xbee.getResponse.getApiId() at the coordinator, and we received 0x90 when the router had just had the code uploaded to it, which of course is what it should be, and it was 0x95 when the arduino was unplugged and plugged back in. Quite honestly we don’t know if this is an anomaly or if it is the reason why the two XBee’s are not communicating. If it is possible that are settings are wrong on X-CTU, we don’t know what to fix either. We are We seriously need some help with this project and would be grateful for any assistance on this project, which we have spent a combined 100 hours or more on at this point. Below is a the router’s code that we are using.

#include <XBee.h>

/*
This example is for Series 2 XBee
Sends a ZB TX request with the value of analogRead(pin5) and checks the status response for success
*/

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

byte to_radio1=0x0000; //used to store which radio we send to
byte to_radio2=0x0000;

uint8_t payload = { ‘H’, ‘i’ };
//uint8_t w_command = {‘W’,‘R’};
//uint8_t h_command = {‘D’,‘H’ };
//uint8_t l_command = { ‘D’,‘L’ };
//uint8_t h_address = { 0,0,1,3,10,2,0,0 };
//uint8_t l_address = {4,0,6,15,14,4,9,2};

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

//AtCommandRequest h_atrequest=AtCommandRequest(h_command,h_address,sizeof(h_address));
//AtCommandRequest l_atrequest=AtCommandRequest(l_command,l_address,sizeof(l_address));
//AtCommandRequest writerequest=AtCommandRequest(w_command);

void setup() {

Serial.begin(115200);
xbee.setSerial(Serial);

Serial.println();
Serial.println(“Setup Finished”);
Serial.println();

}

void loop() {

//zbTx.setAddress64(addr64);

//addr64 = XBeeAddress64(to_radio1,to_radio2);
//zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
//txStatus = ZBTxStatusResponse();

// break down 10-bit reading into two bytes and place in payload

Serial.println("");
xbee.send(zbTx);

// flash TX indicator
Serial.println("");
Serial.println(“Start”);

// after sending a tx request, we expect a status response
// wait up to half second for the status response
if (xbee.readPacket(500)) {
// got a response!

// should be a znet tx status
if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
xbee.getResponse().getZBTxStatusResponse(txStatus);

// get the delivery status, the fifth byte
if (txStatus.getDeliveryStatus() == SUCCESS) {
// success. time to celebrate
Serial.println(“Success”);
} else {
// the remote XBee did not receive our packet. is it powered on?
Serial.println(“Error1”);
}
}
} else if (xbee.getResponse().isError()) {
Serial.println("Error reading packet. Error code: ");
Serial.println(xbee.getResponse().getErrorCode());
} else {
// local XBee did not provide a timely TX Status Response – should not happen
Serial.println(“Error2”);
}

Serial.println(addr64.getMsb());
Serial.println(addr64.getLsb());

delay(1000);

}

And this is the coordinator’s code that we have been using

#include <XBee.h>

// create the XBee object
XBee xbee = XBee();
int signal_strength;
byte received_rssi;

byte rss();

// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0, 0x0000FFFF);
ZBRxResponse rxStatus = ZBRxResponse();

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

void loop() {
xbee.readPacket(100);
if (xbee.getResponse().isAvailable()) {
Serial.println(xbee.getResponse().getApiId());
delay(50);
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
xbee.getResponse().getZBRxResponse(rxStatus);
}
received_rssi = rss();
Serial.print(received_rssi);
}

delay(100);

}

byte rss() {
/* returns received signal strength value for the last RF data packet */

union {byte B; char C;} atCmd[3];
AtCommandRequest atCmdReq;
AtCommandResponse atResp;
byte respLen, *resp, dBm;

strcpy(&atCmd[0].C, “DB”);
atCmdReq = AtCommandRequest(&atCmd[0].B);
atResp = AtCommandResponse();

xbee.send(atCmdReq);
if (xbee.readPacket(5000)) {
if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {
xbee.getResponse().getAtCommandResponse(atResp);
if (atResp.isOk()) {
respLen = atResp.getValueLength();
if (respLen == 1) {
resp = atResp.getValue();
dBm = resp[0];
return dBm;
}
else {
Serial.println(“Unexpected response”);
}
}
else {
Serial.println(“ERROR”);
}
}
else {
Serial.println(“Unknown response”);
}
}
else {
Serial.println(“No response”);
}
}

Hello, please can you tell me how you configure the coordinator and the routers in XCTU?

Hi, welcome to the forum. Please use code tags when posting code:
http://forum.arduino.cc/index.php/topic,148850.msg1118324.html#post_codetags

apsimms:
I am working on a project with a friend to try to create a wireless mesh network using Arduino devices and XBee radios. Basically, we are trying to make a more efficient routing algorithm that will allow the data to be sent at a quicker rate and eliminate confusion between the devices that are being sent.

The mesh routing algorithm resides in the XBees themselves, not in Arduino code. The above statement sounds like you are reprogramming the XBee’s Ember firmware, is that correct?