Using Xbee to transit multiple sensor readings

Hi Guys,

I’m working on a project where I have 3 sensors (1 analog and 2 digital) and 2 XBee modules. One XBee module is connected to the 3 sensors. The other XBee module is connected to a computer via an XBee Explorer USB. I want to write a Java program which will read the 3 sensor inputs and perform some actions on the computer.

The main problem I am having right now is the configuration of the XBee. I don’t know how I can configure the 2 XBee chips. I’ve tried to look online for information but I have really not found anything that I understand. I have the XCTU installed on my laptop, but I am not sure what commands I need to set for the 2 chips. One chip will only need to send the sensor readings. The other chip (which attached to the explorer) only needs to receive the readings from the first chip. The sensor measurements need to also be read by Java via the Explorer.

Also, once I have the chips configured, how does the interface between the XBee Explorer and the computer work? Any help is appreciated.

First which XBees do you have Series 1 or 2. Second what is the Firmware version on these XBees. They come in several flavors.

Look at the links in this thread:

viewtopic.php?f=13&t=17745

Also, there are many threads with similar questions asked about XBee’s. Read them and you will probably find the answers.

Here, I wrote this for myself

Note: XBee series 1 is now called XBee 802.15.4. Digi made this change recently to improve model clarity.

Very good overview of key points of XBee series 1

http://www.johnhenryshammer.com/TEChREF … ries1.html

868-868.8 MHz: Europe, allows one communication channel (2003), extended to three (2006).

902-928 MHz: North America, up to ten channels (2003), extended to thirty (2006).

2400-2483.5 MHz: worldwide use, up to sixteen channels (2003, 2006).

Xbee has built in checksums and built in ACK. See above article on johnhenryshammer.com

XBee firmware history

http://www.digi.com/support/kbase/kbase … sp?id=2182

802.15.4 Modules

http://www.digi.com/products/wireless/p … jsp#models

Newest firmware on the XBee…

Use the X-CTU program to load new firmware. Click the ‘download new versions’ button in that program and X-CTU will download it straight from digi’s website for you. From there, you can load whatever version of the firmware you’d like.

XBee Videos on various features and discussions

http://www.digi.com/products/wireless/p … =3265#more

X-CTU Manual

http://ftp1.digi.com/support/documentat … 1003_A.pdf

Article on ‘which Xbee radio module is right for you’

http://www.ladyada.net/make/xbee/modules.html

Article on ‘802.15.4 vs. Zigbee’

http://www.sensor-networks.org/index.ph … 0823123150

Article on XBee 802.15.4 OEM vs. XBee ZB vs. ZNet205

http://www.sensor-networks.org/index.ph … 0831631643

XBee 802.15.4 Manual

http://ftp1.digi.com/support/documentat … 0982_B.pdf

Demystifying 802.15.4 and Zigbee

http://www.digi.com/pdf/wp_zigbee.pdf

XBee Mechanical Drawings

http://ftp1.digi.com/support/documentat … odules.pdf

XBee w/ RPSMA Connector Drawing

http://ftp1.digi.com/support/documentat … rawing.pdf

xbee AT vs. API …good read

http://www.digi.com/hottag.jsp?ht=/lear … s&rl=false

XBee FAQ

http://www.jsjf.demon.co.uk/xbee/xbee.html

Upgrading XBee firmware

http://www.faludi.com/itp_coursework/me … grade.html

Digi support forum

http://www.digi.com/support/forum/listf … sible=true

Thanks for the info guys. I watched the Tutorial video from the Digi website and it was pretty informative and looked through the info and I have learned alot about how to configure the chip. Here are the settings I plan to use.

Base Station:

DL = 5224

MY = 1778

P0 = 2

P1 = 2

IU = 1

IA = 5224

For the base station, my intention is for the base station to receive the data transmitted by the remote station. In the Digi example, P0 and P1 where both enabled. From what I understand, enabling these two setting will only cause the PWM0 and PWM1 pin to have the same value as the input. Can I disable these pins? I only need to pass the packets onto the USB port. I also understand that IU must be enabled in order to pass the packets onto the USB (so I can read via X-CTU but later will use Java to read the data). IA is bound to the address of the remote chip.

Remote Station:

DL = 1778

MY = 5224

D0 = 3

D1 = 3

D2 = 2

IR = 3E8

IT = A

For my remote station, my intention was to have D0 and D1 be digital inputs. D2 is to be an analog input. The sample rate should be 1 second and there should be 10 samples per transmission.

I have one last question, is it correct that the only other setting I should have to modify is the Channel for each chip? I would set the channel to be the same for both chips obviously.

You guys have been a great help so far.

What XBee modules and firmware version do you have?

I’ll assume these are Series 1 modules running 802.15.4 with v1xEx firmware?

If this is true then reference doc 90000982 from Digi.

Base Station:

