Home/Support/Support Forum/I am not receiving the data packet containing the temperature data from xbee end device sending data to coordinator.

I am not receiving the data packet containing the temperature data from xbee end device sending data to coordinator.

0 votes
Hi everyone,
I got problems when I tried to send temp and humid from dht11 to xbee coordinator via arduino ide. I am not receiving the data packet containing the temperature data from xbee end device sending data to coordinator. When Arduino is uploaded code, serial monitor displays some weird characters. I guess that the result was in incorrect format or sth .... Pls help me.
This is electronic components I use:
- Xbee S2C
- Arduino UNO
- Xbee Shield Arduino
- DHT11 sensor
- Xbee USB Adapter Ft232rl
Configure Xbee in XCTU:
Coordinator:
Function: ZIGBEE TH Reg
ID PAN ID: 1234
SC Scan Channels: 7FFF
JV Channel Verification: Disabled
CE Coordinator Enable: Enabled
AP API Enable: API enabled [1]
Router:
Function: ZIGBEE TH Reg
ID PAN ID: 1234
SC Scan Channels: 7FFF
JV Channel Verification: Enabled
CE Coordinator Enable: Disabled
AP API Enable: API enabled with Escaping [2]
Code Arduino:
#include <DHT.h>

#include <DHT_U.h>

#include <XBee.h>

#include "DHT.h"

#define DHTPIN 2

#define DHTTYPE DHT11

//Initialize XBee ZB client
XBee xbee = XBee();
//Payload byte array
uint8_t payload[8];
//Send to coordinator
XBeeAddress64 addr64 = XBeeAddress64(0, 0);
//Create request for XBee ZB
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));

//Initialize DHT sensor module
DHT dht(DHTPIN, DHTTYPE);

void set_float_to_payload(float value, int index) {

uint8_t *value_array;

value_array = reinterpret_cast<uint8_t*>(&value);

for(int i=0; i<sizeof(value); i++){

payload[i+index] = value_array;

}
}

void setup() {

Serial.begin(9600);

xbee.setSerial(Serial);

dht.begin();
}

void loop() {

delay(3000);

float temperature = dht.readTemperature();

float humidity = dht.readHumidity();


set_float_to_payload(temperature, 0);

set_float_to_payload(humidity, 4);

xbee.send(zbTx);

}
asked Apr 12 in RF Solutions and XBee by duc123 New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
This sounds like an issue with your code. The characters you are seeing would be the Hex API Receive frames coming from the End device over the Coordinator.
answered Apr 12 by mvut Veteran of the Digi Community (15,225 points)
Can you help me how to solve this problem?
What I would suggest is looking at the various 3rd party Arduino libraries that are designed to work with the XBee modules. That should take care of it.
...