Xbee help
Jonathan
Posts: 1,023
Hi All,
I just got a pair of the xBee Pro 60mW units from sparkfun. It was easy using Martin's xBee object to get them talking. The Prop makes so many things so darn easy. All I had to do was setup one cog to TX one of the xBee modules and another cog to RX on the other xBee. So much handier than having to set up two uC's!
Anyway, to the questions. The project I am working on is a water system for my property. There are two wells and a water tank, basically in a straight line. I want to implement wireless control of the well pumps and monitoring of the water level in the tank. There will be a controller unit at my house, which is basically in line with the two wells and the tank. The order is well1--tank--well2--house.
In order to get data from the well at the far end to the controller at my house, I am going to need to pass data through all the xBee's, due to range. I have been pondering the xBee manual, but am still unsure as to which type of network I need to accomplish this.
I will be using the I/O and adc features of the xbees. Very cool that they have them, I should be able to do what I need to do (turn on pumps and sense current flow) using just the xbee, with no local uC. Very cool.
Does anyone have some example code using the API mode with ADC and I/O, networking, that sort of thing? I found Martin's object, and a simple RX/TX demo in one thread, but nothing else. Before I start struggling my way through it, I thought I'd see if there was something to work with. Being a bit of a thickie it might take me a while. [noparse]:)[/noparse] Any and all xbee info welcome!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I just got a pair of the xBee Pro 60mW units from sparkfun. It was easy using Martin's xBee object to get them talking. The Prop makes so many things so darn easy. All I had to do was setup one cog to TX one of the xBee modules and another cog to RX on the other xBee. So much handier than having to set up two uC's!
Anyway, to the questions. The project I am working on is a water system for my property. There are two wells and a water tank, basically in a straight line. I want to implement wireless control of the well pumps and monitoring of the water level in the tank. There will be a controller unit at my house, which is basically in line with the two wells and the tank. The order is well1--tank--well2--house.
In order to get data from the well at the far end to the controller at my house, I am going to need to pass data through all the xBee's, due to range. I have been pondering the xBee manual, but am still unsure as to which type of network I need to accomplish this.
I will be using the I/O and adc features of the xbees. Very cool that they have them, I should be able to do what I need to do (turn on pumps and sense current flow) using just the xbee, with no local uC. Very cool.
Does anyone have some example code using the API mode with ADC and I/O, networking, that sort of thing? I found Martin's object, and a simple RX/TX demo in one thread, but nothing else. Before I start struggling my way through it, I thought I'd see if there was something to work with. Being a bit of a thickie it might take me a while. [noparse]:)[/noparse] Any and all xbee info welcome!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Comments
The XBee manual describes the data format used with the ADC. You'll get a three-byte header, in which the first byte indicates how many samples will be sent, and the second and third bytes are bit flags telling you which analog and digital channels are active.
Then you'll get some number of bytes representing the data. You'll first get two bytes that tell you which of the digital channels are high and which are low. Then for each active ADC channel you'll get two bytes: MSB and LSB of the corresponding channel's analog voltage.
For example, you might receive these data:
Header bytes (3)
00000110 00000010 00001010 = 6 samples, ADC 1 on, DIO 1 and 3 on
Sample bytes (24: 6 sets of 2 bytes representing the status of the digital lines, followed by 2 bytes representing each of the ADC samples)
00000000 00001010 00000000 00011011 = 27 <- value of the sample (first two bytes indicate that dig lines 1 and 3 are HIGH)
00000000 00001010 00000000 00011000 = 24
00000000 00001010 00000000 00011001 = 25
00000000 00001010 00000000 00011010 = 26
00000000 00001010 00000000 00011010 = 26
00000000 00001010 00000000 00011000 = 24
I recorded these using a light meter to provide analog input.
What I have not figured out is why after the header and data, I consistently receive 9 additional bytes. Still working on that part.
I have indeed read that pert, and while I haven't messed with it yet, it seems like it makes sense. I'd still love any sample code out there to ponder, but I thinkI can makeit work.
What I'm grappling with is stuff like how to request an adc reading from the module at the end of my chain, passing it from the house to the end of the chain, then pass the data back through the other modules to the main controller. Perhaps I misunderstand, maybe I need to have an uC with each ofthe xbee units. Iwas hoping that using one controller would allow me to read the adc and set the outputs of each module in the chain.
Thanks for the snip above, it's more stuff to ponder.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
pin2 xbee to prop pin rx(can be 0-31)
pin3 xbee to prop pin tx (can be 0-31)
pin9xbee to ground
pin10 xbee to ground
pin16 xbee to ground
Thats how i work with my xbee 2.5 modules and it works like a charm on 115200
Best regards Anubisbt
Post Edited (Anubisbot) : 2/11/2009 3:01:48 PM GMT
For simple serial with the AppBee Proto you only need to connect Vss, Vdd, Tx, and Tx.
If you want to use the ADC or any other more advanced feature than just magic wireless serial, then you'll need a bit more. The beauty of the straight through serial is that it's seamless, and only takes 2 pins (one for Rx, one for Tx).
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot