Comments on: ESP32: Guide for DS1307 Real Time Clock (RTC) Module (Arduino IDE) https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Mon, 24 Mar 2025 11:43:41 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Gary Cawthon https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1010922 Tue, 25 Feb 2025 16:08:40 +0000 https://randomnerdtutorials.com/?p=163891#comment-1010922 The project worked great, and makes a nice time display. After a few days, I noticed the time starting to drift. Hmmm…
Restarting with the serial monitor active, I found that after an hour, the debug output showed the ESP32 constantly trying to sync with the NTP server. I modified the code function checkTimeAndSync as follows:

void checkTimeAndSync() {
// Sync with NTP server every 1 hour (3600000 ms)
if (millis() – lastSyncMillis >= 3600000) {
Serial.println(“Synchronizing time with NTP…”);
syncTime();
lastSyncMillis = millis(); //do this so it doesn’t keep trying to sync every loop after the first hour.
}
}

resetting lastSyncMillis to millis() so the code doesn’t keep bugging ther NTP server.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1003624 Wed, 29 Jan 2025 14:03:57 +0000 https://randomnerdtutorials.com/?p=163891#comment-1003624 In reply to Gary Cawthon.

Great.
Thanks for sharing.
Regards,
Sara

]]>
By: Gary Cawthon https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1003612 Wed, 29 Jan 2025 12:45:26 +0000 https://randomnerdtutorials.com/?p=163891#comment-1003612 In reply to Sara Santos.

Here is a link to the code:
http://www.github.com/Testroadtech/Arduino-Projects

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1003595 Wed, 29 Jan 2025 11:19:32 +0000 https://randomnerdtutorials.com/?p=163891#comment-1003595 In reply to Gary Cawthon.

Hi.
That’s a very interesting solution.
If you want, please share the code. But use a link to Github.
Don’t paste it directly here as the formatting will be messed up.

Tank you.
Regards,
Sara

]]>
By: Gary Cawthon https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1003459 Tue, 28 Jan 2025 19:55:07 +0000 https://randomnerdtutorials.com/?p=163891#comment-1003459 In reply to Sara Santos.

I could not get the desired outcome with ESP32 sleep/wakeup, as all the tutorials I could find had all the code running in the setup function. I was able to get it to work by setting up display on and off millis timers, turning off the display (display.ssd1306_command(SSD1306_DISPLAYOFF); after a set time, and an “if” statement “if (touchRead(T0) < threshold)” triggering a similar command to turn the display back on.
I have had some OLEDs get degraded displays due to burn-in after being on too long, so it was important to me to have a way to blank it off when not in use.
I can post the code if you are interested.

]]>
By: Peter Kraeft https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1003024 Sun, 26 Jan 2025 23:46:58 +0000 https://randomnerdtutorials.com/?p=163891#comment-1003024 In reply to Dmytro.

Thanks for the clarification.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1002989 Sun, 26 Jan 2025 19:27:34 +0000 https://randomnerdtutorials.com/?p=163891#comment-1002989 In reply to Timothy Rupp.

Hi.
I’m sorry. I forgot to mention, that in the case of the DS3231, the isrunning() function should be replaced with lostPower().

Regards,
Sara

]]>
By: Peter Kraeft https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1002845 Sun, 26 Jan 2025 05:38:19 +0000 https://randomnerdtutorials.com/?p=163891#comment-1002845 In reply to Hans Nijntjes.

Hi Hans, I like the article too, but I have the same question. What is the benefit of the RTC?

]]>
By: Timothy Rupp https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1002813 Sun, 26 Jan 2025 00:36:41 +0000 https://randomnerdtutorials.com/?p=163891#comment-1002813 Thanks for this great little learning project. I had an Elegoo DS_1307 lying about so I attempted to press it into action. Seems like it’s dead…lights are on but nobody is home it seems. The I2C Scanner came up empty when the device was scanned. No problem, I’ve also got a DS-3231 in the parts box and that did check out on the scanner…woohoo! So according to your instructions I set the device to: RTC_DS3231 rtc; This resulted in an error that the device did not have a member named “isrunning” !! Oh well, I didn’t see any reason not to, so I set it back to RTC_DS1307 and long story short…it works just fine.

]]>
By: Dmytro https://randomnerdtutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/#comment-1002749 Sat, 25 Jan 2025 16:24:53 +0000 https://randomnerdtutorials.com/?p=163891#comment-1002749 Hi!
I wanted to ask, what’s the purpose to use ds18b20 with DS1307? We could do something like temperature compensation on DS3231 with that?

]]>