Description
Adafruit CircuitPython 10.0.0-alpha.6 on 2025-05-17; Adafruit Feather ESP32S2 with ESP32S2
Reproducer code:
import alarm
import board
import digitalio
import neopixel
from os import getenv
import random
import time
import adafruit_connection_manager
import adafruit_requests
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
import wifi
# On MagTag, enable power to NeoPixels.
# Remove these two lines on boards without board.NEOPIXEL_POWER.
np_power = digitalio.DigitalInOut(board.NEOPIXEL_POWER)
np_power.switch_to_output(value=True)
builtin_led = digitalio.DigitalInOut(board.LED)
builtin_led.switch_to_output(value=True)
status_pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1, pixel_order=neopixel.GRB, auto_write=True)
status_pixel[0] = 0xff0000
status_pixel[0] = 0xffff00
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
ssid = getenv("WIFI_SSID")
password = getenv("WIFI_PASSWORD")
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")
print("Connecting to %s" % ssid)
wifi.radio.connect(ssid, password)
print("Connected to %s!" % ssid)
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
requests = adafruit_requests.Session(pool, ssl_context)
# Initialize an Adafruit IO HTTP API object
io = IO_HTTP(aio_username, aio_key, requests)
status_pixel[0] = 0x00ff00
try:
random_feed = io.get_feed("random")
io.send_data(random_feed["key"], random.randint(0,9999))
except AdafruitIO_RequestError as e:
print(e)
#print("You must create feeds on AdafruitIO for: temperature, humidity, and pressure")
except OSError as e:
print(e)
np_power.value = False
builtin_led.value = False
# Create a an alarm that will trigger 20 seconds from now.
# time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + (5 * 60))
time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 60)
# Exit the program, and then deep sleep until the alarm wakes us.
alarm.exit_and_deep_sleep_until_alarms(time_alarm)
# Does not return, so we never get here.
I ran this code on a Feather S2 powered by a 3.7v battery connected to the JST port. After running for "a while" and then unplugging the battery and plugging the feather back in to the computer the flash storage shows signs of corruption.
Most of the times that I've seen it happen it creates a file with a weird four character filename:
The file does not always have the same name, but it is often similar. Here is another one:
One time instead of creating a file like this there were a few characters within the code.py
that got corrupted instead leading to syntax error when it tried to run.
After having the corrupted file appear I have been using storage.erase_filesystem()
in the REPL to format the flash and get back to a clean state before starting the next trial.
Often times the code seems to keep running seemingly successfully, the neopixel blinks yellow and green during successful wake up / network connect / post data and I've seen that it has continued doing that but after "a while" when I switched to the PC I found the corrupted file.
I tested 9.2.8 and never had the same issue occur. I've also tested 10 alpha 6 with code that only joins the WIFI network and does not POST data, and I did not have the issue occur under that code either.
"a while" seems to be anywhere from a few minutes to an hour or two. On the trials where it did not occur I left them running for 8+ hours and never saw the issue come up.
I will test on USB power from a wall adapter next to try to remove the JST connected battery from the equation.