#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const String url = "http://example.org";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("Connected!");
}
void loop() {
// Create an HTTP client
HTTPClient http;
// Make a GET request
if (http.begin(url)) {
int statusCode = http.GET();
// Print the status and body
if (statusCode > 0) {
Serial.println("Status: " + String(statusCode));
String payload = http.getString();
Serial.println("Body: " + payload);
} else {
Serial.println("Error: " + http.errorToString(statusCode));
}
// Close the connection
http.end();
} else {
Serial.println("Invalid URL");
}
// Wait for some time before repeating
delay(10000);
}