Search Code

Iṣẹ́ Aago ESP32-S3 RGB LED Matrix Wi-Fi + NTP - 1 Aago Ìpìlẹ̀

Iṣẹ́ Aago ESP32-S3 RGB LED Matrix Wi-Fi + NTP - 1 Aago Ìpìlẹ̀

Aago ESP32-S3 pẹ̀lu 8×8 NeoMatrix (Wi-Fi + NTP Time)

Iṣẹ́ yìí yí ESP32-S3 àti 8×8 RGB NeoMatrix (NeoPixel/WS2812) padà sí aago Intanẹ́ẹ̀tì kékeré. ESP32 sopọ̀ mọ́ Wi-Fi, ó mú àkókò àdúgbò láti ọ̀dọ̀ olùpèsè NTP, lẹ́yìn náà ó yí àkókò padà gẹ́gẹ́ bí HH:MM kọjá lórí àfihàn 8×8.

ESP32-s3_internet_clock_animation

 

Bí ó ṣe ń ṣiṣẹ́ (ìpele gíga)

1) ESP32-S3 sopọ̀ mọ́ olùpín rẹ ní lílo <WiFi.h>.
2) Ó mú àkókò padà láti ọ̀dọ̀ olùpèsè NTP ní lílo "time.h" àti configTime().
3) A ṣe àkókò náà ní ọ̀nà HH:MM àti títọ́jú sínú àkójọpọ̀ ọ̀rọ̀ kékeré.
4) NeoMatrix ṣe àfihàn ọ̀rọ̀ náà àti yíyí kọjá lórí pánẹ́lì 8×8.

Àwọ̀ RGB

A ń ṣàkóso àwọ̀ ọ̀rọ̀ aago ní lílo àwọn iye RGB (Pupa, Alawọ̀, Bulu), níbi tí ikanni àwọ̀ kọ̀ọ̀kan ti ń lọ láti 0 sí 255 àti àwọn àkópọ̀ oríṣiríṣi tí ń dá àwọn àwọ̀ oríṣiríṣi sílẹ̀ lórí NeoMatrix. Nípa yíyí àwọn oniyipada color_RED, color_GREEN, àti color_BLUE padà, o lè rọrùn ṣe àtúnṣe ìrísí aago sí èyíkéyìí àwọ̀ tí o fẹ́. Láti yára rí àwọn iye RGB pàtó fún àwọ̀ kan pàtó, o lè lo Olùyàn Àwọ̀ RGB orí ayélujára Olùyàn Àwọ̀ .

Àwọn ilé-ìkàwé tí a lò

Àwọn ìkànnì wọ̀nyí sọ fún ọ ní pàtó ohun tí sketch náà gbára lé:

#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

Fi Adafruit NeoMatrix sọ̀rọ̀ ní lílo Olùṣàkóso Ilé-ìkàwé Arduino. Yóò tún fa àwọn ìgbẹ́kẹ̀lé tí a nílò bíi Adafruit GFX Library àti Adafruit NeoPixel.

Àwọn ètò olùmúlò pàtàkì tí o GBỌDỌ̀ ṣàtúnṣe

1) Àwọ̀ ọ̀rọ̀ (RGB)

Ṣeto àwọ̀ ọ̀rọ̀ aago rẹ ní lílo àwọn iye 0–255:

//set the color of display made of Red, Green and Blue 
unsigned int color_RED = 17;
unsigned int color_GREEN = 43;
unsigned int color_BLUE = 171;

A ń lo àwọn iye wọ̀nyí níbí:

matrix.setTextColor(matrix.Color(color_RED, color_GREEN, color_BLUE));

Àkíyèsí: Bí o bá ṣeto gbogbo àwọn àwọ̀ sí 0 (dúdú), ọ̀rọ̀ náà yóò di aláìrí. Sketch náà ní àyẹ̀wò ààbò:

// if user set all colors to 0, the display will be turned off so set it green
if (color_RED == 0 && color_GREEN == 0 && color_BLUE == 0) {
  color_GREEN = 200;
}

Èyí ṣe àmúlò pé matrix kò ní rí bí ẹni pé ó ti "kú" nítorí ètò àwọ̀ aláìrí.

2) Wi-Fi SSID àti ọ̀rọ̀ìpamọ́

