Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover old state after powerdown/ reset #10

Open
michapr opened this issue Jan 23, 2025 · 4 comments
Open

Recover old state after powerdown/ reset #10

michapr opened this issue Jan 23, 2025 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@michapr
Copy link

michapr commented Jan 23, 2025

Hi,

If using the device with a ESP32 and deep sleep for saving energy the gas index algorithm will not work because all collected values lost - as far as I understand.
Same will happen if power is down (as sample replace battery or empty LiPo).

Can you provide any example code for save / restore the states to EEPROM?
For ESP32 deep sleep it could be modified later for RTC RAM - and maybe once every hour save to EEPROM or maybe use external FRAM.

THANKS!

@qfisch qfisch added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 27, 2025
@qfisch
Copy link

qfisch commented Jan 27, 2025

Hello @michapr

Such example would indeed be a great addition. 👍
Unfortunately, internally we currently have no plan to work on it.

However we encourage contributions, so someone might do.

Cheers
Q

@michapr
Copy link
Author

michapr commented Jan 27, 2025

This is a pity, because without this feature, the sensor cannot be used in power-saving mode.
And therefore not even in any battery-powered devices.

I had assumed that you know best what needs to be done to implement it.

@ilarth
Copy link

ilarth commented Feb 28, 2025

Looks like the algorithm stores everything in a single struct. So it should be trivial to persist this blob to storage.

The bigger question is whether the algorithm makes sense to have time gaps. The readme say it's been tested for 1-10 second sampling.

What if there is 1 second sampling for a 60 second time window. Then the device stores the blob and sleeps for a relatively long period of time. Let's say any where from 10 minutes to 1 hour. Then it wakes up from deep sleep. Restores the blob to memory and samples for 60 seconds again. Does the algorithm still make sense when used this way?

@psachs
Copy link
Member

psachs commented Mar 14, 2025

The SGP4x sensors perform best under continuous operation with a 1Hz measurement frequency. Decreasing the measurement frequency reduces the response time.

E.g. measuring for a short time and then sleeping will most probably not work very well. Restoring the state helps you to get faster to the same state you had before. It can be used to recover faster after an intentional or unintentional reboot of the device.

The best you can do for a low power application is to use a sampling interval of 10s and go to deep sleep in between the measurements. In this case you don't need to recover the state.
Depending on your hardware you can also run the sensor measurements on a separate core. You don't need to wake up your whole application every 10s, but only the part that measures the sensor.

The SGP4x sensor uses on average 34uA in idle mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants