m5paper_weather_display.ino

M5Stack M5Paper · Archivo : m5paper_weather_display.ino · Lenguaje : C++ · Uso : Afficher l'heure actuelle mise à jour via le réseau NTP.

Combina Wi-Fi y pantalla e-Ink para crear un reloj de red simple.

Reemplace YOUR_SSID y YOUR_PASSWORD con sus credenciales. Utiliza la biblioteca NTPClient. La pantalla no debe actualizarse con demasiada frecuencia para evitar el 'ghosting' y ahorrar batería. Se puede agregar el modo de suspensión profunda para una autonomía máxima.

m5paper_weather_display.ino

#include <M5EPD.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include <NTPClient.h>

M5EPD m5epd;
const char *ssid     = "YOUR_SSID";
const char *password = "YOUR_PASSWORD";

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 0, 60000);

void setup() {
  m5epd.begin();
  m5epd.updateBuffer();
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    m5epd.drawCentreString("Connecting...", 480, 270, 4);
    m5epd.updateDisplay();
  }
  
  timeClient.begin();
  timeClient.forceUpdate();
}

void loop() {
  timeClient.update();
  
  m5epd.fillScreen(EPD_WHITE);
  m5epd.drawCentreString(timeClient.getFormattedTime(), 480, 270, 8);
  m5epd.drawCentreString("M5Paper NTP Clock", 480, 350, 4);
  m5epd.updateDisplay();
  
  delay(10000); // Mise à jour toutes les 10 secondes
}

← Volver a la ficha