Another ESP8266 NTP Client

Another ESP8266 NTP Client

Normally speaking I try to use work of others to include in my projects as much as possible. One of my ESP8266 projects is required to have time and date synchronized frequently and have been trying some of the existing NTP libraries out in the field. Although most of them provide sufficient functionalities, I could not find one that had implemented timezones - in other words UTC offsets - properly.

Most of them have implemented timezones support as either simply allowing for adding/subtracting the respective time difference (as an integer!), or relying on other libraries to create complex rule sets for timezones. For the ESP8266 this is primarily related to the fact that the built in SNTP API timezone implementation has a few limitations:

  • Only timezones values from -11h till 13h hours are supported
  • The timezone value is represented as an integer, allowing for only time differences with a whole number.

So we can't set a UTC offset that has a time difference including 30 minutes (e.g. UTC+03:30) or 45 minutes (e.g. UTC+05:45). In addition, the current list of timezones by UTC offset spans from -12h till 14 hours, so the ESP8266 can not set timezones for UTC−12:00 and UTC+14:00.

For most people aforementioned limitations probably are not a hindrance, however I always like to have all features available to me any time :). Hence, I created a ESP8266 library that supports timezones completely.

The library is completely open source and can be retrieved on GitHub here:NTP Client.

NTP Client Output (Using PlatformIO)

Blog Comments powered by Disqus.