Skip to content
Connect to a NTP server
Branch: master
Clone or download
vincentVDB and sandeepmistry Update keywords.txt
forget ?
setTimeOffset	KEYWORD2
setUpdateInterval	KEYWORD2
setPoolServerName	KEYWORD2
Latest commit 020aaf8 Jul 10, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Added functions for changing the timeOffset and updateInterval later May 14, 2016
.travis.yml Initial add travis arduino build tests Apr 18, 2016
CHANGELOG
NTPClient.cpp added method for changing time server Jun 27, 2018
NTPClient.h added method for changing time server Jun 27, 2018
README.md Update README.md Jun 27, 2018
keywords.txt
library.json
library.properties

README.md

NTPClient

Build Status

Connect to a NTP server, here is how:

#include <NTPClient.h>
// change next line to use with another board/shield
#include <ESP8266WiFi.h>
//#include <WiFi.h> // for WiFi shield
//#include <WiFi101.h> // for WiFi 101 shield or MKR1000
#include <WiFiUdp.h>

const char *ssid     = "<SSID>";
const char *password = "<PASSWORD>";

WiFiUDP ntpUDP;

// By default 'pool.ntp.org' is used with 60 seconds update interval and
// no offset
NTPClient timeClient(ntpUDP);

// You can specify the time server pool and the offset, (in seconds)
// additionaly you can specify the update interval (in milliseconds).
// NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);

void setup(){
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  timeClient.begin();
}

void loop() {
  timeClient.update();

  Serial.println(timeClient.getFormattedTime());

  delay(1000);
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.