wireless data collection with xbee and arduino
an example of a zigbee star network where remote sensor endpoints wirelessly push data to a central coordinator node. the central node can then communicate this data over a usb to serial connection to a visualization on a personal computer.
you dont really need an arduino between the xbee and the computer in this example, but this network setup is more flexible as it would also allow you to use the central arduino to control actuators, or even to send messages to remote nodes with actuators.
- install xbee library for arduino from here: http://code.google.com/p/xbee-arduino/
- install the newsoftserial library for arduino from here (if you have arduino 1.0+ you can use the builtin softserial lib instead): http://arduiniana.org/libraries/newsoftserial/
- download x-ctu to flash xbees: http://www.digi.com/support/productdetl.jsp?pid=3352&osvid=57&s=316&tp=5&tp2=0
- flash coordinator xbee node for net <i> (0 <= i <= 9) with x-ctu:
function set - coordinator api
- pan id = 444<i>
- node identifier = MASTER_<i>
- api enable = 2
- flash xbee sensor endpoint nodes <j…> for net <i> with x-ctu
function set - end point api
- pan id = 444<i>
- node identifier = DAEMON_<i>_<j>
- api enable = 2
arduino sketches for master and daemon nodes:
the daemon node is attached to one or more sensors. it samples them and maps their values to the range from 1-255 (so they fit in one byte). it builds a data packet with a zero to indicate the packet starting and then the sensor values listed in order, and sends it to the coordinator (master) node (which has the address 0, 0 on any zigbee net).
the master node listens to the xbee on the hardware serial port and uses newsoftserial to talk to the processing visualization. it pulls each packet off of the zigbee stack and writes the data values to the software serial port as raw bytes.
processing sketch for visualization:
the processing sketch looks for data packets (starting with a raw zero) and then redraws the visualization with the new sensor data