DS3231 Programmer ESP32
Posted: Sat Jan 22, 2022 8:35 pm
Inspired by Martin's excellent Arduino RTC programmer (see https://flowcode.co.uk/forums/viewtopic.php?f=9&t=1026) and feeling that a PC and an Arduino was overkill for setting a RTC chip...
I came up with the ESP Time Machine(tm)
The idea is that the DS3231 board can be popped into a breadboard - power is applied and the ESP32 gets the time from an SNTP server - and programs the RTC
I couldn't get the ESP32 clock component to work see my comment in bugs (though now I see how to do it using Stefan's example in the forum) - however I've kept my own code as it lets me flash an LED whilst waiting for the SNTP sync and also means the component isn't required... I also used my own DS3231 component (modified to use transactions)
I haven't handled DST / BST- though the code does show how to retrieve it if needed...
Th prototype - I have two LEDs one for 'connection' and one for SNTP sync. I'd be tempted to add a 3rd (error) red LED to light if it can't connect to wi-fi. It outputs the time to UART after programming - though this is probably unnecessary as it id intended to program RTCs for other projects. The ESP32 board doesn't sit well on the breadboard - but I'd envision it in a 'custom' case with a (labelled) socket for the RTC board.
You'll need to set SSID and Password.... I was also tempted to do without resistors for the LEDs and use the ESP32 pullups instead (keep the project cost down !)
One oddity - adding the DS3231 component doubles the i2c address - need to set to 104 (which had me scratching my head for a while)
Martin
I came up with the ESP Time Machine(tm)
The idea is that the DS3231 board can be popped into a breadboard - power is applied and the ESP32 gets the time from an SNTP server - and programs the RTC
I couldn't get the ESP32 clock component to work see my comment in bugs (though now I see how to do it using Stefan's example in the forum) - however I've kept my own code as it lets me flash an LED whilst waiting for the SNTP sync and also means the component isn't required... I also used my own DS3231 component (modified to use transactions)
I haven't handled DST / BST- though the code does show how to retrieve it if needed...
Th prototype - I have two LEDs one for 'connection' and one for SNTP sync. I'd be tempted to add a 3rd (error) red LED to light if it can't connect to wi-fi. It outputs the time to UART after programming - though this is probably unnecessary as it id intended to program RTCs for other projects. The ESP32 board doesn't sit well on the breadboard - but I'd envision it in a 'custom' case with a (labelled) socket for the RTC board.
You'll need to set SSID and Password.... I was also tempted to do without resistors for the LEDs and use the ESP32 pullups instead (keep the project cost down !)
One oddity - adding the DS3231 component doubles the i2c address - need to set to 104 (which had me scratching my head for a while)
Martin