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

    Root causes of high deep sleep current [LoPy1, WiPy2 and SiPy], all the new modules **do not have deepsleep issues**

    Scheduled Pinned Locked Moved Announcements & News
    deepsleep
    127 Posts 48 Posters 109.8k Views 57 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.
    • B Offline
      bucknall @_peter
      last edited by bucknall

      @_peter Yes, this is possible. The footprint of the board is slightly wider than the LoPy but the functionality and pinout is identical to that of the LoPy. This is can be used as an exact replacement for the LoPy!

      Developer Evangelist - Pycom

      1 Reply Last reply Reply Quote 0
      • RobTuDelftR Offline
        RobTuDelft
        last edited by

        Is the script for the PIC also somewhere available?

        Without data you're just another person with an opinion.
        Hackster | About me

        1 Reply Last reply Reply Quote 0
        • M Offline
          mcook @Fred
          last edited by

          @Fred

          Hi,

          I received my PyTrack boards today. I have attached my LoPy to one of them. I am powering the PyTrack via USB. The USB is plugged into a USB multimeter. With the WiFi on, I see it is drawing about 125 mA at 5 VDC. After entering deep sleep, I see the current is reduced to ~48 mA. Is there some configuration that needs to be done in the code in order for the PyTrack boards to work properly with Deep Sleep?

          Mike

          1 Reply Last reply Reply Quote 0
          • D Offline
            daniel
            last edited by

            @mcook, entering deepsleep using the Pytrack as the controller of the operation requires a different approach. We have a library for this that will be published in a few days this week. This library also allows to performing several different operations on the PIC microcontroller that's on the Pytrack/Pysense like reading the battery voltage.

            Cheers,
            Daniel

            1 Reply Last reply Reply Quote 0
            • D Offline
              daniel
              last edited by

              Hello,

              In the meantime while we publish the official library later this week, here is a short version of it which can be used to enter deep sleep mode using the Pytrack/Pysense board and wakeup after a pre-defined number of seconds:

              from machine import I2C
              from machine import Pin
              import machine
              import time
              
              
              I2C_SLAVE_ADDR = const(8)    # This one seems to be an unpopular addresss
              LIS2HH12_I2C_ADDR = const(30)   # both Pysense and Pytrack have the accelerometer onboard
              
              CMD_PEEK = const(0x0)
              CMD_POKE = const(0x01)
              CMD_MAGIC = const(0x02)
              CMD_HW_VER = const(0x10)
              CMD_FW_VER = const(0x11)
              CMD_PROD_ID = const(0x12)
              CMD_SETUP_SLEEP = const(0x20)
              CMD_GO_SLEEP = const(0x21)
              CMD_BAUD_CHANGE = const(0x30)
              CMD_DFU = const(0x31)
              
              REG_CMD = const(0)
              REG_ADDRL = const(1)
              REG_ADDRH = const(2)
              REG_AND = const(3)
              REG_OR = const(4)
              REG_XOR = const(5)
              
              ANSELA_ADDR = const(0x18C)
              ANSELB_ADDR = const(0x18D)
              ANSELC_ADDR = const(0x18E)
              
              ADCON0_ADDR = const(0x9D)
              ADCON1_ADDR = const(0x9E)
              
              _ADCON0_CHS_POSN = const(0x02)
              _ADCON0_ADON_MASK = const(0x01)
              _ADCON1_ADCS_POSN = const(0x04)
              _ADCON0_GO_nDONE_MASK = const(0x02)
              
              ADRESL_ADDR = const(0x09B)
              ADRESH_ADDR = const(0x09C)
              
              PORTC_ADDR = const(0x00E)
              
              WPUA_ADDR = const(0x20C)
              
              MEMORY_BANK_ADDR = const(0x620)
              
              class Pysense:
              
                  def __init__(self, i2c=None, sda='P22', scl='P21'):
                      if i2c is not None:
                          self.i2c = i2c
                      else:
                          self.i2c = I2C(0, mode=I2C.MASTER, pins=(sda, scl))
                      self.reg = bytearray(6)
                      scan_r = self.i2c.scan()
                      if not scan_r or LIS2HH12_I2C_ADDR not in scan_r or not I2C_SLAVE_ADDR in scan_r:
                          raise Exception('Pysense board not detected')
              
                  def _write(self, data, wait=True):
                      self.i2c.writeto(I2C_SLAVE_ADDR, data)
                      if wait:
                          self._wait()
              
                  def _read(self, size):
                      return self.i2c.readfrom(I2C_SLAVE_ADDR, size + 1)[1:(size + 1)]
              
                  def _wait(self):
                      time.sleep_us(100)
                      while self.i2c.readfrom(I2C_SLAVE_ADDR, 1)[0] != 0xFF:
                          time.sleep_us(100)
              
                  def _send_cmd(self, cmd):
                      self._write(bytes([cmd]))
              
                  def setup_sleep(self, time_s):
                      self._write(bytes([CMD_SETUP_SLEEP, time_s & 0xFF, (time_s >> 8) & 0xFF, (time_s >> 16) & 0xFF]))
              
                  def go_to_sleep(self):
                      self._write(bytes([CMD_GO_SLEEP]), wait=False)
                      # kill the run pin
                      Pin('P3', mode=Pin.OUT, value=0)
              

              Example usage:

              from pysense import Pysense
              py = Pysense()
              py.setup_sleep(5)   # setup a 5 seconds sleep time
              py.go_to_sleep()
              

              This works for both Pysense and Pytrack.

              Cheers,
              Daniel

              1 Reply Last reply Reply Quote 1
              • L Offline
                lj Pybytes Beta @Fred
                last edited by

                @Fred

                I didn't received my Deep Sleep Shield , what is the process to check if my request has been registered, plan and hipped to me?

                best
                Luc

                1 Reply Last reply Reply Quote 0
                • I Offline
                  irvinvp @bucknall
                  last edited by

                  @bucknall Did the shields arrive?

                  1 Reply Last reply Reply Quote 0
                  • L Offline
                    leogaggl
                    last edited by

                    I am also wondering what the process is if the Deep Sleep Shields don't arrive. I ordered them when the email went around for my order of LoPy's but never received anything ?

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      rskoniec
                      last edited by rskoniec

                      I've filled the form at https://www.surveymonkey.co.uk/r/PSTPWBB (mid April) and still nothing - no email confirmation, order progress and no DS shields.

                      @Fred said in Root causes of high deep sleep current:

                      Dear All,
                      A quick update on this topic to confirm we are currently testing the Pilot Run samples in Eindhoven. All going well and we expect to have shields to ship circa 2 to 3 weeks e.g. 5/6 June. (...)

                      @Fred Any news?

                      The machine is working as good as it's code.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        daniel
                        last edited by

                        Hello,

                        We have received all the surveys filled up to now and everything is going OK. We are targeting mass production of the deep sleep shields in early July and ship shortly afterwards.

                        Cheers,
                        Daniel

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          crankshaft @Fred
                          last edited by

                          @Fred - Is it possible to acknowledge receipt of the request for a shield when it is initially made and then notify us when it is dispatched, as at the moment I have no idea whether my submission was successful, or when I am likely to receive the shields ?!

                          1 Reply Last reply Reply Quote 2
                          • A Offline
                            athtest800
                            last edited by

                            Hi!
                            The PIC10F322 needs programming? If yes, where can I find the code?
                            Thank you!

                            1 Reply Last reply Reply Quote 0
                            • I Offline
                              irvinvp
                              last edited by

                              @bucknall Did the shields arrive? is 13th July and i don´t have news.

                              R 1 Reply Last reply Reply Quote 0
                              • R Offline
                                rskoniec @irvinvp
                                last edited by

                                @irvinvp Here is the answer https://forum.pycom.io/topic/1480/deep-sleep-shields-delivery-update

                                The machine is working as good as it's code.

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  jalperin
                                  last edited by

                                  I wish to run my lopy on a pysense with the lowest possible current draw from a LiPo battery. I assume I would plug the deep sleep shield in between them. Correct?

                                  Could someone please summarize in one place all the appropriate actions to turn off everything but awake periodically to take a lux reading and transmit it via lora? Thanks for your help.

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

                                    @jalperin from what I understood, the Pysense (and Pytrack) boards actually incorporate what is present on the deep sleep shields.

                                    However, there is still a lingering issue on the Pysense (not the Pytrack) which still uses more current than it should in deep sleep, still waiting for a solution for this.

                                    1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      daniel
                                      last edited by

                                      @jcaron the reason for the higher current on the Pysense is because the sensors need to be disabled as part of the process of going to deepsleep. We will add that to the official library within the next few days.

                                      Cheers,
                                      Daniel

                                      J 1 Reply Last reply Reply Quote 0
                                      • J Offline
                                        jalperin
                                        last edited by

                                        Thank you @jcaron.

                                        Unfortunately, I remain where I started. I am unsure whether I am shutting down WiFi and Bluetooth (I read various posts), and I am unsure how to properly get both the pysense and lopy to deep sleep.

                                        Do I understand it correctly that I don't really need the deep sleep shield but I do need new libraries (that will show up in a few days and will hopefully contain examples)? If so, how does one shut off wifi and bluetooth?

                                        Thanks for your help.

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

                                          @jalperin With the Pysense board, you need to:

                                          • use the libraries that are available on github:
                                            https://github.com/pycom/pycom-libraries/tree/master/pysense/lib

                                          • add the following code:

                                            from pysense import Pysense
                                            py = Pysense()
                                            py.setup_sleep(number_of_seconds)
                                            py.go_to_sleep()
                                            

                                          This will tell the Pysense to stop the LoPy (including Wi-Fi, BT, LoRa...). It's actually powered off. It will be woken up after the given number of seconds has elapsed. Work is in progress to allow wake up on other conditions (some input going high for instance).

                                          At the moment, this will bring down power consumption to about 2.5 mA when running from a LiPo battery. Ultimately it should go down to a fraction of that once everything is correctly shut down.

                                          Note that when the LoPy comes out of deep sleep, it's as if it just rebooted. There are still issues with LoRa keeping state for instance.

                                          As the firmware turns on Wi-Fi when it starts, it's a good idea to stop it right away if you don't need it during the time the LoPy is awake. Not sure about Bluetooth (I stop it, but I'm not sure that's actually needed).

                                          Hope that helps.

                                          1 Reply Last reply Reply Quote 0
                                          • J Offline
                                            jalperin
                                            last edited by

                                            Thank you, @jcaron. Very helpful.

                                            I have been executing that code, but followed by machine.deepsleep(). I gather that is not necessary. Correct?

                                            So, lastly, exactly how does one turn off wifi and bluetooth (I've read different methods in this forum)?

                                            J 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
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 3 / 7
                                            • First post
                                              Last post

                                            Pycom on Twitter

                                            Pycom