Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WiFi.h>
- #include <HTTPClient.h>
- #include <GxEPD2_BW.h>
- #include <SPI.h>
- // WLAN-Zugangsdaten
- const char* ssid = "WLANNAME"; // Dein WLAN-Name
- const char* password = "DeinWlanPasswort"; // Dein WLAN-Passwort
- // E-Ink Display Pinbelegung
- #define EPD_BUSY 4
- #define EPD_RST 16
- #define EPD_DC 17
- #define EPD_CS 5
- #define EPD_CLK 18
- #define EPD_DIN 23
- // Display initialisieren
- GxEPD2_BW<GxEPD2_290_GDEY029T94, GxEPD2_290_GDEY029T94::HEIGHT> display(
- GxEPD2_290_GDEY029T94(EPD_CS, EPD_DC, EPD_RST, EPD_BUSY));
- // URL der Webseite
- const char* serverName = "https://n7.eu/robots.txt";
- void setup() {
- // Serielle Verbindung starten
- Serial.begin(115200);
- // Display initialisieren
- display.init(115200);
- display.setRotation(1);
- display.setFullWindow();
- // Mit WLAN verbinden
- Serial.println("Verbinde mit WLAN...");
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("Mit WLAN verbunden!");
- // Display initialisieren und erste Nachricht anzeigen
- display.firstPage();
- do {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(20, 50);
- display.setTextColor(GxEPD_BLACK);
- display.setTextSize(2);
- display.print("WLAN verbunden!");
- } while (display.nextPage());
- }
- void loop() {
- // Zeitstempel anzeigen (Aktualisierung alle 2 Minuten)
- delay(120000); // 2 Minuten warten
- // HTTP-Anfrage starten
- HTTPClient http;
- http.begin(serverName); // URL der Webseite
- // HTTP GET Anfrage senden
- int httpCode = http.GET();
- if (httpCode > 0) { // Wenn die Antwort erfolgreich war
- String payload = http.getString(); // Antwort in String umwandeln
- Serial.println("Text empfangen:");
- Serial.println(payload); // Zum Debuggen ausgeben
- // Text auf dem Display anzeigen
- display.firstPage();
- do {
- display.fillScreen(GxEPD_WHITE);
- display.setCursor(20, 50);
- display.setTextColor(GxEPD_BLACK);
- display.setTextSize(2);
- display.print(payload); // Empfangenes Text anzeigen
- } while (display.nextPage());
- } else {
- Serial.println("Fehler beim Abrufen des Textes.");
- }
- // HTTP-Verbindung beenden
- http.end();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement