Hi,
I have a problem with my Xbee (series 2), I let 2 arduinos communicate with 2 Xbee modules and it works, I mean, there is a serial link and the program starts but then the arduino resets itself.
I don't know why, I've used several very simple programs that send serial data (one way and two ways), even with one arduino sending to the Xbee who is connected to the serial monitor, data starts flowing and then stops, sometimes after ten seconds, sometimes after three or somtimes even after a minute or two.
The only time it doesn't stop is when I set the jumpers on de Xbee shield to USB (so that the program sends it serial data directly to the serial monitor) or when one of the Xbees is off, then the program keeps running, most of the time and definitely for longer periods.
Could this be with a buffer size/overflow in the Xbee or something, or do I need to clear something in the program for it to keep running? (i've found that when I use a long delay between serial prints it takes longer for the arduino to reset)
some sample code i used:
// Alternate sending '1'/'0' over XBee
void setup()
{
Serial.begin(9600); // XBee
}
void loop()
{
Serial.print('1', BYTE);
delay(500);
Serial.print('0', BYTE);
delay(500);
}
and the receiver:
// Toggle LED on LEDPIN depending on '1'/'0' received
// serially over XBee
#define LEDPIN 13
byte val;
void setup()
{
pinMode (LEDPIN, OUTPUT);
Serial.begin(9600); // Start talking to XBee
}
void loop()
{
if (Serial.available()) {
val = Serial.read();
if (val == '1') {
digitalWrite(LEDPIN, HIGH);
} else if (val == '0') {
digitalWrite(LEDPIN, LOW);
}
}
}
The led blinks three times (sometimes two times) and then stays on or of for a few second (the sending arduino is resetting), and then it starts blinking again. (but only two or three times)
If someone could help me, please, this is really an annoying problem >:(
Thanks