DL = 5224 ; This is the low 32bits of the 64bit address of the remote unit. Match this the the remotes SL. Also match the DH the the remotes SH. This is to send data to the remote.

MY = 1778 ;

P0 = 2

P1 = 2

IU = 1 ; Received data sent out the UART (and then the USB of the interface board).

IA = 5224 ; this is for line passing. the value of an digital input on the remote module will be output on the same pin on this module. I don’t think this is what you want.

Remote Station:

DL = 1778 ; This is the low 32bits of the 64bit address of the receiving (base) unit. Match this the the base’s SL. Also match the DH the the base’s SH. This is to send data to the base.

MY = 5224

D0 = 3 ; digital input

D1 = 3 ; digital input

D2 = 2 ; Analog input

IR = 3E8 ; sample every 1 second

IT = A ; 10 samples before tx data

Have you tried getting pin data out the base UART yet?

I’m not really sure what version and firmware the chips are. This is a group project and one of my partners has the chips. I do know that we bought the XBee 1mW Chip Antennae chips from SparkFun. Link to the product we have is below. I will get in contact with my group member and find out what version and firmware we have.

http://www.sparkfun.com/commerce/produc … ts_id=8664

If I understand this correctly, the remote station package samples the inputs and when X number of inputs have been gathered it is packaged and sent over RF. The base station will receive the packet and send it through the UART pin. The XBee Explorer USB will take the output at the UART pin and send it through USB to the computer. Is my understanding of the operation of the XBee in this configuration correct?

What is the purpose of P0 and P1? In my configuration I have enabled them both but this is because that is how it was set in the example. I am under the impression that enabling P0 and P1 will cause pins PWM0 and PWM1 to have output the same as the packets being received. I don’t think I would need this since I will only need to read the packets sent by the remote radio via USB. Could you provide some clarification? You’ve been a really big help.

Yep, those are the series 1, 802.15.4 modules so the Digi doc I listed above should be the correct one.

I really don’t know about the P0 & P1 parameters. Maybe stevech will comment as he has extensive experience with these modules.

If I understand this correctly, the remote station package samples the inputs and when X number of inputs have been gathered it is packaged and sent over RF. The base station will receive the packet and send it through the UART pin. The XBee Explorer USB will take the output at the UART pin and send it through USB to the computer. Is my understanding of the operation of the XBee in this configuration correct?

That is my understanding as well.

Digi’s 802.15.4 firmware has “virtual wire” capabilities. That’s well described. With it, as said above, you use simple AT commands to define which digital pins are inputs on one XBee and these can be duplicated as outputs on some other Xbee. The pairing of the XBees is via the DH:DL address settings and the radios’ MAC addresses.

The criteria of when to send the current bits can be, as I recall, every x amount of time, after n samples taken at an interval you define, or when the bits change. I think you can do the same with the A/D.

Another way to use the firmware is to gather I/O samples and arrange for them to go wirelessly to an XBee and then to the serial port rather than the virtual wire mode.

I have one more question. For the remote station, what connections do I need to make? I know that I will need to connect the power and ground pins as well as DIO0, DIO1, and DIO2 but are there any other connections I need to make? The manuals says that DOUT and DIN must also be connected but I don’t see how I could make any connections to these pins.

I’m not sure what you really want to do at the ‘base’? I think you want to have serial communication between the ‘base’ XBee and your PC serial port. Is that correct?

If so then you need an RS232 to 3.3V TTL level translator IC on the DIN and DOUT lines to go to the PC COM port.

Look up the MAX232 and/or MAX3232 ICs.

Or use the Sparkfun XBee to USB explorer board.

What are you using DIO0, DIO1 & DIO2 for?

Sorry, I wrote the wrong information in my other post. The base station will be connected to the PC via a USB Explorer. My question was actually about the connections I need to make for the remote station. DIO0 & DIO1 are digital inputs. DIO2 is an analog input. For the remote station I know I will have to connect +3.3V and ground in addition to connecting the sensors to the respect DIO ports. Do I need to make any other connections on the remote station? The manuals says that the DIN and DOUT pins must also be connected (minimal connections are +3.3, GND, DIN, DOUT).

Ah…that makes more sense.

A remote XBee only requires a connection to the UART pins (DIN, DOUT) if you wish to either command the module at the remote with a uProcessor or to send serial data back the the ‘base’. Otherwise if you only need to sense a few things then just the DIO pins can be used.

On Series 1 modules I believe that you must connect Vref to a voltage to have the internal ADC to work (check the document on ADC operation). 3.3V is commonly used.

When only using DIO pins you can get the pin data by either send a data request from the ‘base’ or set-up the data sampling parameters to automatically sample the pins and send the data to the address in DL & DH.

The manuals says that the DIN and DOUT pins must also be connected (minimal connections are +3.3, GND, DIN, DOUT).

Which manual is this?