Rọ́pò àwọn wọ̀nyí pẹ̀lú orúkọ Wi-Fi àti ọ̀rọ̀ìpamọ́ gidi rẹ:

const char* WIFI_SSID     = "WiFi";
const char* WIFI_PASSWORD = "passW0rd";

Nígbà ìbẹ̀rẹ̀, ESP32 ń tẹ̀ àkọsílẹ̀ ìlọsíwájú ìsopọ̀ nínú Serial Monitor àti pé ó parí àkókò lẹ́yìn nǹkan bí iṣẹ́jú àáyá 15 (30 ìgbìyànjú × 500ms).

3) Olùpèsè NTP

Olùpèsè NTP tí a yàn fún ìpìlẹ̀ ni:

const char* ntpServer = "pool.ntp.org";

O lè fi sílẹ̀ bí ó ti rí. Bí o bá fẹ́ lò olùpèsè àdúgbò nígbàkígbà, rọ́pò orúkọ ibùdó pẹ̀lú olùpèsè NTP tí o fẹ́ràn.

4) Àìtúnṣe agbègbè àkókò àti àìtúnṣe ìmọ́lẹ̀ ọjọ́

Àwọn ètò méjì wọ̀nyí ń ṣàkóso àkókò àdúgbò:

// Toronto-ish: UTC-5, plus 1 hour DST
const long  gmtOffset_sec      = -5 * 3600;  // -5 hours
const int   daylightOffset_sec = 3600;       // +1 hour for DST

Bí a ṣe ń ṣeto wọn:

  • gmtOffset_sec = (àìtúnṣe UTC ní wákàtí) × 3600. Àpẹẹrẹ: UTC-5 → -5*3600, UTC+2 → 2*3600.
  • daylightOffset_sec = 0 bí o kò bá fẹ́ àìtúnṣe ìmọ́lẹ̀ ọjọ́, tàbí 3600 bí agbègbè rẹ bá ń ṣàkíyèsí ìmọ́lẹ̀ ọjọ́ lọ́wọ́lọ́wọ́ (+1 wákàtí).

A ń lo àwọn wọ̀nyí níbí:

configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);

Ìtòlẹ́sẹẹsẹ àfihàn

Pín data matrix

A ṣàlàyé pín data níbí:

#define MATRIX_PIN 14

Bí ìsopọ̀ rẹ bá ń lo GPIO yàtọ̀, yí nọ́ńbà yìí padà láti bá a mu.

Ìtòlẹ́sẹẹsẹ NeoMatrix + ìtòlẹ́sẹẹsẹ àwọ̀

A ń bẹ̀rẹ̀ matrix rẹ báyìí:

Adafruit_NeoMatrix matrix(8, 8, MATRIX_PIN,
  NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS   + NEO_MATRIX_PROGRESSIVE,
  NEO_RGB           + NEO_KHZ800);

Àwọn ìdí méjì tí ó wọ́pọ̀ tí àfihàn fi ń dà bí ẹni pé ó "ṣìnà":

  • Yíyí / ìtọ́nà ìsopọ̀: Bí ọ̀rọ̀ bá farahàn ní ìyípadà tàbí dídi, ṣàtúnṣe àwọn àsíá NEO_MATRIX_* (TOP/BOTTOM, LEFT/RIGHT, ROWS/COLUMNS, PROGRESSIVE/ZIGZAG).
  • Ìtòlẹ́sẹẹsẹ àwọ̀: Kóòdù yìí ń lo NEO_RGB. Àwọn pánẹ́lì kan jẹ́ NEO_GRB. Bí pupa/aláwọ̀ èwe/bulu kò bá bá a mu, yí NEO_RGB padà sí ìtòlẹ́sẹẹsẹ tí ó tọ́.

Ìmọ́lẹ̀

A ṣeto ìmọ́lẹ̀ nínú initMatrix():

matrix.setBrightness(40);

Pọ̀ sí i fún àfihàn tí ó mọ́lẹ̀ sí i, dín kù láti dín ooru àti agbára ìtà.

Bí a ṣe ń ṣe àkókò gẹ́gẹ́ bí HH:MM

