I have created a simple project on an ESP32 that keeps track of an hourly value based on the number of counts per hour.
Since it is a remote installation, it runs on AAA batteries, and I use Deep Sleep with an external trigger that will update the count tally if/when the wake-up pin associated is triggered. Counts etc. are preserved in RTC so that the wake from Deep Sleep Reset process will merely add to that already there - the dashboard is then updated with the new value based on the new count number. In short - I am actually counting the wake-up events to generate the data values as this is a simple way to preserve max power, and still get the info I need.
But it can happen that I might not have any counts in an hour - in that case the value should then reset to 0 at the end of the hour so that the next hour can start counting afresh.
I have tried using the ‘Invalidate in…’ option for the Datastream, but it seems that timer will trigger based on the time of the last update it received - so if I get a count at say 11h43 - and then nothing going forward, it will reset to default (0) at 12h43, instead I’d like it to reset at 12h00.
I also looked at the automations, thinking I could use a schedule to reset the counter at the top of each hour. But my understanding is that for this to be effective I’d need to keep the ESP online and would not be able to use Deep Sleep.
Sort of related I looked at using ULP to run as a second Deep Sleep wake up to keep track of the passing of an hour and then force a quick wake-up & reset - but this seems to be limited as I plan on moving the statistics collection to cover both per day, and per month, so the solution would not work for those (based on what I have read).
Any tips/advice as to how I could approach this problem, would be greatly appreciated!