I have 2-Xbee's Series 1
I-Arduino Uno
1-Xbee shield
1-Xbee explorer
1- DHT 11 sensor temperature and humadity
more or less like this : PC commputer --> xbee + xbee explorer <----------> xbee +xbee Shield + sensor DHT 11 +arduino UNO
I would like to see temperature values pop up on the serial monitor while using wireless communication. The temperature sensor is connected to the Xbee shield ,which is connected to the Arduino Uno. I then have the Xbee explorer attached to an Xbee connected to the computer. I can get values to show up on the serial monitor if I connect the Arduino Uno directly to the computer but not when using wireless communication.. Please help, i'am newbie learning xbee and i very confused
here this code :
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
int ledPin = 13; // LED connected to digital pin
int transistorPin = 12;
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(transistorPin, OUTPUT);
blinkLED(ledPin, 2, 500); // startup blink
delay(1000);
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();// start serial at 19200 baud, same as programmer speed
}
void loop() {
blinkLED(ledPin, 1, 250);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
if ( Serial.available() > 0) { // if there are bytes waiting on the serial port
char inByte = Serial.read(); // read a byte
if (inByte == '*') { // if that byte is the desired character
int len = 5; // expected string is 6 bytes long
char inString[len]; // declare string variable
for (int i = 0; i < len; i++) {
inString[i] = Serial.read();
}
if ( strstr(inString, "reset") != NULL ) // check to see if the respose is "reset"
resetChip(5000); // reset the chip after waiting for the specified # of milliseconds
}
}
}
void resetChip(int delayTime) {
/* if the project does not typically receive data, and accidental chip resets are tolerable,
* this is a simple method that should work just fine. Otherwise it is recommended that the
* reset request string be part of a call-response sequence, be transmitted with a
* reserved byte or byte string, or be transmitted in some way out of band, so that it is not
* accidentally received.
*/
Serial.print("\nArduino will reset in ");
Serial.print(delayTime/1000, DEC);
Serial.print(" seconds...\n\r");
blinkLED(ledPin, delayTime/100, 100); // wait for the specified amount of time, doing nothing
Serial.print("\nResetting NOW.\n\r");
digitalWrite(transistorPin, HIGH); // switch on a transistor that pulls the chip's reset pin to ground
}
void blinkLED(int targetPin, int numBlinks, int blinkRate) {
// this function blinks the an LED light as many times as requested
for (int i=0; i<numBlinks; i++) {
digitalWrite(targetPin, HIGH); // sets the LED on
delay(blinkRate); // waits for a second
digitalWrite(targetPin, LOW); // sets the LED off
delay(blinkRate);
}
}
please help me,, thank's