#include "Arduino.h"
#include "ArduinoJson.h"
#include <WiFi.h>
#include <HTTPClient.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 0
#define TFT_CS 2
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const char* ssid = "Wokwi-GUEST";
const char* password = "";
String payload;
String room = "E-201";
const String url = "https://raumzeit.hka-iwi.de/api/v1/timetables/room/" + room + "?reload=t";
// const String url = "http://example.org/";
void parseData(String json) {
// Example JSON data
// const char* jsonStr = "[{\"name\":\"A\",\"longName\":\"Architektur\",\"facultyName\":\"AB\",\"master\":false},{\"name\":\"ARTB\",\"longName\":\"Architektur (B)\",\"facultyName\":\"AB\",\"master\":false}]";
// Parse JSON
// Stream& input;
Serial.println(json);
// Serial.println(master);
Serial.println();
}
void setup() {
tft.begin();
tft.setCursor(20, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello ESP32");
tft.setCursor(24, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("I can do SPI :-)");
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.print("OK! IP=");
Serial.println(WiFi.localIP());
Serial.print("Fetching " + url + "... ");
HTTPClient http;
http.begin(url);
http.addHeader("X-API-Key","ghu438$Q#BJ!");
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
Serial.print("HTTP ");
Serial.println(httpResponseCode);
payload = http.getString();
Serial.println();
Serial.println(payload);
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
Serial.println(":-(");
}
// Parse JSON data
parseData(payload);
}
void loop() {
delay(10);
}
Loading
epaper-2in9
epaper-2in9