This tutorial is part of: ESP32-S3 RGB LED-matrix
Een gaaf project om te maken voor de lol en voor praktische toepassingen met de ESP32-S3 RGB-matrixmodule. Links naar andere video's vind je onderaan dit artikel.
ESP32-S3 RGB LED-matrix internetklokproject - 3 nachtkleuren met datum
ESP32-S3 RGB NeoMatrix internetklok met automatische dag/nacht-helderheid
Dit project is een ESP32-S3 RGB Matrix internetklok die de helderheid overdag en 's nachts automatisch aanpast. De ESP32-S3 maakt verbinding met Wi-Fi, synchroniseert de huidige tijd vanaf een NTP-server en laat de tijd in HH:MM-formaat over een 8×8 RGB NeoMatrix scrollen. De klok ondersteunt ook vaste of wisselende RGB-kleuren voor de weergavetekst.

Wat deze klok doet
Na het inschakelen maakt de ESP32-S3 verbinding met uw Wi-Fi-netwerk en haalt de huidige lokale tijd van internet op. De tijd scrollt soepel over de LED-matrix. Tijdens de nachtelijke uren wordt de weergave automatisch gedimd naar een lagere helderheid, terwijl deze overdag terugschakelt naar een helderder niveau.
Gebruikte bibliotheken
Deze sketch gebruikt de volgende bibliotheken:

#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
Installeer Adafruit NeoMatrix via de Arduino Library Manager. Alle vereiste afhankelijkheden zoals Adafruit GFX Library en Adafruit NeoPixel worden automatisch geïnstalleerd.

Belangrijke gebruikersconfiguratie
Wi-Fi SSID en wachtwoord (hoofdlettergevoelig)
Vervang de volgende waarden door uw eigen Wi-Fi-gegevens:

