Help with Setting Up DS3231 RTC with ESPHome

Hey everyone,

I’m trying to integrate a DS3231 Real-Time Clock (RTC) module with ESPHome but I’m a bit stuck. I know that the DS3231 is compatible with the DS1307 platform in ESPHome, but I want to make sure I’m setting it up correctly.

Here’s what I’ve done so far:

  1. Configured the I²C bus on my ESP device:
i2c:
  sda: GPIO21
  scl: GPIO22

(Pins may vary depending on the board.)
2. Added the DS1307 time component (since DS3231 isn’t directly listed in ESPHome):

time:
  - platform: ds1307
    id: ds3231_time
    update_interval: 15min
  1. Set up SNTP synchronization to update the RTC from an external time source:
time:
  - platform: sntp
    id: sntp_time
    on_time_sync:
      then:
        - ds1307.write_time: ds3231_time
  1. Reading time from DS3231 on boot to make sure the ESP device gets the correct time on startup:
esphome:
  on_boot:
    then:
      - ds1307.read_time: ds3231_time

Now, my questions:

  • Is this the correct approach for using DS3231 with ESPHome?
  • Do I need to use any additional settings or modifications?
  • How do I ensure that the RTC keeps time properly if the ESP device loses power?

I’d appreciate any guidance or suggestions from the community! Thanks in advance.

Not sure if you are the same guy that posted on the HA forum (milo vs miloit), if not this might help:

Thank you no it’s not me…but I will try this