Aago náà ń tọ́jú àkókò tí a ṣe ní ọ̀nà nínú àkójọpọ̀ ohun kíkọ́ 6:

char timeText[6] = "00:00";

Lẹ́yìn náà, updateTimeText() ka àkókò àdúgbò tí NTP ṣe àmúṣọ̀, ó sì kọ ọ̀rọ̀ náà:

// Ṣe àgbékalẹ̀ HH:MM
snprintf(timeText, sizeof(timeText), "%02d:%02d",
         timeinfo.tm_hour,
         timeinfo.tm_min);

Wọ́n ń mú èyí ṣiṣẹ́ lẹ́ẹ̀kan ní ìṣẹ́jú àáyá kọ̀ọ̀kan nínú ìyípo àkọ́kọ́.

Bí yíyí ṣe ń ṣiṣẹ́ lórí àfihàn 8×8

Matrix 8×8 kéré jù láti fi HH:MM hàn ní ẹ̀ẹ̀kan, nítorí náà, sketch ń yí ọ̀rọ̀ náà. Ó ń ya àkókò ní ipò X tí ń yípadà (scrollX), lẹ́yìn náà ó ń gbé e lọ sí òsì ní píkṣẹ́lì kan ní ìmúdójúìwọ̀n kọ̀ọ̀kan.

int16_t scrollX = 8;
const uint16_t scrollIntervalMs = 120;

Ìgbésẹ̀ yíyí kọ̀ọ̀kan:

matrix.fillScreen(0);
matrix.setCursor(scrollX, 0);
matrix.print(timeText);
matrix.show();
scrollX--;

Nígbà tí ọ̀rọ̀ náà bá jáde pátápátá ní ẹ̀gbẹ́ òsì, kóòdù náà ń tún un ṣe láti bẹ̀rẹ̀ lẹ́ẹ̀kan sí i láti ẹ̀gbẹ́ ọ̀tún:

int16_t textWidth = 30;
if (scrollX < -textWidth) {
  scrollX = matrix.width();
}

Ìtéjáde Serial Monitor (ìwádìí)

Sketch yìí ń tẹ àwọn ọ̀rọ̀ tí ó wúlò:

  • Ìlọsíwájú ìsopọ̀ Wi-Fi àti àdírẹ́sì IP
  • Bóyá ìmúṣọ̀ àkókò ti ṣe àṣeyọrí
  • Ọ̀rọ̀ àkókò tí a ṣe àgbékalẹ̀ (fún àpẹẹrẹ, Ọ̀rọ̀ àkókò: 14:32)

Tí àfihàn bá ṣófo, Serial Monitor ni ibi àkọ́kọ́ láti ṣàyẹ̀wò láti fi dá Wi-Fi àti NTP lójú pé wọ́n ń ṣiṣẹ́.

Ìfihàn iṣẹ́-ọwọ́

Lẹ́yìn gbígbé sílẹ̀ àti àtúnbẹ̀rẹ̀:

  • ESP32 ń sopọ̀ sí Wi-Fi
  • Ó ń mú àkókò láti pool.ntp.org
  • Ó ń fi OK hàn fún ìgbà díẹ̀ lórí matrix
  • Ó ń yí àkókò lọ́wọ́lọ́wọ́ bí HH:MM

Àwọn ìgbàlódé àti àwọn ọ̀nà àbọ̀

Kóòdù kíkún wà nísàlẹ̀ àpilẹ̀kọ yìí. Àwọn ẹ̀yà, irinṣẹ́, àti àwọn iwe àkọsílẹ̀ data ni a tún sopọ̀ mọ́ nísàlẹ̀ àpilẹ̀kọ yìí.

Aworan

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
868-ESP32-S3 RGB LED Matrix Internte Clock Project 1 - Basic Clock
Ede: C++
/*
This is ESP32 sketch that connects to the internet, gets the time and displays it on the RGB matrix
you must set your WiFi correctly to make sure it gets connected. 
 watch video https://youtube.com/shorts/4iWjLiD7fS8
 📚⬇️ Download and resource page https://robojax.com/RJT838
 * Author:  Ahmad Shamshiri (Robojax.com)
 * Date: 07 Jan 2026
www.Robojax.com
https://youTube.com/@robojax


*/
#include <WiFi.h>
#include "time.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

