# XBee best input for ultrasonic distance sensor

**URL:** <https://forums.digi.com/t/xbee-best-input-for-ultrasonic-distance-sensor/14422>\
**Category:** XBee & XBee Gateway\
**Tags:** xbee\
**Created:** [February 24, 2015, 11:16am UTC](https://forums.digi.com/t/xbee-best-input-for-ultrasonic-distance-sensor/14422 "2015-02-24T11:16:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferrerovi](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@Ferrerovi](https://forums.digi.com/u/Ferrerovi)\
**Post date:** [February 24, 2015, 11:16am UTC](https://forums.digi.com/t/xbee-best-input-for-ultrasonic-distance-sensor/14422/1 "2015-02-24T11:16:18Z")

</div>

Hi everybody,

- I have an ultrasonic distance sensor: LV-MaxSonar EZ3  
It has 3 outputs: serial, analog voltage and pulse width.

\*Serial: ASCII format.  
\*Analog: 2.54 mV / cm (using a 3.3 V input). Range: 38mV-1.6V.  
\*PW: 58 us / cm.

- On the other hand, I also have one XBee Series 2 to send the information. So, my remote node will be the ultrasonic sensor and the XBee. The maximum voltage that can be applied to analog IO pin is 1.2V.

I would like to know the best option to connect one of these outputs to my XBee.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [February 25, 2015, 9:01am UTC](https://forums.digi.com/t/xbee-best-input-for-ultrasonic-distance-sensor/14422/2 "2015-02-25T09:01:08Z")

</div>

The best option is to use the UART since it offer that.

---

<div class="post-metadata">

**Author:** ![Ferrerovi](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@Ferrerovi](https://forums.digi.com/u/Ferrerovi)\
**Post date:** [February 25, 2015, 9:35am UTC](https://forums.digi.com/t/xbee-best-input-for-ultrasonic-distance-sensor/14422/3 "2015-02-25T09:35:49Z")

</div>

Thanks mvut for your reply.  
I was thinking that would be the best option.

So,I need to connect the serial output to DIN XBee input (PIN 3). Am I right?

Another question appears when I want to connect a motion sensor (1= if detects movement, 0 if not). Now, the motion sensor has only a digital output so I connect it to pin AD0 (AD03). If I want to send the two sensor information (motion+ distance) using the same frame type (ZigBee I/O Data Sample Rx Indicator), do I need to use the analog output from the distance sensor (for example: connect it to pin AD1, AD12)?

Thanks

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [February 25, 2015, 10:02am UTC](https://forums.digi.com/t/xbee-best-input-for-ultrasonic-distance-sensor/14422/4 "2015-02-25T10:02:36Z")

</div>

That is correct. You connect the data out to the data in of the xbee.

No that is not an analog connection but a Digital IO. You would need to set the DIO0 as a Digital Input. Then on the receiving module, you need to use API mode an read the data from the UART of the change.
