Communication between Arduinos using xbee Series 1

Hello--
I have two Series 1 Xbee's connected to Arduino Uno's via a Sparkfun Xbee Shield. I am attempting to get the two to communicate. I have my router (end device; PAN ID: 3332, DH: 13A200, DL:4124935F (NOTE:These are the serial values for my coordinator), MY: FFFE) connected to the Arduino, and the Arduino has the following code uploaded on it:

#include <XBee.h>
#include <AltSoftSerial.h>

XBeeWithCallbacks xbee;

AltSoftSerial SoftSerial;
#define DebugSerial Serial
#define XBeeSerial SoftSerial

void setup() {
  // Setup debug serial output
  DebugSerial.begin(115200);
  DebugSerial.println(F("Starting..."));

  // Setup XBee serial communication
  XBeeSerial.begin(9600);
  xbee.begin(XBeeSerial);
  delay(1);

  // Send a first packet right away
  sendPacket();
}

void sendPacket() {
    // Prepare the Zigbee Transmit Request API packet
    ZBTxRequest tx64Request;
    tx64Request.setAddress64(0x000000000000000);
    uint8_t payload[] = {'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!'};
    tx64Request.setPayload(payload, sizeof(payload));

    // And send it
    uint8_t status = xbee.sendAndWait(tx64Request, 5000);
    if (status == 0) {
      DebugSerial.println(F("Succesfully sent packet"));
    } else {
      DebugSerial.print(F("Failed to send packet. Status: 0x"));
      DebugSerial.println(status, HEX);
    }
}

unsigned long last_tx_time = 0;

void loop() {
  // Check the serial port to see if there is a new packet available
  xbee.loop();

  // Send a packet every 10 seconds
  if (millis() - last_tx_time > 10000) {
    last_tx_time = millis();
    sendPacket();
  }
}

My Coordinator Xbee (PAN ID: 3332, DH: 0, DL: 0, MY: FFFE)is connected to another Arduino. When I look at the serial output for my router Arduino, I get the following error:

Failed to send packet. Status: 0xFF

I think this error message indicates that there was nothing received. I am confused by this because the Association LED on both of my shields blinks when they are powered, indicating that they have found each other on the network, correct?

The code I am using was modified slightly to be used with a Series 1 (it was originally written to be used with Series 2). I think there might be something I am overlooking in the code....

Any help or suggestions would be really helpful. Thanks!

    uint8_t payload[] = {'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!'};

What have you got against

    uint8_t payload[] = {"Hello, world!"};

? Sure is a hell of a lot easier to type AND change.

Why are you using API mode to send such useless data? Using AT mode, and

XBeeSerial.print("Hello, world!");

is a hell of a lot easier.

My Coordinator Xbee

Series 1 XBees do NOT have a coordinator role.

(PAN ID: 3332, DH: 0, DL: 0, MY: FFFE)

Using 0 as the address of an XBee is a BAD idea.

How is the other XBee configured?

First priority of programming: Get it to work
Second: make it efficient.

I am learning and this is a cookie-cutter example from a book that should work, but is giving me trouble. I am hoping more experienced users can give me some constructive help.

As mentioned, I have two Xbees (and through XCTU, I am able to set one to coordinator and the other to End device), one is set as end device (PAN ID: 3332, DH: 13A200, DL:4124935F (NOTE:These are the serial values for my coordinator), MY: FFFE),

and the other is set to Coordinator Xbee (PAN ID: 3332, DH: 0, DL: 0, MY: FFFE).

klk0146:
First priority of programming: Get it to work

I think that is what @PaulS was hinting at :slight_smile:

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

As mentioned, I have two Xbees (and through XCTU, I am able to set one to coordinator and the other to End device)

Coordinators, routers, and end devices are roles in a mesh network fromed by Series 2 radios. Series 1 radios can NOT form a mesh network. They are for point to point.

On one of them, set DH to 1. Set MY to 2.
On the other one, set DH to 2. Set MY to 1.

Do NOT use 0, 0xFFFF, or 0xFFFE for MY or DH.