Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Some questions about SLEEP, RTC and IRQs

    Scheduled Pinned Locked Moved WiPy 2&3
    rtcirqsleep
    2 Posts 2 Posters 1.5k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      Thosch42
      last edited by

      Hi again!
      The WiPy documentation shows, that the RTC is a valid wakeup source for the sleep mode. Derived from the example in the documentation and another forum thread I made this short example:

      import pycom
      import time
      from machine import RTC
      
      pycom.heartbeat(False)
      
      pycom.rgbled(0x007f00) # green
      time.sleep(2)
      pycom.rgbled(0x7f0000) # red
      time.sleep(2)
      pycom.rgbled(0x000000) # off
      
      rtc = machine.RTC()   # init with default time and date
      
      def alarm_handler (rtc_o):
          global rtc_wake
          rtc_wake = True
      
      # create a RTC alarm that expires after 5 seconds
      rtc.alarm(time=5000, repeat=True)
      
      # enable RTC interrupts
      rtc_i = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.SLEEP)
      
      # go into suspended mode
      while True:
          machine.sleep()
          if rtc_wake:
              rtc_wake = False
              print('Awake')
              pycom.rgbled(0x7f0000) # red
              time.sleep(1)
              pycom.rgbled(0x000000) # off
      

      But the code won't run. It seems to me, that the alarm feature of the RTC isn't implemented on my ESP32 based WiPy. Can someone confirm this?
      If this is true, how can I wakeup the WiPy from sleep mode?

      Cheers,
      Thomas

      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @Thosch42
        last edited by

        @Thosch42
        currently only

        machine.deepsleep(5000)
        

        is supported - this is only wakeup "source" - we all waiting for more :)

        think about people first, then computers

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom