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



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



  • @bucknall Did the shields arrive?


  • Pybytes Beta

    @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



  • 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



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



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



  • Is the script for the PIC also somewhere available?



  • @_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!



  • @bucknall I designed the board for Lopy and thought of replacing it with the oem expansion board + oem module. According to you is it possible?



  • @_peter If you're using a LoPy (Development Kit), you can currently get deep sleep with a Pytrack or Pysense - without these you'll need to wait until the Deep Sleep Sheild arrives



  • @bucknall Thank you, we are waiting for the shields.



  • @danielm I have to deliver a LoRaWan sensor node within about 15 days giving me the chance to deep-sleep for 10 minutes and that when it wake up do not join again. is possible ?



  • @danielm The Deep Sleep Shields should be arriving in the 3rd week of June. We will ship them as soon as we receive them. Thanks for your patience!



  • @_peter the OEM reference board does have the same LoPy pin out, with the only difference that P12 is also used there to drive the RF switch (you can see that on the schematics).



  • @bucknall
    When are you planning to ship deep sleep shields to your customers?



  • @_peter We currently have the OEM baseboard reference design available here - https://docs.pycom.io/pycom_esp32/pycom_esp32/datasheets.html#oem-baseboard-reference-design



  • @bucknall Thank you, I apologize but I do not find any documentation on the OEM Reference Board. Do you know where to find it?



  • @_peter The only modules affected by the deep sleep issue is the Development versions of the WiPy 2.0, LoPy and SiPy. All of the OEM modules are not affected by this issue as they do not use the same power regulation as found on the affected modules. This includes the OEM Reference Board.

    Thanks!



  • Unfortunately, the solution to an alternative expansion board is not good for me. I'll have to mount it on an ad hoc card. Question: The OEM Reference Board (https://www.pycom.io/product/oem-reference-board/) + L01 OEM Module (https://www.pycom.io/product/l01/) can solve the problem ? I saw this: https://www.pycom.io/l01-oem-module-deep-sleep-test/. The OEM reference board has the same Lopy pinout?



  • Hi @jomifo,

    If you use a Pysense or Pytrack, you do not need to use the deep sleep shield as the Pysense/track already have this feature built in!


Log in to reply
 

Pycom on Twitter