NodeMCU (Arduino) - RTC init from NTP

This is an example sketch (quick and dirty) to show how I initialized a DS1307 RTC Module from a NTP server's response.
The PIO configuration is for a NodeMCU v1.0 board, which can be modified as required.

Changing Timezone

Change the following constant to your timezone offset from GMT in seconds:

const uint32_t timeZoneOffsetSeconds = 19800;

References

  1. TimeNTP_ESP8266WiFi.ino example from the "Time" library
  2. Arduino Forum Post on improving NTP received time's accuracy
  3. PlatformIO - Fix SPI.h "no such file" error
  4. RTClib.h - toString() Documentation

Built With

Share this project:

Updates