Currently, I have an older ESP8266 plugged into a handy USB to ESP-01 adapter.
I uploaded a simple sketch (below) to retrieve Time using NTPClient:
#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:
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?