#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* pass = "";
unsigned const long interval = 3000;
unsigned long start = 0;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
while(WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.println(".");
}
Serial.println("WiFi Connected!");
Serial.println(WiFi.localIP());
}
void loop() {
if (millis()-start > interval) {
HTTPClient http;
http.begin("https://jsonplaceholder.typicode.com/todos/1");
int httpResponseCode = http.GET();
Serial.print("\nHTTP Response: ");
Serial.println(httpResponseCode);
if(httpResponseCode > 0) {
String payload = http.getString();
Serial.print(payload);
} else {
Serial.print("\nHTTP Response: ");
Serial.print(httpResponseCode);
Serial.println("(Error!)");
}
}
}