Hi all,
This is my first Xbee project, and I'm having some trouble getting them to communicate ![]()
All I'm trying to do at the moment is to have the transmitting Arduino send '1111', wait a second, and then send '000', wirelessly through its Xbee. The receiving Arduino then received this data from it's own Xbee, and switches the onboard LED on, if it reads '1111' and off if it reads anything else.
I'm using 2x Arduino UNOs with Xbee shields and 2xSeries 1 Xbee Trace Antenna Modules. When both Arduinos (with Xbees) are connected to power, the Xbee shield associate LED on both shields switches on and off every second, so I'm assuming this means that they are connected to each other.
What is happening is, that although I can see the TX led on the transmitting Arduino switch on every second (meaning it is transmitting data as it's supposed to), the Pin 13 LED on the receiving Arduino doesn't switch on or off every second. Rather it either stays off, or when I move the external 9v power supply around, it just suddenly switches on and off very quickly (and erratically) until it's at rest again. I checked to see if this was a power supply / wiring issue, but it was clear that it wasn't. Perhaps this means that something is wrong with my Xbee module? Or maybe there is way too much interference around somehow? I'm stumped ![]()
For reference, here's my transmitting code:
void setup()
{
Serial.begin(9600);
}
void loop(){
Serial.println(1111);
delay(1000);
Serial.println(000);
delay(1000);
}
And here's my receiving code:
int ledPin = 13;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop()
{
while(Serial.available() == 0);
int data = Serial.read() - '0';
if (data == 1111){
digitalWrite(13,HIGH);
}
else
digitalWrite(13,LOW);
}
If anyone has had any experience with Xbee modules, I would love to hear from you!
Thanks for reading!