Xbee throws me this alert

Hello guys,

This code that I am going to present to you, generates a mode 1 API frame successfully when I run the program.

The problem: I take examples from Andrewrapp’s Xbee Arduino library, the following functions:

  if (xbee.getResponse().isAvailable()) {

My idea when using these two instructions is to run the code and the Arduino is asking itself: has it received a frame?
Once it has received a frame, it does not really matter that it carries the frame, simply by just receiving a signal from the PC the Arduino will execute the code that I present below.

#include <SafeString.h>
#include <XBee.h>
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <SoftwareSerial.h>

SoftwareSerial xbee(2, 3); //(Rx, TX)

byte packet1[] = {0x7E, 0x00, 0x21}; //Byte delimitador y Longitud de trama
byte packet2[] = {0x10, 0x01, 0x00, 0x13, 0xA2, 0x00, 0x41, 0x4E, 0xF1, 0x24, 0xFF, 0xFE, 0x00, 0x00,}; //Id de trama, tipo de trama, direccion de 64bits, opciones y numero de brincos.

// 00:11:46 05/01/2021 == 19 chars
byte fullPacket[3 + 14 + 19 + 1];// (Delimitador + longitud )+ (tipo + direccion) + fecha + checksum = 37
char buffer [25]; // 19 la fecha  +1  '\0', 25 bytes de tamaño

#define DEBUG SafeString::Output

void setup() {
  Serial.println("Sensor manda la hora y la fecha a la PC");


void loop() {
  if (xbee.getResponse().isAvailable()) {
    tmElements_t tm; //Necesario para poder obtener los valores hora:min:seg dia/mes/año
    if (RTC.read(tm)) {
      sprintf(buffer, "%02d:%02d:%02d %02d/%02d/%04d", tm.Hour , tm.Minute, tm.Second, tm.Day, tm.Month, tmYearToCalendar(tm.Year));
      //sprintf(buffer, "%02d:%02d:%02d %02d/%02d/%04d", 5 , 6, 7, 8, 9, 2021);
      Serial.println(buffer); // con este print compruebo que la fecha y hora
      // build fullpacket
      size_t idx = 0;
      memmove(fullPacket + idx, packet1, sizeof(packet1));
      idx += sizeof(packet1);
      memmove(fullPacket + idx, packet2, sizeof(packet2));
      idx += sizeof(packet2);
      if ((idx + 19 + 1) > sizeof(fullPacket)) {
        // Si el tamaño es incorrecto
        Serial.println(F("fullPacket size wrong"));
      memmove(fullPacket + idx, buffer, 19);
      idx += 19;
      // dejar un byte para el cheksum
      if ((idx + 1) != sizeof(fullPacket)) {
        // fullPacket size wrong
        Serial.println(F("fullPacket size wrong"));

    int chksum = 0;
    for (size_t i = 3; i < idx; i++) { // comienza despues del tamaño dela trama
      chksum += fullPacket[i]; // comienza a sumar 
    chksum = (0xff & chksum);
    chksum = (0xff) & (0xff - chksum);
    fullPacket[idx] = chksum;
    idx++; // El tamao total de la trama
    if (idx != sizeof(fullPacket)) {
      Serial.println(F("fullPacket size error"));

    // Imprime el paquete
    size_t printSize = idx * 3; // ..<space>
    cSF(sfPacket, printSize);
    for (size_t i = 0; i < idx; i++) {
      //sfPacket += "0x";
      if (fullPacket[i] < 16) {
        sfPacket += '0'; 
      sfPacket.print(fullPacket[i], HEX); 
      sfPacket.print(' ');

    xbee.write (fullPacket , idx);   
void print2digits(int number) {
  if (number >= 0 && number < 10) {

When I run this code, the Arduino throws me this alert.

is your problem. I think you meant

XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
// create reusable response objects for responses we expect to handle 
Rx16Response rx16 = Rx16Response();
Rx64Response rx64 = Rx64Response();

Hi drmpf, So if

SoftwareSerial xbee(2, 3); //(Rx, TX)

What happen with 2, 3 pins.

So I made the change and have this alert haha So what happen with my message if I want to sent to the xbee


Blind leading the blind here (perhaps someone who has actually used Xbee API can help)
try looking that this post
XBee in API mode, preparing data to be send and parsing received data

Got It. Thanks For All Drmpf.

Take a look at the documentation on GitHub. You’re still mixing up the XBee object with the serial object. As far as I can see, all you need do with Serial is to pass it to the XBee constructor, then all the operations should be XBee calls.

1 Like

Hi Wildbill Thanks for your time.
So I got your advice, and use this documentation in Github.

So I made these Changes

My Code:

xbee.write (fullPacket , idx);

Code in GigHub

   xbee.send(zbTx ); 

But I don’t have zbTX, so I scroll up, and zbTX is an Object.

XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x403e0f30);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));

Ok here we have 2 Objects addr64 and zbTX; addr64 its the 64 bits address that I have in my code and zbTx its and object and have 3 parameters, addr64, payload and the lenght of payload.

In this part I feel confused, because I would have to delete all my code, because these objects receive different things as parameters than what I have in my code. They are not different things, but the way the code is formulated and how it works, does not allow the use of this object to be possible.

I thought it would be a good idea to use, Because I wanted to update the code in such a way that it would not send a TX signal until the computer sent a TX signal to the sensor.
That the sensor is always asking, is there an incoming message?
And until I sent him a TX, he started running the code and sending me the time and date non-stop.

xbee.readPacket(); /* Read until a packet is received or an error occurs */

  if(xbee.getResponse().isAvailable()) /* True if response has been successfully parsed and is complete */

And, this

   xbee.send(zbTx ); 
//But at the time of using Send, that I send all my frame, the frame that I usually send with this line
//xbee.write (fullPacket , idx);

But if there is a different way to do this, without using the library, that would be great.