Hi,
I'm trying to cummunicate between two Arduinos with two Xbee's (incl adapter kit: http://www.adafruit.com/products/126).
First I just tried if my Serial connection is working:
Arduino via Serial ports to ftdi cable: checked the traffic on both sides using Arduino Serial Monitor and CoolTerm.
-> Bytes could be received on the other side. (both directions)
I already used the Xbee's in AP mode - just sending via the hardware serial port - this also worked.
But I have to use API mode as I need to communicate with 2 or more Xbee's and I guess this is only properly possible in API mode.
My setting:
both Xbee's are in the same PAN
#1 is Xbee Coordinator API (connected Arduino: uploaded the TX sketch)
#2 is Xbee Router API (connected Arduino: uploaded the RX sketch)
both: baud rate: 9600
Now I just uploaded the two example sketches (Series2_TX, Series2_RX) from the Xbee library (sketches attached).
And did following adaption:
- payload
in the example the payload is read from Pin5, but I thought I would just send some constant values for testing purpose
I replaced the commented part below with just the declaration/initialization of the payload array:
//uint8_t payload[] = { 0, 0 };
uint8_t payload[] = { 97, 98 };
//int pin5 = 0;
//pin5 = analogRead(5);
//payload[0] = pin5 >> 8 & 0xff;
//payload[1] = pin5 & 0xff;
- ZBTxRequest Destination Address
Of course I also changed the Destination Address to my receiving Xbee:
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, BANNED);
Result:
The only visual output I get is the integrated PIN 13 LED on the two Arduinos:
- Coordinator (TX sketch) & Xbee #1 (Coordinator):
-> in a loop: blinks once, then twice: accoerding to the sketch this means nothing is coming back to the Xbee...
- Router (RX sketch) & Xbee #2 (Router):
-> no LED blinks: no packet ever arrives on Xbee #2
In general my question is, what could be wrong, as I more or less copied the example code and thought this shouldn't make too many problems...?
Is it correct to use both Xbee's in API mode?
Both types (Coordinator, Router/End device) can send and receive data, right?
Am I missing an import configuration for the Xbee's (in XCTU)?
Fyi: The red LED on my #1 Xbee never flashes - shouldn't it flash in case data is beeing sent?
-> could this mean no data is even sent from Arduino #1 to Xbee #1...?
I'm glad for every help and advice...
Please find attached the two example codes provided by the library...
(Sry for this long text)
Best regards,
Guti
Arduino Uno <-> Xbee <--> Xbee <-> Arduino Uno, Xbee Series
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- guti_haz
- Posts: 7
- Joined: Fri Nov 22, 2013 1:45 pm
Arduino Uno <-> Xbee <--> Xbee <-> Arduino Uno, Xbee Series
- Attachments
-
- Series2_Rx.txt
- (3.23 KiB) Downloaded 214 times
-
- Series2_Tx.txt
- (2.75 KiB) Downloaded 200 times
- guti_haz
- Posts: 7
- Joined: Fri Nov 22, 2013 1:45 pm
Re: Arduino Uno <-> Xbee <--> Xbee <-> Arduino Uno, Xbee Ser
Now I simplified the code a little bit and I just want to send an Xbee package to my second Xbee.
Via onboard led pin 13 I want to show the state on my arduino boards.
Again I used the code from the "simple RX/TX" example and modified it:
I send a package every 3500 ms...
and I just want to know if my second Xbee receives something, but LED 13 always blinks 3 times, meaning nothing arrives, am I right?
Receiving Code:
Via onboard led pin 13 I want to show the state on my arduino boards.
Again I used the code from the "simple RX/TX" example and modified it:
I send a package every 3500 ms...
Code: Select all
// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x40b09937);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
void loop() {
payload[0] = 97;
payload[1] = 98;
xbee.send(zbTx);
// flash TX indicator
flashLed(statusLed, 1, 100);
delay(3500);
}
Receiving Code:
Code: Select all
void loop() {
xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
flashLed(statusLed, 1, 100);
}
else if (xbee.getResponse().isError()) {
flashLed(statusLed, 2, 100);
//nss.print("Error reading packet. Error code: ");
//nss.println(xbee.getResponse().getErrorCode());
}
else{
flashLed(statusLed, 3, 100);
}
delay(1000);
}
Please be positive and constructive with your questions and comments.