All Projects → gmag11 → ESPNtpClient

gmag11 / ESPNtpClient

Licence: GPL-3.0 license
High accuracy NTP library for ESP32 and ESP8266

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to ESPNtpClient

ESPHome-OpenTherm
Example of how to control an opentherm boiler with esphome
Stars: ✭ 54 (-33.33%)
Mutual labels:  esp8266, esp32
iot-product-dev-book
Source code for example apps from IoT Development for ESP32 and ESP8266 with JavaScript.
Stars: ✭ 38 (-53.09%)
Mutual labels:  esp8266, esp32
Arduinowebsockets
A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)
Stars: ✭ 213 (+162.96%)
Mutual labels:  esp8266, esp32
esp8266-esp32-sdk
Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
Stars: ✭ 147 (+81.48%)
Mutual labels:  esp8266, esp32
home-assistant-opentherm-thermostat
Home Assistant OpenTherm Thermostat
Stars: ✭ 26 (-67.9%)
Mutual labels:  esp8266, esp32
Lwesp
Lightweight Espressif AT parser library for ESP8266 and ESP32 devices.
Stars: ✭ 212 (+161.73%)
Mutual labels:  esp8266, esp32
Esp32marauder
A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32
Stars: ✭ 233 (+187.65%)
Mutual labels:  esp8266, esp32
Jled
Non-blocking LED controlling library for Arduino and friends.
Stars: ✭ 197 (+143.21%)
Mutual labels:  esp8266, esp32
AsyncTelegram
Async Arduino Telegram BOT Library for ESP8266 and ESP32
Stars: ✭ 41 (-49.38%)
Mutual labels:  esp8266, esp32
micropython-TEA5767
MicroPython driver for TEA5767 FM radio module on ESP8266/ESP32/Pico
Stars: ✭ 24 (-70.37%)
Mutual labels:  esp8266, esp32
Dsckeybusinterface
An Arduino/esp8266/esp32 library to directly interface with DSC security systems.
Stars: ✭ 202 (+149.38%)
Mutual labels:  esp8266, esp32
MicroPython Examples
MicroPython Examples For 01Studio Development Board
Stars: ✭ 86 (+6.17%)
Mutual labels:  esp8266, esp32
Awot
Arduino web server library.
Stars: ✭ 200 (+146.91%)
Mutual labels:  esp8266, esp32
Awesome Esp
📶 A curated list of awesome ESP8266/32 projects and code
Stars: ✭ 212 (+161.73%)
Mutual labels:  esp8266, esp32
Blog
A set of various projects based on ESP8266, ESP32, ATtiny13, ATtiny85, ATtiny2313, ATmega8, ATmega328, ATmega32, STM32 and more.
Stars: ✭ 198 (+144.44%)
Mutual labels:  esp8266, esp32
Ems Esp
ESP8266 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps
Stars: ✭ 226 (+179.01%)
Mutual labels:  esp8266, esp32
Esp8266 React
A framework for ESP8266 & ESP32 microcontrollers with a React UI
Stars: ✭ 193 (+138.27%)
Mutual labels:  esp8266, esp32
Esp Webota
Simple web based Over-the-Air (OTA) updates for ESP based projects
Stars: ✭ 189 (+133.33%)
Mutual labels:  esp8266, esp32
wireless-esp8266-dap
ESP8266 Wireless Debugger. Based on CMSIS-DAP v2.0.0. Optional 40MHz SPI acceleration, etc. ESP8266 无线调试器
Stars: ✭ 154 (+90.12%)
Mutual labels:  esp8266, esp32
ebusd-esp
Firmware for ESP8266 allowing eBUS communication for ebusd (https://github.com/john30/ebusd)
Stars: ✭ 68 (-16.05%)
Mutual labels:  esp8266, esp32

PlatformIO

ESPNtpClient

There are many NTP client libraries around. All them have different implementations for time tracking. Indeed I developed one of them. It is called NTPClientLib and was intended to be as easy to use as possible while offering a wide range of features, including multiplatform support (ESP8266, ESP32, Arduino MKR1000, Arduino UNO with Ethernet shield). Since that I moved all my projects to ESP8266 and ESP32.

Some time ago ESP32 and ESP8266 SDKs include NTP and time tracking internal functions, including Posix compliant Time.h implementation, what gives less sense to use external libraries.

But all those libraries including Espressif SDK synchronize clock with plus minus 1 second accuracy, what is enough for most projects. But some others that require tight synchronization require additional sources of time reference, although NTP protocol is suitable to have 1 millisecond accuracy on these little boards.

This limitation comes from the way they calculate time offset. All them (at least the ones that I know) only use one of three timestamps that can be extracted from NTP packet, so they do not have round trip delay into account.

This library implementation uses time offset calculation as stated in RFC5905 NTP standard. It is not a complete implementation of NTP protocol in other aspects, although this allows getting precision very close to 1 millisecond.

Many of the methods used in my old NTPClientLib library are the same in this one. I've added some methods to get timeval times, that include microseconds information.

ESPNtpClient do not have any external dependency.


Important: This library task is only related to time synchronization and, as NTP protocol does, works using UTC time internally. All time management including local time conversion, time zones, daylight savings, etc. is done by Espressif sdk time subsystem that is based on GNU time C library. https://web.archive.org/web/20210226233334/https://kirste.userpage.fu-berlin.de/chemnet/use/info/libc/libc_17.html


Note: ESP32 and ESP8266 have their own SNTP clients into their respectives SDKs. So, unless you need additional accuracy that this library provides, it is always recommended to use ESP32 or ESP8266 SDKs.


(Attribution) Clock logo taken from https://www.visualpharm.com/free-icons/clock-595b40b75ba036ed117d92ff

Description

This is a NTP library to be able to get time from NTP server with my connected microcontrollers.

Using the library is fairly easy. A NTP singleton object is created inside library. You may use default values by using NTP.begin() without any parameter. After that, synchronization is done regularly without user intervention. Some parameters can be adjusted: server, sync frequency, time zone.

You don't need anything more. Time update is managed inside library so, after NTP.begin() no more calls to library are needed.

Update frequency is higher (every 15 seconds as default) until 1st successful sync is achieved. Since then, your own (or default 1800 seconds = half hour) adjusted period applies. There is a way to adjust both short and long sync period if needed.

Mostly, this is compatible with older NTPClientLib library.

This library includes an uptime log too. It counts number of seconds since sketch is started.

Every time that local time is adjusted a ntpEvent is thrown. You can attach a function to it using NTP.onNTPSyncEvent(). Called function format must be like void eventHandler(NTPSyncEvent_t event).

Library does WiFi connection tracking by itself so you can call begin after or before WiFi is connected and it takes care of WiFi reconnections. Meanwhile, if 'NTP.begin()' is called when WiFi is already connected, it takes far less to get syncronization. It takes up to 30 seconds if library is called before WiFi connection is completed, but it will only take less than 5 seconds if Wifi was connected prior to NTP.begin() call

There are two examples, one simple and minimum one to show the very basic implementation. Second one shows advanced use with event and WiFi state management.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].