This is the solution that I posed to my senior design in Biomedical Engineering class (BME 440). Over the last few weeks we covered basic Arduino programming (e.g. debounced toggle, DHT sensor), we did some basic ZigBee communication (AT mode). The final project was to build a wireless Humidity, Temperature sensor that can transmit the data to a central computer. Above you can see the wiring to connect the humidity sensor DHT22 (see Adafruit's tutorial) to the Arduino/Xbee Shield. For this solution we configured the XBee S2's to "ZigBee End Device API" with AP = 2 (escape enabled). The central computer is connected to the Network coordinator XBee ("ZigBee Coordinator API AP=1). The Arduino code uses the XBee-Arduino library and the Adafruit DHT library. The python code is using the python-Xbee library.
/** * Copyright 2012, Helmut Strey * * This is an Arduino sketch that reads the humidity and temperature * from a DHT 22 sensor and transmits it using a ZigBee RF module. * It combines two example sketches that came from the XBee-Arduino library: Series2_Tx * and DHTtester from the adafruit DHT arduino library. * * * HumindityTempZigBee is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses */ // data pin of the DHT sensor // Uncomment whatever type you're using! //#define DHTTYPE DHT11 // DHT 11 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) // Connect pin 1 (on the left) of the sensor to +5V // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor DHT /* This example is for Series 2 XBee Sends a ZB TX request with the value of analogRead(pin5) and checks the status response for success */ // create the XBee object XBee xbee = XBee(); // we are going to send two floats of 4 bytes each uint8_t payload = ; // union to convery float to byte string union u_tag u; // SH + SL Address of receiving XBee XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x406F4973); ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload)); ZBTxStatusResponse txStatus = ZBTxStatusResponse(); int statusLed = 13; int errorLed = 13; void void void