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

    lopy4 wakeup on change

    Scheduled Pinned Locked Moved LoPy
    2 Posts 2 Posters 26 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.
    • K Offline
      kjm
      last edited by kjm

      I'm trying to figure how to wakeup a lopy4 when a float switch changes (either off-to-on or on-to-off).

      import machine, time; from machine import Pin
      switch=Pin('P23', Pin.IN, Pin.PULL_UP)
      print ('switch', switch(), 'deepsleep')                               #read switch eg 0=on
      machine.pin_sleep_wakeup(pins=['P23'],mode=not switch(),enable_pull=1)#wakeup when switch changes eg 1=off
      machine.deepsleep()
      

      works but feels clunky & if the switch changes state between the last line & the second last line it won't wakeup. Is there a way to detect a change other than specifying the change you expect before hand?

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @kjm
        last edited by

        @kjm that’s a limitation of the ESP32 itself. There are two ways to wake up from deep sleep on pin state changes, and both require you to specify the target level.

        See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html for details.

        There may be alternatives using the ULP co-processor, haven’t checked if that would actually be possible.

        1 Reply Last reply Reply Quote 1

        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