Dear experts,
I am new to arduino an XBee.
I just used an arduino UNO, XBee Series 2(), XBee USB Adapter and a DHT-11 to assemble an remote humidity/temperature sensor.
And send the data back to PC which also connects a XBee Series 2 and XBee USB Adapter.
The XBee device connected with arduino is configured as ZigBee End Device AT.
And the XBee device connected with PC is configured as ZigBee Coordinator AT.
I just modified PAN ID, Detestation Address and Baud Rate (9600) in both XBee devices.
But very strange... if I send the data back to PC every 4 seconds (or under), there is no any significant problem.
If I change the sending frequency to 5 seconds, the PC can't receive most data, and sometimes receive wrong data.
(As the attached picture.)
Please let me know how to make XBee send and receive data more stable.
Thanks for any advice!
Leon
Ps. Here is my code in arduino:
#include <SoftwareSerial.h>
#include <dht.h>
#define dht_dpin A0
SoftwareSerial xbee(2, 3);
dht DHT;
int pingPong = 1;
void setup() {
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(13, OUTPUT);
xbee.begin(9600);
delay(300);
}
int counter = 0;
void loop() {
xbee.print(counter);
xbee.print(": ");
xbee.print(DHT.humidity);
xbee.print(",");
xbee.print(DHT.temperature);
xbee.println(".");
if (pingPong == 0) {
digitalWrite(13, LOW);
} else {
digitalWrite(13, HIGH);
}
pingPong = 1 - pingPong;
counter ++;
delay(5000);// Sending frequency, no problem under 4000
}