Hello.
Could someone tell me how to receive data from XBee on Arduino?
I can send data but cannot receive, and totally get lost...
My enviroments.
- Arduino Leonardo
- XBee Series 2
- XBee Interface Board from digi
http://strawberry-linux.com/images/xbee-wifi-kit_3.jpg- XBee Explorer Regulated
https://www.sparkfun.com/products/9132- XBee Breakout Board
http://www.switch-science.com/products/detail.php?product_id=100And attach .pro files for both coodinator and router.
My sketch.
#include <SoftwareSerial.h>
uint8_t pinRx = 4, pinTx = 5;
SoftwareSerial mySerial(pinRx, pinTx);
long BaudRate = 9600;
int led = 12;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(BaudRate);
mySerial.begin(BaudRate);
mySerial.listen();
}
void loop()
{
// transmit
if (Serial.available())
{
char gotChar = Serial.read();
Serial.print(gotChar);
mySerial.print(gotChar);
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
}
// receive
if (mySerial.available())
{
char gotChar = mySerial.read();
Serial.print(gotChar);
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
}
}
And my results.
Case. 1 : Both XBee can send and receive.
"X-CTU-Interface Board-XBee" -> "XBee-Interface Board-CoolTerm"
Success.
"X-CTU-Interface Board-XBee" <- "XBee-Interface Board-CoolTerm"
Success.
Case. 2 : XBee on Arduino side cannot receive message.
"X-CTU(or CoolTerm)-Interface Board-XBee" -> "XBee-Explorer Regulated-Arduino"
Fail. And no LED blink on 12 pin. But Explorer's RSSI light is ON and DOUT light is blinking.
"X-CTU(or CoolTerm)-Interface Board-XBee" <- "XBee-Explorer Regulated-Arduino"
Success.
Case. 3 : XBee on Arduino side cannot receive message.
"X-CTU(or CoolTerm)-Interface Board-XBee" -> "XBee-Breakout Board-Arduino"
Fail. And no LED blink on 12 pin.
"X-CTU(or CoolTerm)-Interface Board-XBee" <- "XBee-Breakout Board-Arduino"
Success.
Since I can send and receive with Interface Board, I think the XBee settings are OK.
RSSI right ON when I receive, so seems Arduino failed to retrive serial from XBee.
hmm :(
I appreciate any advice.
Thank you in advance!
A