RTC - Use NTP to rectify DS1307/DS3231 RTC


  • Ameba x 1
  • DS1307/DS3231 RTC x 1


In this example, we use NTP to rectify the time of DS1307/DS3231 RTC module.
The following libraries are required:
RTL8195 Wiring Diagram as follows:


RTL8710 Wiring Diagram as follows:

Open the sample code from “File” -> “Examples” -> “AmebaDS1307RTC” -> “SetTimeNtp”
In the sample code, please provide the ssid/password for WiFi connection. Then compile and upload the sample to Ameba and press reset button. You should see similar log in the Serial Monitor, which means the recification has completed:

Code Reference

After the WiFi connection is established, we use NTP to rectify the time of Time library:

Next, use the time value from Time library to setup the tmElements_t variable, and give the variable to RTC.write()


Finally, we read RTC time value in loop() every second.

Please confirm that QQ communication software is installed