BitMaker-hub / NerdMiner_v2

Improved version of first ESP32 NerdMiner
Other
1.5k stars 268 forks source link

Save stats to NVS. #157

Closed romanmashta closed 12 months ago

romanmashta commented 12 months ago

This MR store stats to NVS storage. It uses increasing time interval from 5 minutes to 12 hours to store stats. So in the long run it uses 12 hours only intervals. This interval along with the wear levelling feature of NVS api should have minimal impact of nvram lifespan and give tens of years of stats saving. Please see for details:

https://espressif-docs.readthedocs-hosted.com/projects/esp-faq/en/latest/software-framework/storage/nvs.html

This feature can be turned on or off through WiFi settings web interface. Default is — Off

Screenshot 2023-09-09 at 13 43 49
roblatour commented 12 months ago

To be honest, I would prefer if the default was set to not write to NVS.

Especially as it does not appear the setting can be changed when flashing using this tool: https://bitmaker-hub.github.io/diyflasher/

romanmashta commented 12 months ago

NVS does not save to same address by design. It uses new location on every update and mark old as free. It would take years to make few cycles over 20kb NVS partition. Your concerns are valid, but they are already addressed by NVS API under the hood. We can even make it toggleable in WiFi config if it is required.

romanmashta commented 12 months ago

@roblatour @BitMaker-hub I've added this option to WiFi settings interface with Off by default. So every user can decide if they want to keep stats through device reboot.

roblatour commented 12 months ago

Great idea, that's perfect.