How to Sync esp32 time with Ds1307RTC.

wildvortex
Posts: 1
Joined: Sat Oct 05, 2024 3:48 pm

How to Sync esp32 time with Ds1307RTC.

Postby wildvortex » Mon Oct 07, 2024 1:24 pm

I am writing code for a remote for a diesel heater in my camper. I will be shutting down the esp32 while not camping and it will therefore not retain its time. I have a DS1307RTC in the mix to keep time while there is no power to the esp. what Ican not find in any of my searches is how to sync the time from the 1307.

I see plenty of examples of syncing time from NPT but where I am going to be using it there will be no internet access. Has anyone done this before?

excuse me if this is simple code for some but since I just started coding in August I am a bit lost with it.

TIA

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: How to Sync esp32 time with Ds1307RTC.

Postby lbernstone » Mon Oct 07, 2024 3:45 pm

You haven't said what you are using for the ds1397 library, but basically call the function to get epoch UTC time from the rtc, then call settimeofday.
This example expects to get input from serial, but shows how to set the time on the esp32.

Who is online

Users browsing this forum: Google [Bot] and 60 guests