Power consumption / wifi-information storage machine.deepsleep()



  • Hi there,

    i run a sensor with the Gpy and want to do that by battery. At first i started to test the machine.deepsleep() and checked the current for estimating the uptime by battery. I uses that simple code:

    import time
    import machine
    
    i=True
    while i==True:
        print('nomal mode 15sec')
        time.sleep(15)
        i = False
    
    print('deepsleep mode 15sec')
    machine.deepsleep(15000)
    

    The boot.py is empty. After upload, i connected just the Gpy(without expansion board) to a power supply and measured the current using a amperemeter. This is what i got:
    0_1525350649062_Current_deepsleep.png

    The y-axis are [A] and the x-axis just number of the value.
    Refering to the given current in the specsheet of 25 uA in deepsleep the first minumum at number 40 is about 18-23 uA and fits actually really good. All of the following minimums are about 32 mA and not the expected 25 uA.
    Someone got any idea why that is? Did i failed to see something?!

    The other problem i got is how to store the wifi-information?

    At the beginning of my script the Gpy is starting a web-server for choosing the correct wifi-ssid and insert the Password for that. After collecting this information my measurement begins. The measured value ist going to be sent by MQTT, then my wish is deepsleep for one day. After every further restart (cause of machine.deepsleep()) the Gpy shound´t start the webserver and use the stored wifi-information.
    Is this possible? What would be the easiest way?

    Thanks a lot!

    Andy



  • @jmarcelino today i was able to add the code:

    import time
    import machine
    from network import LTE
    
    i=True
    
    while i==True:
        print('nomal mode 15sec')
        time.sleep(15)
            
        i = False
    
    lte = LTE()
    lte.deinit()
    
    
    print('deepsleep mode 15sec')
    machine.deepsleep(15000)
    

    but it just runs the error:

    >>> Running o:\Benutzerablagen\Nellis\Pycom GPY\ProjektTest\main.py
    
    >>>
    >>>
    >>>
    >>>
    nomal mode 15sec
    ╝Traceback (most recent call last):
      File "<stdin>", line 16, in <module>
    OSError: the requested operation failed
    ╝>
    MicroPython v1.8.6-849-83e2f7f on 2018-03-19; GPy with ESP32
    Type "help()" for more information.
    

    Is there an other solution i could try?



  • @jmarcelino if the rtc memory is retained on deepsleep this is ideal for transient, but useful state.

    If you want to keep persistence between resets i agree that internal flash is better.

    If you want to keep data between deepsleeps, that may change allot (think temp readings like 21.9 - the decimal may change) rtc could be better.

    Is supporting rtc memory on the roadmap?



  • @gregcope
    I think RTC RAM on the ESP32 gets cleared unless waking from deepsleep so it's less useful that one might think.



  • @jmarcelino will pycom support rtc memory soon, which i understand the ESPs have?



  • @marcobenini thanks



  • @gregcope
    Pycom will support LittleFS for the internal filesystem soon (already in testing) which does wear levelling



  • @gregcope With that volume of writes per year, and being powered by a battery, it is probably better to use a FRAM external memory (I2C or SPI).
    FRAM read/write cycles are about 10^12 - 10^15 depending manufacturer and technology used.



  • @jmarcelino How many write cycles can the pycom family internal flash handle?

    I want to keep state on an SD card (pytrack), but that is not possible as the SD consumes too much power ... (on the next version can we power the SDCard off the 3v3_sensor rail that I understand powers down on sleep).

    I would assume I write every minute. Which is 500K writes a year or so...



  • Hi @andy_n

    I think the LTE modem isn't correctly going into deepsleep after the first time, we're investigating it. As a "debug" step you can try to add

    lte = LTE()
    lte.deinit()
    

    to the end of your cycle. But note this is only for debug purposes, you shouldn't do it in production, instead it's better to let the modem handle it automatically.

    Regarding storing WiFi information the easiest place is to have it on a file in /flash. You can use regular Python file operations to write and read data from it.



Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.