Setting DS3231 time with esp32

If you are asking a question, please follow this template:

  1. My goal is: set ds3231 clock time to local time using esp32
  2. My actions are: I am using ds3231 library, i have added sntp to my mos.yml
  3. The result I see is: clock is always getting started from 0:0:0 and 1-jan 1970
  4. My expectation & question is: i want to get local time and use ds3231 1khz clock to get to get 1milliseond timestamp and use it to getdifferent sensor values at specific timestamp

If you want to use sntp library to set the local time, you also need to set sys.tz_spec in mos.yml.

To synchronize the DS3231, you need to process the event MGOS_EVENT_TIME_CHANGED and set DS3231’s time in the event callback.

Regarding the square wave generation, have a look here