Simple ESP32 wroom test of wifi using NTP

This small ESP32 wroom Arduino program connects to wifi, gets the NTP time and blinks the onboard LED when the NTP time for seconds flips over, that is, “even seconds” turns off the LED and “odd seconds” turns on the LED:


// Simple ESP32 wroom Arduino test program to connect to wifi, get ntp time, blink led every 1 sec. using NTP time.
#include “NTPtimeESP32.h”

NTPtime NTPch(“”); // Choose server pool as required
char *ssid = “SSID”;                        // Set you WiFi SSID
char *password = “wifi-password”; // Set you WiFi password

strDateTime dateTime;

void setup()  {

Serial.println(“Connecting to Wi-Fi”);

WiFi.begin (ssid, password);
while (WiFi.status() != WL_CONNECTED)  {

void loop()  {

// first parameter: Time zone in floating point (for India); second parameter: 1 for European summer time; 2 for US daylight saving time (contributed by viewwer, not tested by me)
dateTime = NTPch.getNTPtime(1.0, 1); //CURRENTLY SET FOR US EST

// check dateTime.valid before using the returned time
if (dateTime.valid) {

byte actualsecond = dateTime.second;
if ((actualsecond & 0x01) == 1 ) digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (seconds bit 0 is HIGH)
else digitalWrite(LED_BUILTIN, LOW); // turn the LED off (seconds bit 0 is LOW)


The files to read the NTP time is here: . They need to be copied into the Arduino sketch folder. The program has been tested on the ESP32 dev kit v1 and the Adafruit ESP32 Feather boards.