Infinite loop of unable to connect

Im using Xbee as an I2C passthrough like this:
reboard(qwiic) → explorer → xbee : xbee ← explorer ← redboard (qwiic)

The xbee receives data just fine and half the time it works to send data from i2c to the other xbee. But the other half it gets caught in an infinite loop saying it cant connect. Here is the relevant code:


while True:
    time.sleep(0.2)  # Small delay to prevent overload
    try:
        # 1️⃣ Read from I2C (ESP32 sending data)
        ...

        # 2️⃣ Write back to I2C if we have received data from XBee
        ...

        # 3️⃣ Send data received from I2C over XBee
        if i2c_received_queue:
            try:
                data_to_send = i2c_received_queue.pop(0) #remove the first item.
                xbee.transmit(DEST_XBEE_ADDR, data_to_send)
                print("Sent Wirelessly (local_xbee --> remote xbee)", data_to_send)
            except Exception as e:
                print("Error sending from I2C overXbee:", e)
                i2c_received_queue.insert(0, data_to_send) #put it back at the front.
                print("Data re-queued.") # tell the user.
                time.sleep(1)

The output:

Data Length Read: 8
I2C Read (i2c --> local_xbee): b'testasdf'
Error sending from I2C overXbee: [Errno 7107] ENOTCONN
Data re-queued.
Error sending from I2C overXbee: [Errno 7107] ENOTCONN
Data re-queued.
Error sending from I2C overXbee: [Errno 7107] ENOTCONN

I would use serial but I dont have a way to solder it together right now.

What firmware version are you running on both modules?

digimesh 3012 but i tried the others and it still didnt work.

also ive isolated the problem down to a single file

import xbee
import time
#sending it to broadcast
DEST_XBEE_ADDR = b'\x00\x00\x00\x00\x00\x00\xFF\xFF'
while True:

    received_msg = xbee.receive()

    time.sleep(0.1)  # Small delay to prevent overload
    try:
        if received_msg: 
            received_data = received_msg
          
            xbee.transmit(DEST_XBEE_ADDR, b'asdf')

even a simple echo like this fails, it only echos back half the time the other half it just fails with that unable to connect error.

even directly putting the addresses instead of using broadcast address works only half the time and then fails on loop.

Try reducing your broadcast time from 0.1 to 1.0.

even with the sleep being increased to something like 5 seconds, its still doing like a 50/50 chance. Im on 3012 firmware btw, i heard somewhere that 3014 fixes is but 3014 isnt even an option in the configuration software xctu

I would suggest that you submit a support case by going to my.digi.com and logging in