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
sleep and deepsleep
Re: sleep and deepsleep
You should put your code inside [ code] Put code here [ /code] tags (remove the space after the opening square bracket.
Then your code retains its indentation, like this:
Then your code retains its indentation, like this:
Code: Select all
while True:
pass
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: sleep and deepsleep
Is it going to sleep once, waking up, going to sleep again and never waking up? If that's the case, there's a known issue with repeating RTC alarms and machine.sleep(). Please try to use single shot alarms instead (setup the alarm again after waking up).
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: sleep and deepsleep
Also, waking up from deepsleep works like coming out out of reset, so execution will being from main. You need to check the reset reason and decide what to do.
Re: sleep and deepsleep
dhylands wrote:You should put your code inside [ code] Put code here [ /code] tags (remove the space after the opening square bracket.
Then your code retains its indentation, like this:Code: Select all
while True: pass
Code: Select all
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
wipy.heartbeat(False) # disable the heartbeat LED
def alarm_handler (rtc_o):
wipy.heartbeat(False) # disable the heartbeat LED
machine.sleep()
# 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()
Ok thanks