However you seem to have posted the complete transmitting program but only part of the receiving program. Please post two complete programs.
There are no two codes as I'm using this code as the complete code. However, you may be finding the receiver code incomplete because I might have written an incomplete code for receiving the data. As my coding is not strong, I'm seeking help from the forum if I can get the completeness in my code.
And I remain skeptical about the completeness of your error message
#include <XBee.h>
#include <stdlib.h>
#include <time.h>
XBee xbee = XBee();
XBee xbee1 = XBee();
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
//XBeeAddress64 ROUTER1 = XBeeAddress64(0x0013A200,0X4147FE2A);
//XBeeAddress64 ROUTER2 = XBeeAddress64(0x0013A200,0x4147FE2B);
//XBeeAddress64 ROUTER3 = XBeeAddress64(0x0013A200,0x4147FE2E);
//XBeeAddress64 ROUTER4 = XBeeAddress64(0x0013A200,0x414E65AA);
XBeeAddress64 ROUTER5 = XBeeAddress64(0x0013A200,0x414E65AE);
XBeeAddress64 ROUTER6 = XBeeAddress64(0x0013A200,0x414E65B1);
String sample;
uint8_t count = 0;
void setup()
{
Serial.begin(9600);
xbee.setSerial(Serial);
Serial.println("Stating Up!");
Serial.println("Start Transmitting");
srand((unsigned)time(NULL));
}
void loop()
{
uint8_t i = 0;
uint8_t x = rand()%10;
uint8_t y = rand()%10;
uint8_t c = "XBeeId 1:";
uint8_t data[] = {x,y};
Serial.print(c,data[0],data[1]);
//uint8_t data[] = "HI, I'M Router 5!";
ZBTxRequest zbTx5 = ZBTxRequest(ROUTER5, data, sizeof(data));
ZBTxRequest zbTx6 = ZBTxRequest(ROUTER6, data, sizeof(data));
sample = "";
while(i<1)
{
xbee.send(zbTx6);
Serial.println("To Router 6");
delay(1000);
i++;
}
//String myString = "By Priyanshu";
//data = atoi(myString.c_str());
//char buf[myString.length()+1];
//myString.toCharArray(buf, myString.length()+1);
//data = ((uint8_t*)buf, strlen(buf));
xbee.readPacket(500);
Serial.println("Packet Detected");
Serial.print("count: ");
Serial.println(count);
if(xbee.getResponse().isAvailable())
{
Serial.println("Packet Arrived");
Serial.print("count: ");
Serial.println(count);
//Serial.println(xbee.getResponse().getApiId());
if(xbee.getResponse().getApiId() == ZB_RX_RESPONSE)
{
Serial.print("From Router 6: ");
xbee.getResponse().getZBRxResponse(rx);
for(int i=0; i<rx.getDataLength(); i++)
{
//sample+= (char)rx.getData(i);
Serial.println(rx.getData(i),DEC);
}
count++;
Serial.print("count: ");
Serial.println(count);
}
}
else if(xbee.getResponse().isError())
{
Serial.print("Error Reading Packet. Error Code: ");
Serial.println(xbee.getResponse().getErrorCode());
}
delay(1000);
}
Try this code as I run on my machine and I'm getting this error. However, my objective from this error message is that at the transmitting end I'm able to send an ID no. but cannot differentiate that the coordinates I'm sending, how to figure it out.
As the random values, I'm generating as of now is between 0 to 9 just for the understanding purpose. But, in future, I shall be sending between 0 to 255 as there are in total 256 pixels of any color. So at that time how do we segregate the coordinates. Like the example, I gave earlier we are sending ID no. (say) 5 so we know it's ASCII value is 53 and the coordinates are (12,206). The output I'm getting is 5312206. So, how do we know if it is (12,206) or (122,06)? That's the problem I'm facing.
I know I've made it a big hype out of it, but as I mentioned my coding is not strong and this is an entirely new project for me so I'm facing a lot of challenges with it. You people being expert and thoroughly active on the forum to help the rookie coders might help me with it.