[solved] Smart way to reset a variable every 24 hours?


now I have tried to get the rtc clock sync with the phone clock, but it wont sync. Keeps in year 1-jan-1970.

tried to give it 20 min to sync.
RTC widget set to copenhagen.

Here is the code:

#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

WidgetRTC rtc;

SimpleTimer timer;

void setup()

void loop()

void showCurrentTime()
  String CurrentDate = String(day()) + '-' + monthShortStr(month()) + '-' + year();
  String CurrentTime = String(hour()) + ':' + minute() + ':' + second();
  String formattedDate = CurrentDate + String(" | ") + CurrentTime;

Wow! And what happens if you have to trigger something and your server is down, your wifi is down or your isp is down?
I’m so old scool, but it works even if your house is down! :joy:

it just forgets to reset a counter for one day, no big deal…

But my code above, I cant find any error when compared to the example sketch but it doesnt work.

Ok, not in your case, but my blink app is used “only” to configure, not to control an irrigation system, a loss of water can bring my bonsais to the trash bin…

1 Like

Always have a backup plan, I’d say. I know some plants are delicate than others (orchids, bonsai and so on), so I’d always check them manually.

But on the other hand, the chances that your internet goes down for more than 24h? How big are those? There is always risk involved because things are created by men and we are not infallible :slight_smile:

Found out why RTC widget would not sync time…

update blynk libraries from v0.4.3 to v0.4.4

I’ll borrow this thread for a question since the topic is on RTC.

Does the RTC widget require the project to be running in order to function?
If yes
Does it require the phone app to be running in foreground or does it also work with the phone app in the background? :slight_smile:


Well, I don’t know nothing about orchids, but the bonsai trees in summer it needs at least 3-4 or more watering times… so yes, a downtime of just a minute can bring a tree to the trash bin or lose some years of work due a branch lose…

I know nothing about plants but I know there are 1440 minutes each day.

So with 4 watering times a day that would be every 360 minutes (every 6 hours).

How long does each watering last? Very surprised that 1 minute late with the watering will kill the plant.
Certainly needs to be automated if that is the case.

I was just thinking the other way. If they are so precious I’d want to do it by hand :slight_smile:

1 Like

@Lichtsignaal in my experience a well programmed machine is much more reliable than most humans when it comes to these types of tasks.

I mean that if internet fails just in the moment the clock send the trigger time, the plants can be not watered…
By the way, I think there are less probabilities of fail with local dedicated RTC than with Blynk RTC, even that I have my home thermostat running since more than 1 month and it didn’t fail once…

You could use the Time Input widget and check if the trigger times (on or off) have passed during the brief period the device was offline.

Emphasis on well :wink: But I tend to agree. What I actually meant to say was that my idea of grwoing bonsai would be a manual thing, just for the rest and relaxation it comes with. To escape this horribly fast and tech savvy world for a moment (did I just actaully say that? :wink: )

These plant things you refer too… isn’t that what food eats?

So, is this resurrected thread still needing answers to resetting variable or why RTC lives back in the 1970’s (I think the answer to that is use latest library 0.4.4), or do I need to learn botany to partake? :wink: