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

    Sleep mode with LoPy4 and ExpBoard 3.0 (Pin wake up)

    Scheduled Pinned Locked Moved Discussion
    lopy4expansion boardsleepdeep sleepwake on pin
    7 Posts 3 Posters 1.2k Views 3 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.
    • P Offline
      ProtonX
      last edited by

      Hi! I am quite new to Pycom and Lopy and I am trying to program the sleep mode:
      I want it to wake it up only if there is a high signal on one of two pins. Eg. pin1 or pin2...
      Then I want to do two different things depending which pin it was.
      The rest of the time, it has to be in sleep mode. (It runs on a Li-Ion Battery and should use low power.)

      My questions:

      1. Is a LoPy4 and an Expansion Board 3.0 the correct hardware for this or do I need a Deepsleep Shield?
      2. Is there a working example I could use as a start?
      3. Do I have to join the LoraWAN again, every time I am waking it up?
      4. Is it possible to wake it up when it receives a Lora Message?

      I would really appreciate if you guys could help me to start.
      Thanks ProtonX

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

        @ProtonX

        For 1: I suppose so, but i don't have that specific hardware combination so I'll let others chime in (and for 2. as well, but I think there are examples in the documentation).

        For 3: No. But you need to save the LoRa state to nvram before going to sleep (lora.nvram_state) and restore the state (lora.nvram_restore) when you wake up.

        For 4: No. When in deep sleep, the LoRa modem is sleeping as well, and can't wake the module up. In any case, to receive a message at any time (as opposed to only right after you send an uplink), you need to set LoRaWAN to class C, which means the LoRa modem is listening (and using power) all the time, which is not a good idea if you're running on battery (and if you need deep sleep, it probably means you're running on battery). Even if you could have the modem listening with the ESP32 sleeping (which I don't think is possible at this time), the modem would use > 10 mA, which would drain even a relatively large 2500 mAh battery in a few days. You would also need a network that supports class C devices, which is not common.

        The basic principle for battery-powered devices on LoRa is that they sleep most of the time, and will only listen for downlinks in a small window right after they send something. The network will queue messages and send them to the device after it receives something from it.

        danD 1 Reply Last reply Reply Quote 1
        • P Offline
          ProtonX
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • P Offline
            ProtonX
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • danD Offline
              dan @jcaron
              last edited by

              @jcaron @ProtonX You don't need the Deep Sleep shield, it's only needed for LoPy, WiPy, and SiPy. You can find the deep sleep documentation here.

              1 Reply Last reply Reply Quote 1
              • P Offline
                ProtonX
                last edited by

                Thank you. Sleep mode seems to work now! I will do some current tests today.

                As a next step, I would like to implement that the lora state is safed before sleepmode and restored when restarting (from an interrupt).
                I haven't found any documentation about the "nvram_state" and "nvram_restore" function. Where can I find this?
                Or is it just: lora.nvram_state() and lora.nvram_restore() where I need it in the code?

                Thanks for your help! It starts to be fun.

                P 1 Reply Last reply Reply Quote 0
                • P Offline
                  ProtonX @ProtonX
                  last edited by

                  Nevermind. It works now.
                  The correct function is: lora.nvram_save() and lora.nvram_restore()

                  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