What line(s) of your programs are producing the funny characters? Can't you stop that?
I genuinely don't know what lines are producing these characters, in starting I tried figuring it out that what exactly it symbolizes to but later on I gave up assuming that as a representation for me to understand that once I received these characters, it means it is transmitting.
The output in your first picture in Reply #49 is NOT the output from the program AA because the program AA does not contain any line that prints To Router 1
I just provided you this output for the understanding that why I was not able to copy paste the matter I was getting at the Serial Monitor because of those characters.
How do I know that output that is supposed to come from program AB actually did so?
If you run the program for the Receiver part (i.e., program B) for the AB transmitter program, you'll receive this output. And I've copy-pasted the output of both the programs AA and AB receiver part in Reply #46.
Take out the random numbers - just get it to send the same numbers every time - or maybe get it to send numbers that increment by 1 within a small range - say 100 to 110. And put some space between the numbers when you print the values that are being sent.
I've taken out the random numbers and replaced them with the numbers ranged from 100 to 105.
Here's the code:
#include <XBee.h>
#include <time.h>
#include <stdlib.h>
XBee xbee = XBee();
XBeeAddress64 ROUTER5 = XBeeAddress64(0x0013A200,0x414E65AE);
XBeeAddress64 ROUTER6 = XBeeAddress64(0x0013A200,0x414E65B1);
uint8_t input = 0;
uint8_t i = 100;
void setup()
{
Serial.begin(9600);
xbee.setSerial(Serial);
Serial.println("Stating Up!");
srand((unsigned)time(NULL));
}
void loop()
{
uint8_t data[4];
uint8_t receivedChar = '0';
boolean newData = false;
while(i < 105)
{
data[0] = '6';
data[1] = i;
data[2] = ',';
data[3] = ++i;
ZBTxRequest zbTx5 = ZBTxRequest(ROUTER5, data, sizeof(data));
ZBTxRequest zbTx6 = ZBTxRequest(ROUTER6, data, sizeof(data));
delay(500);
Serial.println("Start Transmitting");
Serial.print("Data Sent:\t");
Serial.print(data[0]);
Serial.print(data[1]);
Serial.print(data[2]);
Serial.println(data[3]);
delay(500);
xbee.send(zbTx5);
Serial.println(": To Router 5");
delay(500);
}
}
Here instead of space, I've given a comma whose ASCII value is 44. So, when data is sent it is like this: 5410044101, which means data is sent from Router 6 (ASCII value: 54), 100 is the x-coordinate and 101 is the y-coordinate separated by a comma (ASCII Value: 44).
The output is like this:Transmitted Output:
Received Output:
Here, you can the highlighted text I've done to see the data sent and the data received.
Does this mean that there is some different setting for the two programs? Why are they not the same?
No, there are two settings to get the output. Let say, I'm talking about the program AA which is working fine. So, when we want to upload the sketch or code we wrote in the Arduino UNO, we have to keep the setting in USB Mode and when we want to see the output at the receiver end that the data is wirelessly getting transmitted or not, we switch the setting to XBEE Mode of the
SainSmart XBee-Arduino Shield.You can see the details present on the Arduino Forum as well:
ArduinoXbeeShield