I do not have much experience with Arduino and XBee.
I am now using the remote Arduino Nano to acquire 5 channals annalog data. Then I put them in the serial port. These data will be sent to the other Arduino via XBee.
But I have noticed, that the data, which is sent, not the same as the data, which is received. The other problem is that, after several minutes, I could not read any data from the receiver Arduino.
I will post my Arduino program here. Hope someone could help me!
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. The system in the 3rd example will be the most reliable and should be straightforward to implement in your project.
I recently have a project, which uses two Arduinos and two XBees to implement a wireless measurement technique.
I want to use the remote Arduino to capture analog signal from 5 channels and send it to the local Arduino via XBee. But the data, which is sent from the remote Arduino, is not the same as the data, which is received.
I will post my programs for Arduinos and the screenshots for data here. Hope someone could help me. I will really appreciate that.
I recently have a project, which uses two Arduinos and two XBees to implement a wireless measurement technique.
I want to use the remote Arduino to capture analog signal from 5 channels and send it to the local Arduino via XBee. But the data, which is sent from the remote Arduino, is not the same as the data, which is received.
I will post my programs for Arduinos and the screenshots for data here. Hope someone could help me. I will really appreciate that.
Best regard
// Example of sending numbers by Serial
// Author: Nick Gammon
// Date: 31 March 2012
int sensorPin = A0;
int sensorPin1= A1;
int sensorPin2= A2;
int sensorPin3= A3;
int sensorPin4= A4;
int sensorValue = 0;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;
const char startOfNumberDelimiter = '<';
const char endOfNumberDelimiter = '>';
void setup ()
{
Serial.begin (9600);
} // end of setup
void loop ()
{
Serial.println ("Starting ...");
Serial.print (startOfNumberDelimiter);
Serial.print (analogRead(sensorPin)); // send the number
Serial.print (endOfNumberDelimiter);
Serial.println ();
Serial.print (startOfNumberDelimiter);
Serial.print (analogRead(sensorPin1)); // send the number
Serial.print (endOfNumberDelimiter);
Serial.println ();
Serial.print (startOfNumberDelimiter);
Serial.print (analogRead(sensorPin2)); // send the number
Serial.print (endOfNumberDelimiter);
Serial.println ();
Serial.print (startOfNumberDelimiter);
Serial.print (analogRead(sensorPin3)); // send the number
Serial.print (endOfNumberDelimiter);
Serial.println ();
Serial.print (startOfNumberDelimiter);
Serial.print (analogRead(sensorPin4)); // send the number
Serial.print (endOfNumberDelimiter);
Serial.println ();
delay (1000);
} // end of loop
code for local Arduino
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
};
void loop() {
if(Serial.available()>0) {
Serial.println(Serial.read());
}
}
received data

sent data

SVersion0 and SVersion1 are dumb names. How are we supposed to tell which code is on the sender and which is on the receiver?
Assuming that SVersion1 is the sender, and SVersion0 is the receiver, you are sending characters from one Arduino to the other.
But, what are you receiving? What DOES Serial.read() return? Specifically, what is the type? Is printing that type a reasonable thing to do? Does it match what you sent?
The answer to the last question is no, which should give you some clues to the other answers and a possible solution.