XBee3 and Arduino

Hello everyone!

I have two XBee3 and I'm trying to make them communicate using the most basic configuration. One XBee connected to the explorer + XCTU and another one with an Arduino board.

I tried using the basic library for XBee and Arduino, but it didn't work. GitHub - andrewrapp/xbee-arduino: Arduino library for communicating with XBee radios in API mode. The same code worked for a series 2 XBee but didn't for the series 3.

I've also tested a basic code using the explorer + XCTU and another one with a Waspmote board. However, the code did work here for both, xbee2 and xbee3 without changing anything in it.

I found this question here in the forum https://forum.arduino.cc/index.php?topic=631635.0. but no one answered it.

I hope anyone can help and I'd be more than happy to provide any necessary information to solve this.

Please post your entire code in tags.

Both of them work fine.

#include <XBee.h>

XBee xbee = XBee();

unsigned long start = millis();

// allocate two bytes for to hold a 10-bit analog reading
uint8_t payload[] = { 'H', 'i' };

// 64-bit addressing: This is the SH + SL address of remote XBee
XBeeAddress64 addr64 = XBeeAddress64(0x00000000, 0x0000ffff);
// unless you have MY on the receiving radio set to FFFF, this will be received as a RX16 packet
Tx64Request tx = Tx64Request(addr64, payload, sizeof(payload));

TxStatusResponse txStatus = TxStatusResponse();


void setup() {
  Serial.begin(115200);
  xbee.setSerial(Serial);
}

void loop() {
       if (millis() - start > 5000) {
      xbee.send(tx);
    }
    
    delay(1000);
}
#include <XBee.h>

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

uint8_t payload[] = { 'H', 'i' };

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

void setup() {
  Serial.begin(115200);
  xbee.setSerial(Serial);
}

void loop() {   
  // break down 10-bit reading into two bytes and place in payload
  xbee.send(zbTx);

  delay(1000);
}

falkenauge:
Both of them work fine.

Glad to see you got it working

Power_Broker:
Glad to see you got it working

Sorry for the misunderstanding, both of them work fine with the xbee2, not with the xbee3.

I've been having similar issues to what you are having. I've been trying to get two XBee 900HP/S3B Pros to work for a while now and still no luck. So far I've been to send messages to my remote XBees set as routers from my Coordinator XBee in XCTU but as far as getting the XBees attached to Arduino to transmit anything no luck. I'll leave the code below if you want it but it basically prints whatever the coordinator sends:

#include <AltSoftSerial.h>


// Use some macros to allow changing the serial ports to use easily
AltSoftSerial SoftSerial;
#define DebugSerial Serial
#define XBeeSerial SoftSerial

void setup() {
  DebugSerial.begin(115200);
  XBeeSerial.begin(9600);
  DebugSerial.println(F("Starting..."));
}

void loop() {
  if (XBeeSerial.available()) {
    char data[8];
    uint8_t column;

    for (column = 0; column < sizeof(data); ++column) {
      // Wait up to 1 second for more data before writing out the line
      uint32_t start = millis();
      while (!XBeeSerial.available() && (millis() - start) < 1000) /* nothing */;
      if (!XBeeSerial.available())
        break;

      // Start of API packet, break to a new line
      // In transparent mode, this causes every ~ to start a newline,
      // but that's ok.
      if (column && XBeeSerial.peek() == 0x7E)
        break;

      // Read one byte and print it in hexadecimal. Store its value in
      // data[], or store '.' is the byte is not printable. data[] will
      // be printed later as an "ASCII" version of the data.
      uint8_t b = XBeeSerial.read();
      data[column] = isprint(b) ? b : '.';
      if (b < 0x10) DebugSerial.write('0');
      DebugSerial.print(b, HEX);
      DebugSerial.write(' ');
    }

    // Fill any missing columns with spaces to align lines
    for (uint8_t i = column; i < sizeof(data); ++i)
      Serial.print(F("   "));

    // Finalize the line by adding the raw printable data and a newline.
    DebugSerial.write(' ');
    DebugSerial.write(data, column);
    DebugSerial.println();
  }

  // Forward any data from the computer directly to the XBee module
  if (DebugSerial.available())
    XBeeSerial.write(DebugSerial.read());
}

The wiring is on a Waveshare XBee adapter to Arduino Uno:

RXD => RXD
TXD => TXD
DIN => Pin 9
DOUT/CONFIG => Pin 8

Let me know if you find any solutions and someone who wants to be a real MVP should write a series 3 library.