# NTPClient library is working without any code to establish a network connection!

**URL:** <https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191>\
**Category:** 3rd Party Boards\
**Created:** [June 27, 2025, 12:08pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191 "2025-06-27T12:08:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoThatOtherGuy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nothatotherguy/32/1238064_2.png) [@NoThatOtherGuy](https://forum.arduino.cc/u/NoThatOtherGuy)\
**Post date:** [June 27, 2025, 12:08pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/1 "2025-06-27T12:08:09Z")

</div>

Currently, I have an older ESP8266 plugged into a handy [USB to ESP-01](https://www.amazon.com/ESP-01S-Programmer-Adapter-Wireless-4-5-5-5V/dp/B07V556Q82/ref=cm_cr_arp_d_product_top?ie=UTF8) adapter.

 ![8266](https://europe1.discourse-cdn.com/arduino/original/4X/9/3/d/93def1586f489e959d431334d28161743c6fd143.jpeg)

I uploaded a simple sketch (below) to retrieve Time using NTPClient:

```arduino
#include <NTPClient.h>
#include <WiFiUdp.h>

WiFiUDP ntpUDP;
NTPClient ntpClient(ntpUDP, "pool.ntp.org", -18000, 60000);

void setup() {

  Serial.begin(115200);

  Serial.println();
  Serial.println();
  Serial.println();

  for (uint8_t t = 5; t > 0; t--) {
    Serial.printf("[SETUP] WAIT %d...\n", t);
    Serial.flush();
    delay(1000);
  }
 
  ntpClient.begin();
}

void loop() {

  ntpClient.update();
  Serial.print("NTP time: ");
  Serial.print(ntpClient.getFormattedTime());
  Serial.print(" ");
  Serial.print(ntpClient.getEpochTime());
  Serial.println();

  Serial.println("Wait 5s before next round...");
  delay(5000);
}

```

Notice that in no way do I establish _any_ kind of IP connection in the code, yet when I upload the sketch, unplug the adapter and plug it back in to run the sketch, I get working results in the Serial monitor:

 ![8266-2](https://europe1.discourse-cdn.com/arduino/original/4X/8/a/1/8a1ddbb373b49c36fa6b288278058973a843650f.png)

I would expect my code to fail at this point, but I can only surmise that the USB to ESP-01 adapter provides a working connection to the 8266 that is plugged into it. If that case, how can I determine (from within the sketch) what the IP address might be?

---

<div class="post-metadata">

**Author:** ![ahsrabrifat](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ahsrabrifat/32/1126412_2.png) [@ahsrabrifat](https://forum.arduino.cc/u/ahsrabrifat)\
**Post date:** [June 27, 2025, 12:34pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/2 "2025-06-27T12:34:21Z")

</div>

You can You can query the IP address using `WiFi.localIP()` from within your sketch. But to do this, you need to `#include <ESP8266WiFi.h>`. using `WiFi.localIP()` from within your sketch. But to do this, you need to `#include <ESP8266WiFi.h>`.

---

<div class="post-metadata">

**Author:** ![NoThatOtherGuy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nothatotherguy/32/1238064_2.png) [@NoThatOtherGuy](https://forum.arduino.cc/u/NoThatOtherGuy)\
**Post date:** [June 27, 2025, 1:24pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/3 "2025-06-27T13:24:35Z")

</div>

Thanks. I tried that, but I get back "(IP unset)". I also tried it with **Ethernet.h** , but get the same result.

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [June 27, 2025, 1:40pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/4 "2025-06-27T13:40:46Z")

</div>

you don't need an external library for NTP on an ESP8266.  
The ESP Plattform package comes with everything you need for NTP on an ESP8266.

see:

> **[NTP for the ESP8266 including day light saving time (DST) without 3rd party...](https://werner.rothschopf.net/202011_arduino_esp8266_ntp_en.htm)**

---

<div class="post-metadata">

**Author:** ![NoThatOtherGuy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nothatotherguy/32/1238064_2.png) [@NoThatOtherGuy](https://forum.arduino.cc/u/NoThatOtherGuy)\
**Post date:** [June 27, 2025, 1:47pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/5 "2025-06-27T13:47:31Z")

</div>

Thank you for that information, it is helpful.

But, I'm trying to figure out how NTP is working on my 8266 when I have not established any kind of network connection within the sketch itself. Somehow, the board has enough access to the Internet that NTP is reporting proper time.

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [June 27, 2025, 1:50pm UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/6 "2025-06-27T13:50:36Z")

</div>

> [@NoThatOtherGuy](#):
>
> I have not established

This is done by the ESP in the background - may be due to a previous sketch you had on your ESP before this outdated NTP sketch.

You can try to delete the stored wifi data:

![grafik](https://europe1.discourse-cdn.com/arduino/original/4X/d/d/b/ddbda555becc4229863b3e1b6304a901520c126d.png)

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [June 28, 2025, 7:11am UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/7 "2025-06-28T07:11:26Z")

</div>

It remembers an old connection.

If you Call `WiFi.disconnect(true);` in the setup() that will clear saved credentials.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 25, 2025, 7:11am UTC](https://forum.arduino.cc/t/ntpclient-library-is-working-without-any-code-to-establish-a-network-connection/1392191/8 "2025-12-25T07:11:48Z")

</div>

Closed on December 25, 2025, 7:11am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
