Just to pitch in, this is how I’m doing it:
void totalRuntime()
{
if (digitalRead(blowerPin) == LOW) // If fan is running...
{
++currentCycleSec; // accumulate the running time, however...
currentCycleMin = (currentCycleSec / 60);
}
else if (digitalRead(blowerPin) == HIGH && currentCycleSec > 0) // if fan is off but recorded some runtime...
{
Blynk.virtualWrite(110, ++hvacTodaysStartCount); // Stores how many times the unit has started today... adds one start.
currentCycleSec = 0; // Reset the current cycle clock
currentCycleMin = 0;
}
}
totalRuntime is something that I have running every second. As you can see, this solution is intertwined with recording a current fan cycle runtime… something you may or may not be interested in! I reset all these values at midnight.