How to Re-initialize a Stuck ESP32 (in CircuitPython)
I designed my particulate air quality sensor project around Adafruit's PyPortal. It uses a ESP32 coprocessor for networking.
Unfortunately, the ESP32 is a little flaky. It tends to lose track of the network after an hour or so:
ESP32 not responding Traceback (most recent call last): File "code.py", line 182, inFile "adafruit_requests.py", line 725, in post File "adafruit_requests.py", line 649, in request File "adafruit_connection_manager.py", line 331, in get_socket File "adafruit_connection_manager.py", line 248, in _get_connected_socket File "adafruit_connection_manager.py", line 61, in connect File "adafruit_esp32spi/adafruit_esp32spi_socketpool.py", line 114, in connect File "adafruit_esp32spi/adafruit_esp32spi.py", line 899, in socket_connect File "adafruit_esp32spi/adafruit_esp32spi.py", line 801, in socket_open File "adafruit_esp32spi/adafruit_esp32spi.py", line 422, in _send_command_get_response File "adafruit_esp32spi/adafruit_esp32spi.py", line 378, in _wait_response_cmd File "adafruit_esp32spi/adafruit_esp32spi.py", line 292, in _wait_for_ready TimeoutError: ESP32 not responding
I tried re-initializing the network,
but it didn't help: re-initializing always died with
Timed out waiting for SPI char
and
SCK in use.
There are lots of people asking about this on the net, but I couldn't find a
discussion that actually had a solution for how to re-initialize a stuck ESP32.
So I asked Claude. I know, AI, eww ... but Claude seems to have access to
CircuitPython code and discussions that Google doesn't index, so sometimes
it's the best way to find out how to solve CircuitPython problems.
It took a couple of iterations (each requiring a few hours of testing,
since it typically takes an hour or so before the network stops working),
but we got there.
Here's what seems to work for me.
[ 10:10 Apr 30, 2026 More hardware | permalink to this entry | ]