ESP32-S3 RGB LED Matrix Internet Clock Project - 4 Random color

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.

ESP32-s3_internet_clock_animation

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: Use 3600 when DST is active, or 0 otherwise

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:MM format
  • 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.

Images

ESP32 S3 Matrix
ESP32 S3 Matrix
ESP32 S3 Matrix  pin out
ESP32 S3 Matrix pin out
ESP32-S3_RGB_8x8_matrix-3
ESP32-S3_RGB_8x8_matrix-3
ESP32-S3_RGB_8x8_matrix1
ESP32-S3_RGB_8x8_matrix1
ESP32-S3_RGB_8x8_matrix-2
ESP32-S3_RGB_8x8_matrix-2
ESP32-s3_internet_clock_animation
ESP32-s3_internet_clock_animation
873-ESP32-S3 RGB LED Matrix Internte Clock Project 4 - Random Color
Language: C++
Copied!

Resources & references

Files📁

Fritzing File