0

I've managed to connect to Xbees. One is attached to the CPU via XbeeExplorer and another one is a ElSequencer (An lilypad arduino board). The connection works great and I can send wireless signals using the serial monitor without problems. Baudrates, pan IDs and destinations adress are all correct and working. The thing is that, strangely, the Xbee keeps sending data to the Arduino randomly. Like all kinds of serial signals. If I put the Arduino to print back the received signals,

Serial.print(incomingByte);

I start too see infinite signals coming back. What means the Xbee keeps sending the serials, without any command. The values are totally random. Like: 126010 131005301080854 126010131005301080854 126010131005301080854 126010131005101080856 126010131005101080856 126010131005301080854 126010131005201080855

My arduino code is below. Is a simple turn on and off lights. Since the Xbee keeps sending random signals, sometimes the signals match the programed ones and a light is turned on or off.

int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  Serial.begin(57600);

  // The EL channels are on pins 2 through 9
            // Initialize the pins as outputs
            pinMode(2, OUTPUT);  // channel A  
            pinMode(3, OUTPUT);  // channel B   
            pinMode(4, OUTPUT);  // channel C
            pinMode(5, OUTPUT);  // channel D    
            pinMode(6, OUTPUT);  // channel E
            pinMode(7, OUTPUT);  // channel F
            pinMode(8, OUTPUT);  // channel G
            pinMode(9, OUTPUT);  // channel H

}

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    Serial.print(incomingByte);

    //EL WIRES
    if (incomingByte == 'A') {
      digitalWrite(2, HIGH);
    }
   if (incomingByte == 'B') {
      digitalWrite(3, HIGH);
    }
   if (incomingByte == 'C') {
      digitalWrite(4, HIGH);
    }
   if (incomingByte == 'D') {
      digitalWrite(5, HIGH);
    }
   if (incomingByte == 'E') {
      digitalWrite(6, HIGH);
    }
   if (incomingByte == 'F') {
      digitalWrite(7, HIGH);
    }
   if (incomingByte == 'G') {
      digitalWrite(8, HIGH);
    }
   if (incomingByte == 'H') {
      digitalWrite(9, HIGH);
    }
   //
  if (incomingByte == 'I') {
      digitalWrite(2, LOW);
    }
   if (incomingByte == 'J') {
      digitalWrite(3, LOW);
    }
   if (incomingByte == 'L') {
      digitalWrite(4, LOW);
    }
   if (incomingByte == 'M') {
      digitalWrite(5, LOW);
    }
   if (incomingByte == 'N') {
      digitalWrite(6, LOW);
    }
   if (incomingByte == 'O') {
      digitalWrite(7, LOW);
    }
   if (incomingByte == 'P') {
      digitalWrite(8, LOW);
    }
   if (incomingByte == 'Q') {
      digitalWrite(9, LOW);
    } 
  }
}
  • The data that is printed does not look random to me, a lot of numbers repeat. Are your xbees in API mode perhaps? Using xbee series 1 or 2? Also you declared incomingByte as int, maybe it should be byte or char? And lastly, could the Rx line on the arduino be picking up noise? – user2019047 Jun 02 '13 at 20:45
  • Yeah, you are kind of right. They change the pattern with time. But the thing is that I am not sending this on purpose. This is Xbee sending values by itself. :/ They are not in API mode. Xbee S1. Declaring as int because this is how all examples do. But why it would cause this issue? The signals are working great. If I do everything through the FTDI cable, things just work perfectly. This "Rx" is a tough question for me. :) How do I check that? – Pablo Assis Jun 03 '13 at 00:58
  • I do not know your setup, but to make certain that the xbee in the XbeeExplorer is indeed sending data, try to implement a variable that counts up for every character received, and sends the value back to the XbeeExplorer xbee. Then move out of range for a while and then move into range again and check the value. Did it still count up while the xbees were out of range? If not then the XbeeExplorer seems to indeed transmit these sequences. If it did continue counting up then the signal is coming from somewhere else. maybe there are other xbees in the area :) Change the pan ID! – user2019047 Jun 03 '13 at 01:46

0 Answers0