XBEE Library Arduino-0015

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
StepByStep
 
Posts: 2
Joined: Mon Aug 17, 2009 8:39 pm

XBEE Library Arduino-0015

Post by StepByStep »

Hi,

I loaded an example Xbee Api program to my Arduino Diecimila (compiled ok).
That program makes two Xbee nodes (1 Router and 1 Coordinator) communicate in API mode (same PAN ID, same baud rate, same channel, and API mode enable).

I plugged an Xbee node (Router) to the Arduino board. This couple hardware is now not linked to the pc but is powered.
Then i plugged an Xbee node (Coordinator) to the PC by USB port (configured with X-CTU).

1/ How can i be sure that the program is running on the Arduino board?
(and transmitting request to the Xbee router on it?)

2/If it run, How can i retrieve some information sended to the Coordinator?

Thank you.
Here the code: from Xbee-Arduino project

Code: Select all

#include <XBee.h>

// Create an XBee object at the top of your sketch
XBee xbee = XBee();

// create an array for holding the data you want to send.  You can change the contents of your array later on in the loop.
uint8_t payload[] = { 'X', 'B', 'e', 'e' };
// Specify the address of the remote XBee (this is the SH + SL)
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x404a50cc ); //0x403e0f30  // 0x404a52B4 pour le coordinateur
// Create a TX Request
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
// Create a Status Response object
ZBTxStatusResponse txStatus = ZBTxStatusResponse();

// Tell XBee to start Serial
void setup() { 
  xbee.begin(9600);
}

void loop() {   
    // Send your request
    xbee.send(zbTx);

    // We'll wait up to five seconds for the status response.  If the receiving XBee is powered on, the response will
    // arrive very quickly, but if the remote XBee is not powered on or associated it could take a few seconds for a response.
    if (xbee.readPacket(5000)) {
        // Got a response!

        // Should be a ZB TX Status             
        if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
          // It is, now get the status response
           xbee.getResponse().getZBTxStatusResponse(txStatus);
               
           // Check if it was delivered
           if (txStatus.getDeliveryStatus() == SUCCESS) {
                // Packet was successfully delivered
           } else {
                // The remote XBee did not receive our packet. is it powered on?
           }
        }
    }
}

StepByStep
 
Posts: 2
Joined: Mon Aug 17, 2009 8:39 pm

Re: XBEE Library Arduino-0015

Post by StepByStep »

Hi Experts,

I did it.

Answer of my first question :

Code: Select all

int led = 13; // connect LED to pin 13

// Tell XBee to start Serial
void setup() {  
  xbee.begin(9600);
  pinMode(led, OUTPUT); // sets pin 13 as output
}
... and in the loop

Code: Select all

digitalWrite(led, HIGH);   // sets the LED on
                delay(300);                  // waits for a second
                digitalWrite(led, LOW);    // sets the LED off
                delay(300);                  // waits for a second
Answer of my second question:
Since the two modules are configurered (tricky) it is easy to see sended frames with an Hyperterminal.

Code: Select all

Trame RX #9 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #8 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #7 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #6 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #5 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #4 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #3 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #2 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #1 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Trame RX #0 : 7e | 0 | 16 | ffffff91 | 0 | 7d | 33 | ffffffa2 | 0 | 40 | 4a | 50 | ffffffcc | 2f | 1b | ffffffe8 | ffffffe8 | 0 | 7d | 31 | ffffffc1 | 5 | 41 | 58 | 42 | 65 | 65 | 7d | 5d
Attachments
CommunicationOK.PNG
CommunicationOK.PNG (33.13 KiB) Viewed 869 times

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”