very simple newsoftserial
|Sensor Xbee test board. Three inputs|
for the A/D's selectable.
I used X-CTU to configure all Xbee's .
The receiver Xbee is default (transparent mode) with a PAN ID that agrees with all of your transmitter Xbee's. Set all the baud rates the same. This is so you only receive data from YOUR transmitters!
I used one Xbee for transmission, it has three AD inputs A0,A1,A3 active. Configured as follows:
MY (16bit source) = 1 the first and only unit transmitting at this PAN ID
SLEEP MODE = 4 cyclic wakeup every 2 seconds transmit data go to sleep
ST =3 Time after last sample to go back to sleep. (ms)
SP = C8 sleep period 2 seconds (Hex in 10ms steps)
D0, D1, D3 = 2 This enables A/D on these inputs
IT = 4 sample each input 4 times
IR =1 time (ms) between samples
Thats all; just supply this Xbee with power and hook up the three inputs. You will see the power lite blink every 2 seconds and if you look closely the red data lite blinks also for the one RF packet that is sent.
Set up newsoftserial between the receiver Xbee and the Arduino like the Adafruit example
In my example the sampled RF packet bytes = 35 as follows:
7E, 0, 20, 83, 0, 1, 4F, 0, 4, 16, 0, 1, C1, 0, 9C, 3, 64, 1, C1, 0, 9C, 3, 64, 1, C2, 0, 9C, 3, 64, 1, C1, 0, 9C, 3, 64, FD,
My code to test xbeePacketsize
Quick view of my Headers:
8 bytes of RF header; 3 bytes of Data header; Data values, checksum.
- 7E Packet start delimiter
- 00 MSB length
- 20 LSB length Length is 32 + 3 bytes already; end is at byte 35
- 83 ATI identifer..receive 16 address packet data, the only mode I use.
- 00 MSB 16 bit source address
- 01 LSB 16 bit source address in my case 1
- 4F RSS RF signal strength -75dBm. I'll plot this vs distance soon. This is typical for wireless.
- 00 reserved Options
- 04 Total number of data samples (a/d conversions) 4 in my case
- 16 bitwise indication of channels enabled A/D see manual. This is how you setup the transmitting Xbee.
- 00 bitwise indication of digital enabled pins on the transmitting Xbee. None in my case.
- 01 MSB A/D first conversion for pin A0 in my case. 1*256 + LSB
- AB LSB A/D first conversion for pin A0. Value is MSB + 160 + 11 or 427 (0-1023 possible)
Remember I count from 1's but arrays are indexed from 0. I sometimes mix them up, be careful! Count!
My data starts at byte and ends at byte and byte is the checksum. My case 3channels*4samples*2bytes/value = 24 more bytes. 11 + 24 inclusive is 34. 34 is the last data byte.
All data in this xbee mode will start at byte and be (num sampled channels) * (num A/D conversions) * 2 bytes of data long.
It is simple to now fill a dataArray with the outputs of the xbee A/D values for each conversion
My code xbeeDataArray
Hope this helps.