Can anyone help me with my project. I am building a countdown timer using push button and RTC module.
When I push the button it will trigger the relay on, then stop after 6hours
What is the issue that you are having?
Can I store the exact time from RTC when I push the button. For ex. I push the button at 5:00PM the timer then start , and after 6hours the timer will stop. (11:00PM)
I can store a time from an RTC and compare that time to a furutre time and do the thing. I do not know if you posses the skills to do the same. My answer to the question of "Can I store the exact time..." would be depends upon your programming skills.
You may want to do some research into using millis() for timing.
Can you show the code for storing the time? no matter what library is used, Maybe I will have an Idea to make the whole function. Thanks in advance. I am a begginer in arduino programming, It will be great help if you can show me some codes.
I only have code to store time using the ESP32Time library.
Did you try using the words "arduino store time" in a internet search?
Read up on the millis() function and the blink without delay (bwod) sketch and ponder.
Here's the flow of the function I want to make:
If button is pushed read the time from RTC , then the timer will start. Then after 6hours the timer will stop. No matter what time I pushed the button it will stop after 6hours from the start time.
Agreed, you don't need an RTC to time 6 hours. Just use millis() to determine when 6 * 3600 * 1000 = 21,600,000 milliseconds have expired. Be sure to use an 'unsigned long' variable type for all such timing.
That being said, the proper way to time intervals based on a reading from an RTC is to do all calculations using Epoch Time. That way you don't have to worry about roll over of seconds into minutes, minutes into hours, hours into days, etc.
It is much easier to use the millis() function . But I am also trying to display the current time and date with an LCD. So I will need to use RTC for that
Fair enough. But, you should still use Epoch time when testing for your 6 hour interval to expire.
can you show me some examples of the epoch time?. I never used one before. Is there an epoch time function in the RTC module?
Start by specifying the exact Arduino Board, RTC module, and libraries you intend to use. Post the code you've written so far.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.