Open
Description
CircuitPython version
Adafruit CircuitPython 8.0.5 on 2023-03-31; Raspberry Pi Pico with rp2040
also
Adafruit CircuitPython 8.0.5 on 2023-03-31; Pimoroni Pico LiPo (16MB) with rp2040
Code/REPL
#
import board
import digitalio
import time
import alarm
from analogio import AnalogIn
logInt = 15.0 # seconds
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
vsys = AnalogIn(board.A2) #reads the voltage
conversion_factor = 3 * 3.3 / 65535
while True:
led.value = True
voltage = vsys.value * conversion_factor
s_bat = f'{voltage:.2f}'
# stripped out the log-to-flash lines for clarity
led.value = False
# time.sleep(logInt)
# With time.sleep(), logging words fine. Does not work with light_sleep_until_alarms() below.
# Alarms work fine without the AnalogIn read.
#
# Create a an alarm that will trigger logInt seconds from now.
time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + logInt)
# Do a light sleep until the alarm wakes us.
alarm.light_sleep_until_alarms(time_alarm)
Behavior
Reading from an AnalogIn pin causes RP2040 light sleep to fail (code above).
No error messages; the loop just doesn't repeat.
Loop works fine with time.sleep().
Description
Might be related to #7568 (suggested by Dan).
Same bug on both RPi Pico and Pimoroni Pico LiPo
Additional information
No response