Skip to content

mitchsf/NTP2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NTP2

A modern, non-blocking, lightweight, NTP client library for Arduino and ESP32-based boards, with support for Kiss-o'-Death (KoD) reporting.

πŸ”§ Features

  • Fully non-blocking time updates
  • Handles NTP KoD (Kiss‑o'-Death) codes
  • Supports both domain and IP-based server configuration
  • Configurable poll intervals, response timeouts, and retry delays
  • Minimal resource usage
  • I won't provoke an NTP server to test KoD reporting, but Anthropic Claude Sonnet 4 checked and confirmed that it will work.

πŸ“¦ Installation

  1. Download the latest release.
  2. Unzip into your Arduino libraries/ folder.
  3. Restart the Arduino IDE.
  4. update() MUST be in loop().

Or install directly via Arduino Library Manager (when published).

πŸ§ͺ Overly Simplified Example

#include <WiFi.h>
#include <WiFiUdp.h>
#include <NTP2.h>

WiFiUDP udp;
NTP2 ntp(udp);

void setup() {
  Serial.begin(115200);
  WiFi.begin("SSID", "password");
  while (WiFi.status() != WL_CONNECTED) delay(1000);

  ntp.begin();  // Uses default pool.ntp.org server
}

void loop() {
  NTPStatus status = ntp.update();

  if (status == NTP_CONNECTED) {
    Serial.println(ntp.epoch());
  }

  delay(1000);
}

Check the examples/NTP2_Basic sketch for full usage.

πŸ”„ Status Codes

  • NTP_CONNECTED – Valid response received
  • NTP_IDLE – Waiting or processing
  • NTP_BAD_PACKET – Invalid or no response
  • NTP_KOD_* – Kiss-o'-Death response (rate-limiting, denial, etc.)

βš™οΈ Configuration Methods

ntp.updateInterval(ms);      // Set poll interval
ntp.responseDelay(ms);       // Time to wait before reading response
ntp.retryDelay(ms);          // Retry delay after failure or KoD
ntp.forceUpdate();           // Force an immediate query

πŸ§‘β€πŸ’» Author

Mitch Feig
πŸ“§ [email protected]

πŸͺͺ License

MIT License. See LICENSE file for details.

About

Non-blocking NTP client for Arduino with Kiss-o'-Death handling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages