Issue with MAX6675 and XBee3 – Device Not Scanning After Flashing Code

Hello everyone,
I’m currently working on a project involving an XBee3 module and a MAX6675 thermocouple sensor. I flashed the following MicroPython code to the XBee3 device:

python

from max6675 import MAX6675
import time
import machine
import xbee

Configure XBee3 sleep settings (Cyclic Sleep Mode)

xbee.atcmd(‘SM’, 4) # Set to Cyclic Sleep mode
xbee.atcmd(‘SP’, 1000) # Sleep period: 1000 * 10ms = 10 seconds
xbee.atcmd(‘ST’, 100) # Stay awake for 100ms (adjust if needed)
xbee.atcmd(‘WR’) # Write settings to non-volatile memory

Temperature sensor setup

thermo = MAX6675(
sclk_pin=machine.Pin(“D2”),
cs_pin=machine.Pin(“D3”),
miso_pin=machine.Pin(“D12”)
)

def send_data(temp_c, temp_f):
# Customize with your transmission method
print(“{:.2f},{:.2f},”.format(temp_c, temp_f))

try:
# Read and send temperature data
temp_c = thermo.read_celsius()
temp_f = thermo.read_fahrenheit()
send_data(temp_c, temp_f)
except Exception as e:
print(“Error: {}”.format(e))

After flashing this code, the console showed:

Parsing /flash/main.py…
Compiling /flash/main.py…
Running bytecode…
However, after this point:

The XBee3 module no longer appears in scanning mode.

I am unable to detect or communicate with the device.

I suspect the sleep configuration (SM=4, cyclic sleep) may be interfering with connectivity or causing the module to enter a sleep state too quickly. Could the timing parameters (SP and ST) be affecting serial communication or preventing proper startup?

Has anyone faced a similar issue with XBee3 and sensor integration? Any suggestions on how to recover the device or how to activate xbee so that it could be seen in the discover mode, or adjust the sleep setting to prevent this would be greatly appreciated

May I suggest you comment out the sleep function from your code. You very well could be sleeping too fast.

For commenting out the sleep function in my code to upload new firmware to my XBee module. I must first discover the XBee in XCTU. The problem is that I can’t find the XBee in discovery mode, likely because it’s already in sleep mode. Since I can’t discover it, I’m unable to upload the updated code. How can I resolve this issue?

I would suggest trying to use a remote AT command from a another radio in the network to disable the Python auto start as well as changing AP command to transparent. Then you can do a reboot and have the Python application no running.