#include <WiFi.h>
#include <HTTPClient.h>
//service level agreement
void setup() {
Serial.begin(9600);
pinMode(32, OUTPUT);
Serial.print("Connecting to WiFi");
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println("WiFi Connected");
}
void loop() {
HTTPClient http;
String URL = "http://2451-21-733-067.000webhostapp.com/data.php" ;
http.begin(URL);
int http_code = http.GET();
if (http_code>=200 && http_code<300) {
Serial.print("HTTP code: ");
Serial.println(http_code);
String payload = http.getString();
Serial.println(payload);
if(payload.toInt()) digitalWrite(32, HIGH);
else digitalWrite(32, LOW);
}
else {
Serial.print("Error code: ");
Serial.println(http_code);
}
http.end();
delay(15000);
}