Problems with communication between Arduino and XBee S2C in API mode

Hello,

I’m developing a sensor network project to agriculture. I’m using Arduino UNO boards and XBee S2C communications. The XBee are communicating between them, as I can see in XCTU software, but I can’t communicate XBee’s with Arduinos. They are configured with the same Pan ID and API 2 mode.

I’m using the xbee-arduino library, and I’m trying to run the example for the Series 2 XBee. The Tx node (Router or End Device) blinks twice the builtin led, which tells me that the local XBee is not providing a response, as you can see in the example code below.

I’m using an Arduino Wireless SD shield and I’ve tried connecting the XBee direct to de Arduino getting the same result.

That is the example code:

/**
 * Copyright (c) 2009 Andrew Rapp. All rights reserved.
 *
 * This file is part of XBee-Arduino.
 *
 * XBee-Arduino is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * XBee-Arduino is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with XBee-Arduino.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <XBee.h>

/*
This example is for Series 2 XBee
 Sends a ZB TX request with the value of analogRead(pin5) and checks the status response for success
*/

// create the XBee object
XBee xbee = XBee();

uint8_t payload[] = { 0, 0 };

// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x4176eca5);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();

int pin5 = 0;

int statusLed = 13;
int errorLed = 13;

void flashLed(int pin, int times, int wait) {

  for (int i = 0; i < times; i++) {
    digitalWrite(pin, HIGH);
    delay(wait);
    digitalWrite(pin, LOW);

    if (i + 1 < times) {
      delay(wait);
    }
  }
}

void setup() {
  pinMode(statusLed, OUTPUT);
  pinMode(errorLed, OUTPUT);

  Serial.begin(9600);
  xbee.setSerial(Serial);

  flashLed(statusLed, 5, 50);
}

void loop() {

  // break down 10-bit reading into two bytes and place in payload
  pin5 = 25;
  payload[0] = pin5 >> 8 & 0xff;
  payload[1] = pin5 & 0xff;

  xbee.send(zbTx);

  // flash TX indicator
  flashLed(statusLed, 1, 100);

  // after sending a tx request, we expect a status response
  // wait up to half second for the status response
  if (xbee.readPacket(500)) {
    // got a response!

    // should be a znet tx status            	
    if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
      xbee.getResponse().getZBTxStatusResponse(txStatus);

      // get the delivery status, the fifth byte
      if (txStatus.getDeliveryStatus() == SUCCESS) {
        // success.  time to celebrate
        flashLed(statusLed, 5, 50);
      } else {
        // the remote XBee did not receive our packet. is it powered on?
        flashLed(errorLed, 3, 500);
      }
    }
  } else if (xbee.getResponse().isError()) {
    //nss.print("Error reading packet.  Error code: ");  
    //nss.println(xbee.getResponse().getErrorCode());
  } else {
    // local XBee did not provide a timely TX Status Response -- should not happen
    flashLed(errorLed, 2, 50);
  }

  delay(1000);
}

Hope you help me! and sorry about my English. Thanks!

Can the Arduino and XBee communicate in AT mode? That is a far simpler mode to test.

PaulS:
Can the Arduino and XBee communicate in AT mode? That is a far simpler mode to test.

I did't try it, but I'll do. Thanks for your answer!

PaulS:
Can the Arduino and XBee communicate in AT mode? That is a far simpler mode to test.

I’ve tried to run this simple example in AT mode, and It doesn’t work… :’(

I think I have a problem with any parameter of the XBee S2C configuration in XCTU.

I think I can fix this!

I called Digi, and they said that with the S2C the Dout pin on the xbee is floating, while on the S2B it is held high. All you need to do (If you are using a xbee shield from sparkfun etc.) is solder a 10KOhm resistor between the DOUT pin and 3.3V VCC pin. This holds it high during bootup and now I can talk between my arduinos again!