Shop OBEX P1 Docs P2 Docs Learn Events
Xbee help — Parallax Forums

Xbee help

JonathanJonathan Posts: 1,023
edited 2009-02-12 15:51 in Propeller 1
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

Comments

  • sylvie369sylvie369 Posts: 1,622
    edited 2009-02-10 22:20
    Can we assume that you've read the material in the XBee manual on the ADC data format?

    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.
  • JonathanJonathan Posts: 1,023
    edited 2009-02-10 22:35
    Sylvie,

    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
  • RICoderRICoder Posts: 91
    edited 2009-02-10 23:46
    Does anyone have a simple schematic for hooking up an XBee to a prop chip?
  • AnubisbotAnubisbot Posts: 112
    edited 2009-02-11 14:53
    just plug pin1 on the xbee to 3.3
    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
    640 x 480 - 122K
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-02-11 18:28
    @RICoder
    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).
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-02-11 18:40
    Well, with ADC, the XBee set up to transmit will of course need the appropriate analog input and voltage reference connections, but the one that is connected directly to the (data receiving) Prop will still only need the RX, TX, power and ground connections. The transmitting XBee will do the ADC conversion, and send the data in digital form.
  • RICoderRICoder Posts: 91
    edited 2009-02-11 22:46
    Thanks. I've been using it as a pass-through for serial communications and was thinking of switching to API mode since I will have a lot of devices. That's when I'll need to look at the other connections right?
  • JonathanJonathan Posts: 1,023
    edited 2009-02-12 15:51
    What I'm trying to figure out is if the xbee's automatically rebroadcast wahetver they receive. I only bought two to play with, wish I had gotten three so I could find out. If they do, I see how (I think) the network works. If not, I don't see how to do a chain as I need to do. Seems tough to find out more on networking these units, I looked on the web and didn't find much.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Sign In or Register to comment.