how can I hold a data after I used deep sleep python

  • I am using fipy and sigfox to send data from some sensors, and pytrack to get the coordinates, the sensor data will be sent every hour and the coordinates only 1 time a day, after sending a message with the sensor data I want to put fipy on deep sleep to save energy. the problem is that after using deep sleep the device restarts and I can't get the coordinates to be sent just once a day.

    My idea is to use a counter from 1 to 24, every time the counter value is at 1 send the sensor data and the coordinates, when the counter value is from 2 to 24 send only the sensor data.
    Every time the counter adds up to 1, I want the device to go into deep sleep mode, but when it restarts it saves the counter value.
    I would greatly appreciate your support.

    if counter==1:
        print("Send the sensor data and  coordinates")
    elif counter>1 and counter<=24
        print("Send Only the sensor data")
    if counter==24:
        counter=1 # Here i reset the counter
    counter.hold(True)# I know this function don´t work in this case.
    # pin.hold(True/false) the hold function is used to holde the state of a pin.
    machine.deepsleep (60000)

  • Banned

    This post is deleted!

  • @agotsis That will work if things is not time-critical yes! But if your wakeup is depending on a interrupt from a sensor, and you want to be able to start sampling from the sensor(s) as soon as you get an interrupt, deepsleep is simply not feasible. You will not get data before it is finished re-booting after deepsleep, losing a lot of data in the meantime.

  • @Erick-Falcon @railmonitor And a third one if you still want to use deep-sleep: use NVRAM to store values that are preserved after boot. How? Based on pycom's functions pycom.nvs_set(key, value) and pycom.nvs_get(key)

  • Hi Erick

    There are basically two solutions to the problem:

    Not using deepsleep but lightsleep instead, which does not reboot your device. It does have a higher power-consumption, but it is still saving a lot.

    Storing the data / counter or whatever on a SD card for use after wake up from Deepsleep.

    Best Regards

Log in to reply

Pycom on Twitter