# idigidia with xbee in AT mode, using PIC microcontroller

**URL:** <https://forums.digi.com/t/idigidia-with-xbee-in-at-mode-using-pic-microcontroller/3273>\
**Category:** Python\
**Created:** [January 7, 2010, 11:42pm UTC](https://forums.digi.com/t/idigidia-with-xbee-in-at-mode-using-pic-microcontroller/3273 "2010-01-07T23:42:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zamora250186](https://avatars.discourse-cdn.com/v4/letter/z/a88e57/32.png) [@zamora250186](https://forums.digi.com/u/zamora250186)\
**Post date:** [January 7, 2010, 11:42pm UTC](https://forums.digi.com/t/idigidia-with-xbee-in-at-mode-using-pic-microcontroller/3273/1 "2010-01-07T23:42:20Z")

</div>

My project target is take samples with a PIC18 microcontroller and send the samples when the gateway (connectport x4) required. I want to make a CLI so i send a command itself as (x1) and then PIC respond with a sample of the ADC and send it to idigi platform using idigi\_db presentation.

I have the program in PIC interfacing with xbee in AT mode. I’m new programming python so i have some questions.

Work DIA with xbee in AT mode, API mode or both?

How can i send my PIC command from the gateway in python, i can use xbee\_device\_ddo\_set\_param or xbee\_device\_schedule\_after()? I’m really lost here.

Can I modify the file xbee\_xbib.py to adapt him to my application?

sorry by my english, thanks in advance.

---

<div class="post-metadata">

**Author:** ![cpopp](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cpopp](https://forums.digi.com/u/cpopp)\
**Post date:** [January 8, 2010, 12:09am UTC](https://forums.digi.com/t/idigidia-with-xbee-in-at-mode-using-pic-microcontroller/3273/2 "2010-01-08T00:09:28Z")

</div>

Hi,

When you interact with the XBee module in AT mode from your PIC microcontroller, you can for the most part just treat it like a serial port. So from that perspective, you’ll mainly be reading the port, and then just writing to it in response to commands you have received.

With that in mind, it would probably be useful to take a look at some of the serial related drivers in the Dia. (In version 1.2.x).

There are xbee\_serial\_loopback.py and xbee\_serial\_terminal.py which both extend xbee\_serial.py which gives the basic foundation for sending serial data to an XBee in a Dia device driver.

These will give you some examples of how you might send data so it will be retrieval from the serial port of the XBee, and also how you would read the data that your PIC sends through the XBee.

I would suggest starting with the xbee\_serial\_loopback device. From glancing at the source, it looks like every 5 seconds (based on the loop\_rate\_sec setting), it sends some data. Then whenever data is received from the XBee, the message\_indication function is called.

Then you would just define a simple serial protocol between the gateway and the PIC that they will use to exchange messages.

Chris

---

<div class="post-metadata">

**Author:** ![zamora250186](https://avatars.discourse-cdn.com/v4/letter/z/a88e57/32.png) [@zamora250186](https://forums.digi.com/u/zamora250186)\
**Post date:** [January 8, 2010, 12:51am UTC](https://forums.digi.com/t/idigidia-with-xbee-in-at-mode-using-pic-microcontroller/3273/3 "2010-01-08T00:51:48Z")

</div>

Thanks you very much for your prompt response, you have all the reason I will review the xbee\_serial\_loopback.py.  
greetings.
