# DIO change status not received in python

**URL:** <https://forums.digi.com/t/dio-change-status-not-received-in-python/30880>\
**Category:** Python\
**Created:** [May 11, 2024, 4:25pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880 "2024-05-11T16:25:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tewfik](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tewfik](https://forums.digi.com/u/tewfik)\
**Post date:** [May 11, 2024, 4:25pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/1 "2024-05-11T16:25:14Z")

</div>

hi ,  
i have 2 xbee S1 linked , send receive is ok via xctu and my python program .the only issue is my push button (connected to one of the xbees set in DIOo) when pressed i get the api frame (change detect) via xctu but not in my python program , althought it’s a loop listening for all incoming data (i have tried a basic python serial listen port is ok and also all kind of terminals are receiving the data)

# XBee setup

```
    self.serial_port = "COM10"  
    self.xbee_device = XBeeDevice(self.serial_port, 1200)
def start_xbee(self):
    try:
        self.xbee_device.open()

        print("Device serial port opened successfully.")
        print("Waiting for data...")

        while True:

            xbee_message = self.xbee_device.read_data()

```

---

<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:** [May 14, 2024, 12:49pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/2 "2024-05-14T12:49:07Z")

</div>

It does not look like you are looking for Hex data packets.

---

<div class="post-metadata">

**Author:** ![tewfik](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tewfik](https://forums.digi.com/u/tewfik)\
**Post date:** [May 15, 2024, 7:30pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/3 "2024-05-15T19:30:43Z")

</div>

xbee\_device.read\_data() suppose to receive any kind of data (it works with sending manually frame from xctu) the only data i don’t receive is when change detect of the remote xbee occurs (even i see the same data from other apps (xctu, terminal, and even pyserial))  
the pb is for sure the way the library xbee\_device.read\_data() works (maybe flow control) i dont know really i’m stuck

---

<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:** [May 16, 2024, 12:25pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/4 "2024-05-16T12:25:22Z")

</div>

> [@tewfik](#):
>
> xbee\_device.read\_data()

What library are you using?

Do you have AP set on the radio for 1 or 2?

---

<div class="post-metadata">

**Author:** ![tewfik](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tewfik](https://forums.digi.com/u/tewfik)\
**Post date:** [May 16, 2024, 5:58pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/5 "2024-05-16T17:58:24Z")

</div>

import digi.xbee.devices  
all api is set and works (checkked with xctu)

---

<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:** [May 17, 2024, 4:58pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/6 "2024-05-17T16:58:13Z")

</div>

Tewfik,

What Library are you using to obtain the function “xbee\_device.read\_data()”? Where did you obtain it from?

---

<div class="post-metadata">

**Author:** ![tewfik](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tewfik](https://forums.digi.com/u/tewfik)\
**Post date:** [May 18, 2024, 3:39pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/7 "2024-05-18T15:39:10Z")

</div>

digi-xbee version 1.4.1  
i use pycharm with python 3.12 and my pyserial 3.5  
all updated

---

<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:** [May 20, 2024, 1:31pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/8 "2024-05-20T13:31:36Z")

</div>

> [@mvut](#):
>
> xbee\_device.read\_data()

[https://xbplib.readthedocs.io/en/latest/user\_doc/communicating\_with\_xbee\_devices.html?highlight=read\_data()#polling-for-data](https://xbplib.readthedocs.io/en/latest/user_doc/communicating_with_xbee_devices.html?highlight=read_data()#polling-for-data)  
I don’t know if you are already doing this, but you need to have the read\_data in a loop as the DIO data will be sent as an Asynchronous function.

---

<div class="post-metadata">

**Author:** ![tewfik](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tewfik](https://forums.digi.com/u/tewfik)\
**Post date:** [May 21, 2024, 11:09pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/9 "2024-05-21T23:09:56Z")

</div>

yes i do  
# XBee setup  
self.serial\_port = “COM10” # Replace with your port  
self.xbee\_device = XBeeDevice(self.serial\_port, 1200)  
def start\_xbee(self):  
try:  
self.xbee\_device.open()

```
        print("Device serial port opened successfully.")
        print("Waiting for data...")

        while True:

            xbee_message = self.xbee_device.read_data()

            if xbee_message:

                    deviceid = str(xbee_message.remote_device.get_64bit_addr())

                    rssi_bytearray = xbee_message.remote_device.get_parameter("DB")
                    rssi = int.from_bytes(rssi_bytearray, byteorder='big') # Convert bytearray to int

                    print(f'Message from ID: {deviceid}, RSSI: {rssi}')
      time.sleep(0.1)
    except Exception as e:
        print("Error:", e)

```

---

<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:** [May 22, 2024, 1:32pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/10 "2024-05-22T13:32:55Z")

</div>

Is there a specific reason you are trying to run at a 1200 baud rate and not something like 9600 or 115.2kbps?

---

<div class="post-metadata">

**Author:** ![tewfik](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tewfik](https://forums.digi.com/u/tewfik)\
**Post date:** [May 22, 2024, 9:32pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/11 "2024-05-22T21:32:40Z")

</div>

No I was running basically with 57600 then I tried many rates (including 9600) to see if reducing baud rate will fix that  
Anyway the com is working fine since with the same code I receive api if I send it manually with xctu only dio change detect api ( tx 83) is not working while this same api is received if I use terminal or serial read ()

---

<div class="post-metadata">

**Author:** ![DavidLewis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@DavidLewis](https://forums.digi.com/u/DavidLewis)\
**Post date:** [August 7, 2024, 12:44pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/12 "2024-08-07T12:44:35Z")

</div>

It seems your Python program isn’t capturing the API frames from the XBee when the push button is pressed. Here are some quick tips to troubleshoot:

1. Ensure API Mode: Make sure your XBee is set to API mode, as it won’t send API frames in AT mode.
2. Check Data Handling: Verify that your loop correctly processes the incoming data, especially for change detect frames.
3. Add Debugging: Include print statements to log incoming data, which can help identify if messages are being received but not processed.

These steps should help you resolve the issue.

---

<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:** [August 7, 2024, 12:46pm UTC](https://forums.digi.com/t/dio-change-status-not-received-in-python/30880/13 "2024-08-07T12:46:44Z")

</div>

This sounds like you have not set the Change Detect function in the radios firmware to the correct values.
