#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <Adafruit_ILI9341.h>
// Replace with your network credentials
const char* ssid = "Wokwi-GUEST";
const char* password = "";
// TFT setup
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST -1 // You can set TFT_RST to -1 if not used
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
tft.begin();
tft.setRotation(1);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(100);
tft.print(".");
}
tft.print("\nOK! IP=");
tft.println(WiFi.localIP());
}
void loop() {
HTTPClient http;
// Send HTTP GET request
http.begin("http://example.com"); // Replace with your URL
int httpCode = http.GET();
if (httpCode > 0) {
Serial.println("success");
String payload = http.getString(); // Get the response payload
Serial.println(payload);
// Clear TFT screen
tft.fillScreen(ILI9341_BLACK);
// Display payload on TFT
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(0, 0);
tft.println(payload);
}
http.end();
delay(60000); // Wait 1 minute before fetching again
}