TLDR: Does anyone have code to reset a value at the same time every day?
I have an Arduino-powered weather station and am trying to write code that will keep track of the daily high and daily low. My thought is for the Arduino to compare the current temp to the recorded low temp and if it's below set the low temp to the current temp. The same thing for high but in reverse.
But in order for it to be daily, I need the Arduino to reset the low temp / high temp at a given time each day. I'm having trouble thinking through the logic of how to accomplish that. Before I burn too many brain cells, I thought I'd see if anyone has already figured this out.
I know I could write a code that says "if the time is greater than minute X and less than minute Y, reset the value" but what if the unit happened to be powered off during that one X-Y minute? Could it figure out when it came back on that minute X-Y had passed and reset? I don't know how likely that scenario is, but still I'd like to account for it if not too complicated.
For reference, in addition to millis I also have the Time library (GitHub - PaulStoffregen/Time: Time library for Arduino) so I can call the current year, day, hour, minute, etc. as well as a unix time.