If you look at Page 7 of the 90000982_B.pdf document by Digi, it states that DIN and DOUT are minimum connections. Since I only have 2 XBee radios in my network, I don’t need to use both DL and DH, only DL should suffice? The example in the same document shows only DL being set.

If you look at Page 7 of the 90000982_B.pdf document by Digi, it states that DIN and DOUT are minimum connections.

Yep, that is a confusing statement. This is assuming that the XBee is to be used for serial communication. The Digi Docs and confusing, poorly organized, and sparse in application details. I've found that all the information required is in the Docs but it does take some experimenting to discover what the info means.

Since I only have 2 XBee radios in my network, I don’t need to use both DL and DH, only DL should suffice? The example in the same document shows only DL being set.

One which page is this?

If this works then ok only set DL. IF it doesn’t then set both DL & DH.

there’s a config item on whether long or short addressing is to be used.

I always use long (64 bit).

The configuration example I was referring to was on Page 15 of the manual.

What configuration do I need to set in order to choose a 32 or 64 bit address?

irfank:
The configuration example I was referring to was on Page 15 of the manual.

What configuration do I need to set in order to choose a 32 or 64 bit address?

XBee Pro Series 1 manual page 20

"Every RF data packet sent over-the-air contains a Source Address and Destination Address field in

its header. The RF module conforms to the 802.15.4 specification and supports both short 16-bit

addresses and long 64-bit addresses. A unique 64-bit IEEE source address is assigned at the factory

and can be read with the SL (Serial Number Low) and SH (Serial Number High) commands.

Short addressing must be configured manually. A module will use its unique 64-bit address as its

Source Address if its MY (16-bit Source Address) value is “0xFFFF” or “0xFFFE”.

To send a packet to a specific module using 64-bit addressing: Set the Destination Address (DL +

DH) of the sender to match the Source Address (SL + SH) of the intended destination module.

To send a packet to a specific module using 16-bit addressing: Set DL (Destination Address Low)

parameter to equal the MY parameter of the intended destination module and set the DH (Destination

Address High) parameter to ‘0’."

XBee Pro Series 1 manual page 43

"To transmit using a 16-bit address, set the DH parameter to zero and the DL parameter less than

0xFFFF. 0x000000000000FFFF (DL concatenated to DH) is the broadcast address for the PAN."

stevech:

irfank:
The configuration example I was referring to was on Page 15 of the manual.

What configuration do I need to set in order to choose a 32 or 64 bit address?

XBee Pro Series 1 manual page 20

"Every RF data packet sent over-the-air contains a Source Address and Destination Address field in

its header. The RF module conforms to the 802.15.4 specification and supports both short 16-bit

addresses and long 64-bit addresses. A unique 64-bit IEEE source address is assigned at the factory

and can be read with the SL (Serial Number Low) and SH (Serial Number High) commands.

Short addressing must be configured manually. A module will use its unique 64-bit address as its

Source Address if its MY (16-bit Source Address) value is “0xFFFF” or “0xFFFE”.

To send a packet to a specific module using 64-bit addressing: Set the Destination Address (DL +

DH) of the sender to match the Source Address (SL + SH) of the intended destination module.

To send a packet to a specific module using 16-bit addressing: Set DL (Destination Address Low)

parameter to equal the MY parameter of the intended destination module and set the DH (Destination

Address High) parameter to ‘0’."

XBee Pro Series 1 manual page 43

"To transmit using a 16-bit address, set the DH parameter to zero and the DL parameter less than

0xFFFF. 0x000000000000FFFF (DL concatenated to DH) is the broadcast address for the PAN."

If you use Peer-to-Peer mode/topology, the most simple, you simply set DH:DL to the MAC address of the module to which subsequent data is to go. This can be any module and can change on the fly.

In Peer-to-peer mode, you use AT commands to configure the XBee to not be a PAN Coordinator, Not require Association.

Peer-to-peer mode is like the simple “Ad-hoc” mode of WiFi where each node knows a priori the address of other nodes with which it wishes to communicate. In both WiFi and 802.15.4, any node can send to the broadcast address to send to all in range nodes (you must do your own error correction for broadcasts). The XBee broadcast address is DH=0, DL=FFFF

Thanks for all of your help. My XBee radios seem to be communicating fine. I’ve captured many packets and I’m trying to analyze the packets and extract the sensor samples from the packets. Here is an example of one of the packets.

7E 00 0C 83 52 24 35 00 01 08 03 00 03 01 1E A3

I know that

7E is the start delimiter

00 0C is the length of the packet

83 I’m not sure what this is, I think it is an API frame identifier.

52 24 is the destination address low

35 00 01 08 03 00 03 01 1E is the payload

A3 is the check sum.

Is my breakdown of the packets correct?

Your XBees are working! Great.

The breakdown of the frame looks correct.

0x83 is the frame type, see page 13 of doc.

Is the payload as you expect?

The I/O data format is on page 12 of the doc.

Do you need help decoding it?