Background:
I have successfully gotten communication between 2 Unos using Software Serial working.
My sending station sends the numbers 1 to 100 repeating to the receiving station which outputs it to the serial monitor.
Here's my next challenge: I want to replace this direct connection with 2 Xbees.
In each case I have the Xbees and Uno's connected with 3 wires.
The sending station has 1 Gnd to Gnd, 1 5V to 5V, and 1 from Pin 3 to Rx on the Xbee.
The green light is flashing.
The receiving station has 1Gnd to Gnd, 1 5v to 5V and 1 from Pin 2 to Tx on the Xbee.
The green light is flashing and the red light is lit constantly.
My code for both stations is this:
SENDING
Code: Select all
#include <SoftwareSerial.h>
SoftwareSerial Xbee(2,3);
int i;
void setup()
{
Serial.begin(57600);
Xbee.begin(57600);
} // Setup
void loop()
{
for ( i = 1; i <= 100; i++)
{
Xbee.print(i);
Xbee.print('T');
Serial.println(i);
delay(500);
}
} // Loop
Code: Select all
#include <SoftwareSerial.h>
SoftwareSerial Xbee(2,3);
int RecVar;
int input;
void setup()
{
Serial.begin(57600);
Xbee.begin(57600);
} // Setup
void loop()
{
// delay(50);
if(Xbee.available())
{
RecVar = Xbee.read();
//Serial.println(RecVar); //Troubleshooting step
if(isDigit(RecVar))
{
input = (input * 10) + (RecVar - 48);
}
else
{
Serial.println(input);
input = 0;
}
}
} // Loop
But when put through the Xbees I get:0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
What's the Xbee Doing?2
3
4
5
6
8
9
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
0
2
0
2
0