const char* WIFI_SSID = "WiFi";
const char* WIFI_PASSWORD = "passW0rd";
Belangrijk: Wi-Fi SSID's zijn hoofdlettergevoelig. Een SSID genaamd "Book" is niet hetzelfde als "book". Als de hoofdletters niet exact overeenkomen, zal de ESP32 geen verbinding kunnen maken.
NTP-server, tijdzone en zomertijd
De klok synchroniseert de tijd met behulp van de volgende NTP-server:
const char* ntpServer = "pool.ntp.org";
De lokale tijd wordt berekend met behulp van deze offsets:
const long gmtOffset_sec = -5 * 3600;
const int daylightOffset_sec = 3600;
gmtOffset_secdefinieert uw UTC-offset in secondendaylightOffset_secvoegt één uur toe wanneer zomertijd actief is (gebruik0indien niet nodig)
Deze waarden worden toegepast met:
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
Automatische dag/nacht-helderheid
De helderheid van de weergave verandert automatisch op basis van het huidige uur:
const int DAY_BRIGHTNESS = 40;
const int NIGHT_BRIGHTNESS = 5;
const int NIGHT_START_HOUR = 22; // 10 PM
const int NIGHT_END_HOUR = 6; // 6 AM
Tussen 22:00 en 06:00 wordt de matrixhelderheid verlaagd om comfortabel te zijn in donkere omgevingen. Buiten die uren wordt de volledige daghelderheid hersteld. U kunt deze waarden aanpassen aan uw kamerverlichting.
RGB-kleurconfiguratie
De tekstkleur van de klok wordt gedefinieerd met RGB-waarden (Rood, Groen, Blauw), waarbij elk kanaal varieert van 0 tot 255. Meerdere kleuren kunnen in een array worden opgeslagen en automatisch worden gewisseld:
uint8_t userColors[][3] = {
{17, 43, 171}, // Lichtblauw
{255, 0, 0}, // Rood
{0, 255, 0}, // Groen
{255, 165, 0}, // Oranje
{255, 0, 255} // Magenta
};
Als useFixedColor is ingesteld op true, gebruikt de klok altijd één kleur. Als dit is ingesteld op false, verandert de kleur automatisch na elke volledige scroll van de tijd.
Om snel de exacte RGB-waarden voor elke kleur te vinden, gebruikt u de RGB-kleurkiezer-tool: Kleurkiezer .
Tijdweergave en scrollen
De huidige tijd wordt opgemaakt als HH:MM en opgeslagen in een kleine karakterbuffer. Omdat de weergave slechts 8 pixels breed is, scrollt de tekst soepel van rechts naar links. Zodra de tijd volledig van de weergave is verdwenen, wordt de volgende kleur (indien ingeschakeld) geselecteerd voor de volgende doorgang.
Demonstratie
Na het uploaden van de sketch:
- Maakt de ESP32-S3 verbinding met Wi-Fi
- Wordt de tijd vanaf internet gesynchroniseerd
- Scrollt de huidige tijd over de RGB-matrix
- Verandert de helderheid automatisch tussen dag en nacht
- Blijft de tekstkleur vast of wisselt op basis van uw instellingen
Downloads en links
De volledige broncode vindt u onder dit artikel. Links naar onderdelen, gereedschappen en datasheets zijn beschikbaar onder dit artikel.
This tutorial is part of: ESP32-S3 RGB LED-matrix
- ESP32-S3 RGB LED-matrixproject 1- Basispunt
- ESP32-S3 RGB LED-matrixproject 2 - Scrollende tekst
- ESP32-S3 RGB LED-matrixproject 3 - Tekst vanaf mobiele telefoon
- ESP32-S3 RGB LED-matrixproject 4 - Kantelpunt
- ESP32-S3 RGB LED-matrixproject 5 - Pijl altijd omhoog
- ESP32-S3 RGB LED-matrixproject 6 - Cible-spel
- ESP32-S3 RGB LED-matrix Wi-Fi + NTP-tijdklokproject -1 Basisklok
- ESP32-S3 RGB LED-matrix internetklokproject - 2 klokken multi-kleur tijd- en datumweergave
- ESP32-S3 RGB LED-matrix internetklokproject - 5 Regenboogkleur
- ESP32-S3 RGB LED-matrix internetklokproject - 4 willekeurige kleuren
- ESP32-S3 RGB LED Matrix test for RGB, GRB setting
/*
* =====================================================================================
* ESP32-S3 INTERNET RGB CLOCK (8x8 Matrix) - Project 3- Night color with Date
* =====================================================================================
watch video https://youtube.com/shorts/4iWjLiD7fS8
📚⬇️ Download and resource page https://robojax.com/RJT840
* Author: Gemini (AI Thought Partner) & Ahmad Shamshiri (Robojax.com)
* Date: 07 Jan 2026
* * FEATURES:
* 1. WiFi/NTP Time: Syncs automatically with internet time servers.
* 2. Cycle-Based Color: Color changes ONLY after the time finishes a full scroll.
* 3. Auto-Brightness: Dims the LEDs during night hours (User-configurable).
* =====================================================================================
*/
#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define MATRIX_PIN 14
// --- BRIGHTNESS CONFIGURATION ---
const int DAY_BRIGHTNESS = 40;
const int NIGHT_BRIGHTNESS = 5;
const int NIGHT_START_HOUR = 22; // 10 PM
const int NIGHT_END_HOUR = 6; // 6 AM
// --- COLOR CONFIGURATION ---
bool useFixedColor = false;
int fixedColorIndex = 0;
uint8_t userColors[][3] = {
{17, 43, 171}, // Light Blue
{255, 0, 0}, // Red
{0, 255, 0}, // Green
{255, 165, 0}, // Orange
{255, 0, 255} // Magenta
};
// 👇 REPLACE these with your real home WiFi name & password
const char* WIFI_SSID = "WiFi";
const char* WIFI_PASSWORD = "passW0rd";
int currentColorIndex = 0;
int totalColors = sizeof(userColors) / sizeof(userColors[0]);
// --- INTERVALS ---
unsigned long lastTimeUpdateMs = 0;
const uint16_t timeUpdateIntervalMs = 1000;
unsigned long lastScrollMs = 0;
const uint16_t scrollIntervalMs = 100;
// --- GLOBAL VARIABLES ---
Adafruit_NeoMatrix matrix(8, 8, MATRIX_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_RGB + NEO_KHZ800);
char timeText[6] = "00:00";
int16_t scrollX = 8;
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = -5 * 3600;
const int daylightOffset_sec = 3600;
void updateTimeText() {
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) return;
// Format HH:MM
snprintf(timeText, sizeof(timeText), "%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min);
// Apply Auto-Brightness
if (timeinfo.tm_hour >= NIGHT_START_HOUR || timeinfo.tm_hour < NIGHT_END_HOUR) {
matrix.setBrightness(NIGHT_BRIGHTNESS);
} else {
matrix.setBrightness(DAY_BRIGHTNESS);
}
}
void scrollTime() {
matrix.fillScreen(0);
// Pick the color (Fixed or Cycle)
int idx = useFixedColor ? fixedColorIndex : currentColorIndex;
matrix.setTextColor(matrix.Color(userColors[idx][0], userColors[idx][1], userColors[idx][2]));
matrix.setCursor(scrollX, 0);
matrix.print(timeText);
matrix.show();
scrollX--;
// Width for "HH:MM" is roughly 30 pixels
int16_t textWidth = 30;
// TRIGGER: When time is fully off-screen
if (scrollX < -textWidth) {
scrollX = matrix.width(); // Reset position to right side
// Cycle to the next color in the array for the next pass
if (!useFixedColor) {
currentColorIndex = (currentColorIndex + 1) % totalColors;
Serial.print("Next cycle color index: ");
Serial.println(currentColorIndex);
}
}
}
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(DAY_BRIGHTNESS);
updateTimeText();
}
void loop() {
unsigned long now = millis();
// Update time digits and brightness once per second
if (now - lastTimeUpdateMs >= timeUpdateIntervalMs) {
lastTimeUpdateMs = now;
updateTimeText();
}
// Handle the scrolling animation
if (now - lastScrollMs >= scrollIntervalMs) {
lastScrollMs = now;
scrollTime();
}
}
Dingen die je misschien nodig hebt
-
Amazon
-
eBay
-
AliExpressPurchase ESP32-S3 RGB Matrix from AliExpresss.click.aliexpress.com
-
AliExpressPurchase ESP32-S3 RGB Matrix from AliExpress (2)s.click.aliexpress.com
Hulpmiddelen en referenties
-
Video
-
Intern🎨 Color picker Toolrobojax.com
Bestanden📁
Fritzing-bestand
-
esp32-S3-supermini-tht fritzing part
esp32-S3-supermini-tht.fzpz0.02 MB