//set the color of diplay make of Red, Green and Blue 
unsigned int color_RED = 17;
unsigned int color_GREEN = 43;
unsigned int color_BLUE = 171;

// 👇 REPLACE these with your real home WiFi name & password
const char* WIFI_SSID     = "WiFi";
const char* WIFI_PASSWORD = "passW0rd";



#define MATRIX_PIN 14

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;
unsigned long lastScrollMs = 0;
const uint16_t scrollIntervalMs = 120;

unsigned long lastTimeUpdateMs = 0;
const uint16_t timeUpdateIntervalMs = 1000;

//prototypes
bool updateTimeText();  // forward declaration
void scrollTime();      // forward declaration



// NTP (time) server
const char* ntpServer = "pool.ntp.org";

// Toronto-ish: UTC-5, plus 1 hour DST
const long  gmtOffset_sec     = -5 * 3600;  // -5 hours
const int   daylightOffset_sec = 3600;      // +1 hour for DST



bool updateTimeText() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) {
    Serial.println("Failed to obtain time for display");
    return false;
  }

  // Format HH:MM
  snprintf(timeText, sizeof(timeText), "%02d:%02d",
           timeinfo.tm_hour,
           timeinfo.tm_min);

  Serial.print("Time text: ");
  Serial.println(timeText);
  return true;
}

void scrollTime() {
  matrix.fillScreen(0);
  matrix.setCursor(scrollX, 0);
  matrix.print(timeText);
  matrix.show();

  scrollX--;

  // Rough width: 5 characters ("HH:MM") × 6 pixels each ≈ 30 px
  int16_t textWidth = 30;
  if (scrollX < -textWidth) {
    scrollX = matrix.width();  // reset to right edge (8)
  }
}


void initMatrix() {
  matrix.begin();
  matrix.setBrightness(40);        // be careful with heat
  matrix.setTextWrap(false);
  matrix.setTextColor(matrix.Color(color_RED, color_GREEN, color_BLUE)); // color of text
}

void showMessage(const char* msg) {
  matrix.fillScreen(0);
  matrix.setCursor(0, 0);  // top-left
  matrix.print(msg);
  matrix.show();
}


void printLocalTime() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) {
    Serial.println("Failed to obtain time");
    return;
  }
  // Format: 2025-11-18 14:35:12
  Serial.printf("%04d-%02d-%02d %02d:%02d:%02d\n",
                timeinfo.tm_year + 1900,
                timeinfo.tm_mon + 1,
                timeinfo.tm_mday,
                timeinfo.tm_hour,
                timeinfo.tm_min,
                timeinfo.tm_sec);
}

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println();
  Serial.println("ESP32-S3 Internet Clock - WiFi + NTP test");

  // Connect to WiFi
  Serial.print("Connecting to WiFi: ");
  Serial.println(WIFI_SSID);
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

  int retries = 0;
  while (WiFi.status() != WL_CONNECTED && retries < 30) { // ~15s timeout
    delay(500);
    Serial.print(".");
    retries++;
  }
  Serial.println();

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("WiFi connection FAILED");
  } else {
    Serial.print("WiFi connected. IP: ");
    Serial.println(WiFi.localIP());
  }

// if user set all colors to 0, the dispaly will be turned off so set it green
  if(color_RED ==0 & color_GREEN ==0 && color_BLUE ==0)
  {
    color_GREEN = 200;
  }

  // Configure time via NTP
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  Serial.println("Waiting for time...");
  delay(2000); // small wait for initial sync

  printLocalTime(); // print once at startup

    // NEW: init the LED matrix and show a test message
  initMatrix();
  showMessage("OK");
}

void loop() {
  unsigned long now = millis();

  // Update the time string "HH:MM" once per second
  if (now - lastTimeUpdateMs >= timeUpdateIntervalMs) {
    lastTimeUpdateMs = now;
    updateTimeText();  // fills timeText[], e.g. "14:32"
  }

  // Scroll the time across the 8×8 every scrollIntervalMs
  if (now - lastScrollMs >= scrollIntervalMs) {
    lastScrollMs = now;
    scrollTime();      // uses timeText and scrollX
  }
}

Orisun & itọkasi

Fáìlìs📁

Fayile Fritzing