This tutorial is part of: ESP32-S3 RGB LED Matrix
Cool project to create for fun and practical applications using ESP32-S3 RGB Matrix module.
ESP32-S3 RGB LED Matrix Internet Clock Project - 4 Random color
ESP32-S3 Internet Clock with Random RGB Colors
This project is an ESP32-S3 RGB Matrix Internet Clock that connects to Wi-Fi, synchronizes the local time from an NTP server, and scrolls the time in HH:MM format across the built-in 8×8 RGB NeoMatrix. In this version, the hours, colon, and minutes are each rendered in random colors selected on every full scroll cycle, creating a dynamic and playful clock display that constantly changes.

How this clock works
After powering the board via USB-C, the ESP32-S3 connects to your Wi-Fi network and retrieves the current local time from the internet. The time is split into three parts—hours, colon, and minutes—and each part is drawn separately on the RGB matrix. When the text scrolls fully off the screen, new random colors are chosen for the next pass.
Libraries used
This sketch uses the following libraries:

#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
Install Adafruit NeoMatrix from the Arduino Library Manager. Required dependencies such as Adafruit GFX Library and Adafruit NeoPixel will be installed automatically.

Important user configuration
Matrix data pin (built-in RGB matrix)
Although the RGB matrix is integrated on the board, the data pin must still be defined in the code:

#define MATRIX_PIN 14
GPIO 14 is commonly used on ESP32-S3 RGB matrix boards. If your board variant uses a different pin, update this value accordingly.
Wi-Fi SSID and password (case-sensitive)
Replace the Wi-Fi credentials with your own network details:
const char* WIFI_SSID = "your WiFi SSID";
const char* WIFI_PASSWORD = "passW0rd";
Important: Wi-Fi SSIDs are case-sensitive. An SSID named "Book" is not the same as "book". If the capitalization does not match exactly, the ESP32-S3 will fail to connect.
NTP server, time zone, and daylight saving
Time synchronization is done using an internet NTP server:
const char* ntpServer = "pool.ntp.org";
Local time is calculated using UTC and daylight saving offsets:
// Toronto-ish: UTC-5, plus 1 hour DST
const long gmtOffset_sec = -5 * 3600;
const int daylightOffset_sec = 3600;
gmtOffset_sec: UTC offset in seconds (adjust for your location)daylightOffset_sec: Use3600when DST is active, or0otherwise
These settings are applied using:
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
Automatic day / night brightness
The clock automatically adjusts brightness based on the current hour:
const int DAY_BRIGHTNESS = 40;
const int NIGHT_BRIGHTNESS = 5;
const int NIGHT_START_HOUR = 22;
const int NIGHT_END_HOUR = 6;
Between 10 PM and 6 AM, the display dims to reduce glare in dark environments. During daytime hours, the matrix returns to normal brightness.
Random RGB color behavior
A predefined list of RGB colors is stored in an array, where each color is defined using Red, Green, and Blue values ranging from 0 to 255:
uint8_t userColors[][3] = {
{255, 0, 0}, // Red
{0, 255, 0}, // Green
{0, 0, 255}, // Blue
{255, 165, 0}, // Orange
{255, 0, 255}, // Magenta
{0, 255, 255}, // Cyan
{255, 255, 0} // Yellow
};
On every full scroll cycle:
- The hour digits are assigned a random color
- The colon receives a different random color
- The minute digits receive another random color
This produces a constantly changing color combination that keeps the clock visually interesting. To create your own custom colors, you can use the RGB Color Picker tool: RGB Color Picker.
Time rendering logic
The time is split into three components:
- Hours:
HH - Colon:
: - Minutes:
MM
Each part is drawn individually so it can have its own color, while all parts move together to form a smooth scrolling animation across the 8×8 display.
Random color generation
To ensure color randomness, the sketch seeds the random number generator at startup using an unconnected analog pin:
randomSeed(analogRead(0));
This makes sure that color combinations are different on every power-up and every scroll cycle.
Demonstration
After uploading the sketch and powering the board via USB-C:
- The ESP32-S3 connects to your Wi-Fi network
- Time is synchronized from the internet
- The time scrolls in
HH:MMformat - Hours, colon, and minutes change to random colors each cycle
- The display automatically dims at night
Downloads and links
The complete source code is provided below this article. Useful tools and references are linked below this article.
This tutorial is part of: ESP32-S3 RGB LED Matrix
- ESP32-S3 RGB LED Matrix Project 1- Basic Dot
- ESP32-S3 RGB LED Matrix Project 2 - Scrolling Text
- ESP32-S3 RGB LED Matrix Project 3 - Text from mobile phone
- ESP32-S3 RGB LED Matrix Project 4 - Tilt dot
- ESP32-S3 RGB LED Matrix Project 5 - Arrow always up
- ESP32-S3 RGB LED Matrix Project 6 - Cible game
- ESP32-S3 RGB LED Matrix Wi-Fi + NTP Time Clock Project -1 Basic Clock
- ESP32-S3 RGB LED Matrix Internet Clock Project - 2 Clock multi color Time & Date Display
- ESP32-S3 RGB LED Matrix Internet Clock Project - 3 Night Color with Date
- ESP32-S3 RGB LED Matrix Internet Clock Project - 5 Rainbow color
- ESP32-S3 RGB LED Matrix test for RGB, GRB setting
Resources & references
-
Video
-
Internal🎨 Color picker Toolrobojax.com
Files📁
Fritzing File
-
esp32-S3-supermini-tht fritzing part
esp32-S3-supermini-tht.fzpz0.02 MB