#include <ESP8266HTTPClient.h>
void loop() {
if (WiFi.status() == WL_CONNECTED) { // Check Wi-Fi connection status
HTTPClient http;
http.begin("https://api.ipify.org"); // Specify the URL
int httpCode = http.GET(); // Send the request
if (httpCode > 0) { // Check for the returning code
String payload = http.getString(); // Get the request response payload
Serial.println(payload); // Print the response payload
} else {
Serial.println("Error on HTTP request");
}
http.end(); // Close connection
} else {
Serial.println("WiFi Disconnected");
}
delay(10000); // Send a request every 10 seconds
} |