0

I'm trying to get a XBEE shield to operate on an Arduino Leonardo. Usually i use the AltSerialLibrary to emulate an extra serial for the xbee. However since the Leonardo comes with two sets of serial, i figured I use that instead.

//#include <AltSoftSerial.h>

//AltSoftSerial XBee(5,13); // RX, TX

void setup() {

  Serial1.begin(9600);
  Serial.begin(9600);

}

void loop() {

  Serial.println("Odds");
  Serial1.println("Ends");

  delay(1000);


}

The code above aims to write values to both the serial monitor (serial) and xbee (serial1). However in the Xbee's XCTU program, the remote xbee does not recieve any data.

Any feedback on how I might fix this will be appreciated.

  • How is the Xbee connected? You have a SoftSerial connection commented out, but Serial1 does not use the same pins as the SoftSerial would have. – BrettAM Dec 23 '14 at 18:40
  • kinda obvious question, but how did you configure the XBee previously? – cjferes Jan 12 '15 at 15:43
1

You said you are using a Xbee shield. What shield is it, and what pins does it use for Serial communications?

If you were using software to emulate the second serial port on other arduinos, you were probably using different pins, and so if the shield is designed to communicate over (as an example) pins 2 and 3 then it will most likely not work with pin 0 and 1 without moving jumpers or switches. For example, this Xbee Shield: http://core-electronics.com.au/xbee-shield.html/?acc=9f61408e3afb633e50cdf1b20de6f466 has a switch to switch between pins 0 and 1 and pins 2 and 3.

You could also try some code that reads from Serial and prints the data to Serial1 and visa versa. This means you can experiment to get a greater understanding of the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.