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



  • 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



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



  • 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.



  • @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.



  • This post is deleted!


  • This post is deleted!


  • @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.



Pycom on Twitter