#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* serverUrl = "https://jsonplaceholder.typicode.com/todos/1"; // Replace with your server URL
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
// Specify the URL to fetch data from
http.begin(serverUrl);
// Send the GET request
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
String payload = http.getString();
Serial.println("HTTP Response code: " + String(httpResponseCode));
Serial.println("Response data: " + payload);
} else {
Serial.println("Error on HTTP request");
}
http.end();
}
delay(20000); // Wait for 20 seconds before making the next request
}