Zigbee

October 10th, 2018

Hardwares required

  1. USB-to-ZigBee device
  2. ZigBee Antenna module
  3. ZigBee Sensor
  4. Google Nexus tablet with Android 4.1

XBee sensor configuration

The XBee sensor cannot be configured directly. Instead, it needs to be set up over-the-air via Zigbee (using API frame instead of traditional AT commands – more detail next).
First, the XBee ZB chip needs to be configured as a “Coordinator”. It can be done using Digi’s X-CTU tool:
http://www.digi.com/support/productdetail?pid=3352&osvid=57&type=utilities
I installed X-CTU to a Windows XP laptop for this setup. On X-CTU – select “ZIGBEE COORDINATOR API” under “Modem Configuration”.
Next, we downloaded the 2CA7 patch for the XBee sensor from the Digi support forum thread. Get it here.
(Note: It appears that Digi has not updated their tool to include the latest firmwares for the XBee sensors, and so without this patch, the XBee sensor’s configuration will not be recognized by X-CTU)
Extract the files from the patch, go under folder “xbee_zb”, open “XB24-ZB_2CA7.mxi”, and add the following line under “[Sleep Modes]” section:
[IR][0][Periodic sampling][E;0x1-0xFFFE ;x 1 ms][0: disable periodic sampling. Otherwise, x 1ms.]
On X-CTU – go to “Download new versions” under “Modem Configuration”, update source via “File” and select the 2CA7 patch. Then, go to “Remote Configuration”, discover the XBee sensor under the Coordinator – the XBee sensor should have/assign the function set “END DEVICE – LTH”. By default, the XBee sensor runs in passive mode – returns data only if polled.
From trials-and-errors, we found the following settings to allow it to transmit data periodically:
– “Sleep modes”
— SP = 100
— SN = 10
— PO = 10
— IR = 1000
The following settings enable to sensors within the XBee sensor unit:
– “I/O settings”
— D1 = 2
— D2 = 2
— D3 = 2
— P1 = 3
Once this is set up, the XBee sensor should be transmitting around every 10 seconds.

Android Device

On the receiving side, the Android device should be on 4.0.x or later. The XBee ZB with the USB adaptor should be recognized automatically without rooting. You can the “Slick USB 2 Serial Terminal” free App to test the connectivity.

Frame Format

The data is transmitted in hex, an example of the data received:
7E 00 18 92 00 13 A2 00 40 79 2D FB 68 68 41 01 08 80 0E 08 00 00 B8 02 74 03 54 A2
The API documentation:
http://ftp1.digi.com/support/documentation/90000976_M.pdf
Quick breakdown through trials and errors:
7E = Marker of beginning of API frame
00 18 = Size of content in this frame
92 = API frame code – “Data sample received” – see documentation
00 13 A2 00 40 79 2D FB = Originating device (XBee sensor) long address
68 68 = Originating device short address
41 = Receive option
01 = Number of sample
08 80 0E 08 00 = Related to the digital and analog I/Os
00 B8 = Light data (analog line ADC1)
02 74 = Temperature data (ADC2)
03 54 = Humidity data (ADC3)
A2 = Checksum

Calculation of temperature and humidity data

http://forums.digi.com/support/forum/viewthread_thread,10179#31172
(The formulas are unconfirmed and need to be verified. We also read a forum note stating that the temperature sensor was updated, so this formula may or may not be accurate)
Temperature:
Temp_C = (mVanalog – 500.0) / 10.0
mVanalog = (ADC2/1023.0) * 1200
e.g. ADC2 = 02 74 =  628 ; mVanalog = 736.7 ; Temp_C = 23.7
Humidity:
hum = (((mVanalog * 108.2 / 33.2) / 5000 – 0.16) / 0.0062)
mVanalog = (ADC3/1023.0) * 1200
e.g. ADC3 = 03 54 = 852 ; mVanalog = 999.4 ; Hum = 79.3
Light:
lux = (ADC1) /1023.0) * 1200
e.g.: ADC1 = 00 B8 = 184 ; Lux = 216 (0 to 1100)

Webpage Display

http://svm-sxn-wsn-sxn.ecs.soton.ac.uk/server/display.html

Comments are closed.