sleep and deepsleep
Posted: Sun Nov 29, 2015 2:10 pm
I have trouble getting a wipy to repeated go to sleep after executing some housekeeping and eventually reading some sensor. However the code below sleeps only once. I am using MicroPython v1.5-1-ge954604 on 2015-10-21; WiPy with CC3200
# code begin
import machine
from machine import RTC
import wipy
rtc = machine.RTC() # init with default time and date
rtc = RTC(datetime=(2015, 10, 31, 18, 0, 0, 0, None)) # init with a specific time and date
# print(rtc.now())
wipy.heartbeat(False) # disable the heartbeat LED
def alarm_handler (rtc_o):
wipy.heartbeat(False) # disable the heartbeat LED
machine.sleep()
# do some non blocking operations
# warning printing on an irq via telnet is not
# possible, only via UART
# create a RTC alarm that expires after 10 seconds
rtc.alarm(time=10000, repeat=True) # expected this to repeatedly set the alarm
# enable RTC interrupts
rtc_i = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.DEEPSLEEP)
# I can't get this to go into repeated sleep !!! kinda expected in repeat set true above that the instructions would execute in the handler
while True:
wipy.heartbeat(False) # disable the heartbeat LED and keep current low
machine.deepsleep()
#code end
# code begin
import machine
from machine import RTC
import wipy
rtc = machine.RTC() # init with default time and date
rtc = RTC(datetime=(2015, 10, 31, 18, 0, 0, 0, None)) # init with a specific time and date
# print(rtc.now())
wipy.heartbeat(False) # disable the heartbeat LED
def alarm_handler (rtc_o):
wipy.heartbeat(False) # disable the heartbeat LED
machine.sleep()
# do some non blocking operations
# warning printing on an irq via telnet is not
# possible, only via UART
# create a RTC alarm that expires after 10 seconds
rtc.alarm(time=10000, repeat=True) # expected this to repeatedly set the alarm
# enable RTC interrupts
rtc_i = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.DEEPSLEEP)
# I can't get this to go into repeated sleep !!! kinda expected in repeat set true above that the instructions would execute in the handler
while True:
wipy.heartbeat(False) # disable the heartbeat LED and keep current low
machine.deepsleep()
#code end