Author Options:

Xbee interfacing -Need to send PIR sensor value and Gas sensor value from Tx end to Rx end.Read details for further info Answered

Hi all,
I am building a robot for my project and currently i am facing some issues with it.. Hope someone could help me resolve it. ! Thanks in advance for your help and support !! :-)

Detailed specs :

First of all i use 3 arduino - 1 at TX (user end) and 2 at RX (Bot side).

Now , I am using a PIR (Human motion detection ) Sensor and Gas sensor at  Rx(Bot side). 

The issue i am facing is , I am not able to send the Values read by both the sensors to the User end though xbee.. However the sensor is reading the values properly in Bot side , but iwhen sent to the User end i am getting the values as '-1' or the ASCII value of the Corresponding sent sensor value.

Now the help i need is.. I need someone (If possible) to send the code where 
1.A transmitter Code where you read the PIR,Gas sensor value and transmit the value through xbee.
2. A receiver code  where in you read the values that are sent through a xbee.

Kindly Help.. Thanks in advance ! :-)




3 years ago

Get the Xbee radios configured to talk to each other first. You should have some software called XCTU already to configure the settings within each Xbee, such as the channel used for transmission, ID's, and the baud rates that they communicate at.


You should be able to hook up the radios to any 2 USB ports on your computer, or on separate computers, and connect to each one separately on the XCTU program. That program allows you to send data on one radio which you can then view received from the other radio.


Also go ahead and test to see if you can control the bot directly with a UART connection (like through a FTDI adaptor connected to a computer.) If it's not working, try flipping the Rx and Tx lines. Remember, the Tx from the FTDI should connect to Rx on the bot, and The Tx from the bot should connect to Rx on the FTDI. Modify the code however you need to to make the code work from that point. Once that works, simply substitute the configured radios and make sure they are set up to work on the same baud rate and the FTDI connection previosly.


Answer 3 years ago

The Xbee radios are actually quite advanced, and have many advanced features:

For instance: The Baud rates on each Xbee radio doesn't necessarily have to be matched, but if they aren't matched, then you will only be able to send short packets of data before filling up and pontenially overflowing the small buffer within each radio. Imagine this like filling a cup of water with an outlet at the bottom. If you it fill up faster than the cup empties, then you will eventually lose water as it overflows. Same concept with the Xbee radio buffers.


For reliable communication, slower baud rates are generally better. The Xbees can communicate at almost 1Mb/s from what I remember, or about the speed of broadband internet in the US in the early 2000's. However errors in communication occur frequently at these high UART speeds.

Xbee radios I believe also allow you to configure how many times the message transmitted is repeated for redundancy and reliability. (again trading in speed for reliable data link), you can dig around in the XCTU program and learn what all the configurable things do.