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

    FiPy deepsleep methods

    Scheduled Pinned Locked Moved FiPy
    24 Posts 7 Posters 267 Views 8 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.
    • G Offline
      Gijs
      last edited by Gijs

      I finally got around to testing this with our otii-arc, using the Fipy on 1.20.2.r4, with LTE modem firmware LR5.2.1.0-48829 (Cat-M1) and all boot flags set to False, in an expansionboard v3.1 (no jumpers), I was able to get down to ~30uA.
      I will let you know of the results for LR6 41019 (NB-IoT)

      You can find the example scripts I used below

      #setting boot flags
      
      import pycom
      print('Current boot flags')
      print('Heartbeat on boot: \t', pycom.heartbeat_on_boot())
      print('WiFi on boot: \t\t', pycom.wifi_on_boot())
      print('LTE modem on boot: \t', pycom.lte_modem_en_on_boot())
      print('Pybytes on boot: \t', pycom.pybytes_on_boot())
      print('Smart config on boot: \t', pycom.smart_config_on_boot())
      print('Watchdog on boot: \t', pycom.wdt_on_boot())
      print('setting ALL boot flags to False')
      pycom.heartbeat_on_boot(False)
      pycom.wifi_on_boot(False)
      pycom.lte_modem_en_on_boot(False)
      pycom.pybytes_on_boot(False)
      pycom.smart_config_on_boot(False)
      pycom.wdt_on_boot(False)
      print('Heartbeat on boot: \t', pycom.heartbeat_on_boot())
      print('WiFi on boot: \t\t', pycom.wifi_on_boot())
      print('LTE modem on boot: \t', pycom.lte_modem_en_on_boot())
      print('Pybytes on boot: \t', pycom.pybytes_on_boot())
      print('Smart config on boot: \t', pycom.smart_config_on_boot())
      print('Watchdog on boot: \t', pycom.wdt_on_boot())
      

      Deepsleep:

      import machine
      import time
      import pycom
      print("log {}".format(time.ticks_ms()))
      print(pycom.heartbeat())
      time.sleep(1)
      time.sleep(1)
      time.sleep(1)
      machine.deepsleep(10000)
      
      
      
      1 Reply Last reply Reply Quote 0
      • G Offline
        Gijs
        last edited by

        Returning to this with the LTE firmware version you're using, LR6 41019 (NB-IoT) and the same boot flags, I again get results close to ~35uA with the same Fipy. Not sure what the difference is between our setups, except that Im using an expansionboard, but that should not make a (positive) difference here. Are you confident in your current measurement setup?
        Let me know!

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

          @Gijs I think the big difference is that you never instantiate LTE, whereas they do (which is kind of useful on an LTE-capable board ;-> ), but then never manage to stop it from drawing milliamps.

          I would suppose the goal is to reproduce (at least) one of the scenarios listed here, i.e. either:

          • manage to switch off the modem (in theory with lte.deinit()) so that it completely stops drawing power
          • get the modem in power saving mode (in theory with lte.deinit(detach=False, reset=False) after setting the PSM parameters) so that it draws as little as possible.
          K 1 Reply Last reply Reply Quote 1
          • G Offline
            Gijs
            last edited by

            Ah sorry then I misunderstood the problem at hand. I thought it was impossible for them to get down to 35uA at all. I'll have a look at this again then.

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

              @jcaron Agree with your earlier comment that lte.init()/deinit() are vague & vary with the version. Also we've found that deepsleep current also depends on if the modem was reset at some point. We've found

              lte.deinit(); lte.init(); lte.deinit()
              

              is necessary to get uA deepsleep after an lte modem reset.

              1 Reply Last reply Reply Quote 1
              • G Offline
                Gijs
                last edited by Gijs

                Sorry, it took me some time to look at this again, but updating my previous example to include LTE, this seems to be the proper way on NB-41019:

                import machine
                import time
                import pycom
                from network import LTE
                lte = LTE()
                print("log {}".format(time.ticks_ms()))
                print(pycom.heartbeat())
                lte.deinit(reset=True)
                time.sleep(1)
                time.sleep(1)
                time.sleep(1)
                machine.deepsleep(10000)
                

                To clarify, by default lte.deinit() closes the UART connection to the modem, and the modem should put itself into sleep mode as its no longer needed. Except, the behaviour is somewhat unreliable, so forcing the flag reset=True, we can force the modem to go back to its initial powerup behaviour, which is to go to sleep when its no longer needed. For example calling the following:

                lte.deinit()
                lte.reset()
                

                Does not quite work, as we close the UART before resetting. Moreover, switching the statements will wake the modem after the reset, which is also not desired.
                In my testing, I was able to get the device down to 35uA, with the LTE modem included

                L J 2 Replies Last reply Reply Quote 5
                • L Offline
                  livius @Gijs
                  last edited by livius

                  @Gijs said in FiPy deepsleep methods:

                  lte.deinit(reset=True)

                  It is in doc but i suppose it should be more strictly commented to highlight the problem.
                  https://docs.pycom.io/firmwareapi/pycom/network/lte/#ltedeinitdetachtrue-resetfalse

                  think about people first, then computers

                  1 Reply Last reply Reply Quote 3
                  • J Offline
                    jcaron @Gijs
                    last edited by

                    @Gijs You should probably also update the first example at https://docs.pycom.io/tutorials/networks/lte/power/ then.

                    Can you also clarify whether the time.sleep statements are required?

                    Also, even though you instantiate LTE, you don't do much with it before going back to sleep. Did you try a full init-attach-connect-send-sleep cycle?

                    I'm pretty sure many will want to know if this works for both NB-IOT and Cat-M1.

                    I think it would be great for someone at Pycom to take each and everyone of the tutorials and examples (IIRC there are examples here and there in the reference part of the documentation) and check that they indeed work as they should with the current versions (and ideally list for each "tested with version XXX", including both module and modem firmware versions where appropriate, and all relevant details to be able to reproduce the test). For all examples involving deep sleep, stating the resulting deep sleep current would be great.

                    The next step would then be prior to any new release to check that all those still work. Many tutorials and examples have gone awry over time.

                    That would probably one the biggest steps Pycom could take towards better QA. Quite some work and probably a full time job (or maybe several), but it would save soooo much time for all the people trying to reproduce examples that just don't work...

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

                      @jcaron Not to mention what to do when the deinit attempt causes an line "66 OSError: the requested operation failed"!

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        Gijs
                        last edited by

                        I'll answer the questions I can answer now, for the other ones I'll have to get back to you

                        Can you also clarify whether the time.sleep statements are required?

                        This is for me to determine when something is happening in the code during my power measurement and should allow to CTRL+C out of the deepsleep loop. I dont think it provides any other 'functionality'

                        Also, even though you instantiate LTE, you don't do much with it before going back to sleep. Did you try a full init-attach-connect-send-sleep cycle?

                        I did not, mainly because I couldn't come by any simcard at the time of measuring. Though I believe it should make no difference in the end result per the workings of lte.deinit(reset=True)

                        I'm pretty sure many will want to know if this works for both NB-IOT and Cat-M1.

                        Yes, I understand. At the moment I cannot be conclusive about this, as there are some dissimilarities between the firmwares. We're working on gathering operational current measurements to publish in the docs that should be reproducable, but its taking some more time than expected.

                        I think it would be great for someone at Pycom to take each and everyone of the tutorials and examples (IIRC there are examples here and there in the reference part of the documentation) and check that they indeed work as they should with the current versions (and ideally list for each "tested with version XXX", including both module and modem firmware versions where appropriate, and all relevant details to be able to reproduce the test). For all examples involving deep sleep, stating the resulting deep sleep current would be great.

                        I totally agree. All examples should work with the latest (stable) firmware. At the moment we're thinking about syncing the examples in the docs to a github repository (just like how it used to be in the pycom-libraries repo), so that when the repo is updated, the examples automatically update in the docs. Though we were not able to find a system yet.

                        66 OSError: the requested operation failed

                        This is something I'll have to look into again, but things keep coming up :(

                        1 Reply Last reply Reply Quote 0
                        • B Offline
                          BlackDuck @frederik Leys
                          last edited by

                          Hey @frederik-Leys, the LoPy does not have an LTE Modem so lte = LTE() should be have no effect on LoPy but und FiPy it should start the modem.

                          Change your code to:

                          import pycom
                          import machine
                          import time
                          from network import LTE
                          from network import WLAN
                          wlan = WLAN()
                          lte = LTE()
                          time.sleep(5)
                          lte.init()
                          wlan.deinit()
                          
                          pycom.heartbeat(False)
                          
                          print(pycom.heartbeat_on_boot())
                          print(pycom.lte_modem_en_on_boot())
                          print(pycom.pybytes_on_boot())
                          print(pycom.smart_config_on_boot())
                          print(pycom.wdt_on_boot())
                          print(pycom.wifi_on_boot())
                          
                          #colors in hexadecimal (0xRRGGBB)
                          pycom.rgbled(0x00FF00) # Red
                          time.sleep(1)
                          lte.deinit()
                          machine.deepsleep(40*1000)
                          

                          To get in uA range. Or let it run in powersave mode like:

                          import pycom
                          import machine
                          import time
                          from network import LTE
                          from network import WLAN
                          wlan = WLAN()
                          lte = LTE(psm_period_value=1, psm_period_unit=LTE.PSM_PERIOD_1H,
                                    psm_active_value=5, psm_active_unit=LTE.PSM_ACTIVE_2S )
                          print(lte.psm())
                          time.sleep(5)
                          lte.init()
                          wlan.deinit()
                          
                          pycom.heartbeat(False)
                          
                          print(pycom.heartbeat_on_boot())
                          print(pycom.lte_modem_en_on_boot())
                          print(pycom.pybytes_on_boot())
                          print(pycom.smart_config_on_boot())
                          print(pycom.wdt_on_boot())
                          print(pycom.wifi_on_boot())
                          
                          #colors in hexadecimal (0xRRGGBB)
                          pycom.rgbled(0x00FF00) # Red
                          time.sleep(1)
                          lte.deinit(detach=False, reset=False)
                          machine.deepsleep(40*1000)
                          

                          which brought me to 300uA.

                          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
                          • 2
                          • 2 / 2
                          • First post
                            Last post

                          Pycom on Twitter

                          Pycom