Search Code

Iṣẹ́ Aago Internet Matrix LED RGB ESP32-S3 - Àwọ̀ Alẹ́ 3 pẹ̀lú Ọjọ́

Iṣẹ́ Aago Internet Matrix LED RGB ESP32-S3 - Àwọ̀ Alẹ́ 3 pẹ̀lú Ọjọ́

Aago ESP32-S3 RGB NeoMatrix ti Aago Ayelujara pẹlu Imọlẹ Ọjọ/Alẹ Laifọwọyi

Ise agbese yii jẹ Aago Matrix RGB ESP32-S3 ti o ṣatunṣe imọlẹ laifọwọyi ni ọsan ati ni alẹ. ESP32-S3 sopọ si Wi-Fi, ṣe amuṣiṣẹpọ akoko lọwọlọwọ lati olupin NTP, ati yi akoko ni ọna kika HH:MM kọja NeoMatrix 8×8 RGB. Aago naa tun ṣe atilẹyin awọn awọ RGB ti o wa titi tabi ti n yipo fun ọrọ ifihan.

Ohun ti aago yii ṣe

Lẹhin ti o ba tan, ESP32-S3 sopọ si nẹtiwọọki Wi-Fi rẹ ati gba akoko agbegbe lọwọlọwọ lati intanẹẹti. Akoko naa yi laisiyọ kọja matrix LED. Ni awọn wakati alẹ, ifihan naa ṣe imọlẹ silẹ laifọwọyi si ipele imọlẹ kekere, nigba ti ọsan o pada si ipele imọlẹ ti o ga julọ.

ESP32-s3_internet_clock_animation

Awọn ile-ikawe ti a lo

Sketch yii lo awọn ile-ikawe wọnyi:

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

Fi sori ẹrọ Adafruit NeoMatrix lati inu Oluṣakoso Ile-ikawe Arduino. Gbogbo awọn igbẹkẹle ti o nilo bii Adafruit GFX Library ati Adafruit NeoPixel yoo fi sori ẹrọ laifọwọyi.

Iṣeto olumulo pataki

Wi-Fi SSID ati ọrọ igbaniwọle (ti o ṣe pataki si ọrọ nla/kekere)

Rọpo awọn iye wọnyi pẹlu awọn iwe-ẹri Wi-Fi tirẹ:

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

Pataki: Awọn SSID Wi-Fi jẹ ti o ṣe pataki si ọrọ nla/kekere. SSID ti a npè ni "Book" kii ṣe kanna pẹlu "book". Ti ọrọ nla ko ba baamu deede, ESP32 yoo kuna lati sopọ.

Olupin NTP, agbegbe akoko, ati fifipamọ ọsan

Aago naa ṣe amuṣiṣẹpọ akoko nipa lilo olupin NTP yii:

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

Akoko agbegbe ni a ṣe iṣiro nipa lilo awọn aiyipada wọnyi:

const long  gmtOffset_sec     = -5 * 3600; 
const int   daylightOffset_sec = 3600;
  • gmtOffset_sec ṣalaye aiyipada UTC rẹ ni awọn aaya
  • daylightOffset_sec ṣafikun wakati kan nigbati akoko fifipamọ ọsan ba n ṣiṣẹ (lo 0 ti ko ba nilo)

Awọn iye wọnyi ni a lo pẹlu:

configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);

Imọlẹ ọjọ / alẹ laifọwọyi

Imọlẹ ifihan naa yipada laifọwọyi da lori wakati lọwọlọwọ:

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

Laarin 10 PM ati 6 AM, imọlẹ matrix naa dinku lati jẹ ki o rọrun ni awọn agbegbe dudu. Ni ita awọn wakati wọnyẹn, imọlẹ ọjọ kikun yoo pada. O le ṣatunṣe awọn iye wọnyi lati ba imọlẹ yara rẹ mu.

Iṣeto awọ RGB

Awọ ọrọ aago naa jẹ asọye nipa lilo awọn iye RGB (Pupa, Alawọ ewe, Bulu), nibiti ikanni kọọkan ti wa lati 0 si 255. Awọn awọ pupọ le wa ni ipamọ ninu akojọpọ ati yipo laifọwọyi:

uint8_t userColors[][3] = {
  {17, 43, 171},  // Bulu Imọlẹ
  {255, 0, 0},    // Pupa
  {0, 255, 0},    // Alawọ ewe
  {255, 165, 0},  // Osan
  {255, 0, 255}   // Magenta
};

Ti useFixedColor ba ṣeto si true, aago naa maa lo awọ kan nigbagbogbo. Ti o ba ṣeto si false, awọ naa yoo yipada laifọwọyi lẹhin gbogbo yiyi kikun ti akoko naa.

Lati wa awọn iye RGB gangan fun eyikeyi awọ ni kiakia, lo Ẹrọ Yiyan Awọ RGB: Yiyan Awọ .

Ifihan akoko ati yiyi

Akoko lọwọlọwọ jẹ kika bii HH:MM ati ipamọ sinu ifipamọ ohun kikọ kekere. Nitori ifihan naa jẹ awọn piksẹli 8 nikan ni iwọn, ọrọ naa yi laisiyọ lati ọtun si osi. Ni kete ti akoko naa ba kuro ni ifihan patapata, awọ atẹle (ti o ba ṣiṣẹ) ni a yan fun igba atẹle.

Ifihan

Lẹhin gbigbe sketch naa soke:

  • ESP32-S3 sopọ si Wi-Fi
  • Akoko jẹ amuṣiṣẹpọ lati intanẹẹti
  • Akoko lọwọlọwọ yi kọja matrix RGB
  • Imọlẹ yipada laifọwọyi laarin ọjọ ati alẹ
  • Awọ ọrọ wa titi tabi yipo da lori awọn eto rẹ

Awọn igbasilẹ ati awọn ọna asopọ

Koodu orisun kikun wa ni isalẹ nkan yii. Awọn ọna asopọ si awọn ẹya, awọn irinṣẹ, ati awọn iwe data wa ni isalẹ nkan yii.

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
870-ESP32-S3 RGB LED Matrix Internte Clock Project 3 - Night Color with Date
Ede: C++
/*
 * =====================================================================================
 * 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();
  }
}

Orisun & itọkasi

Fáìlìs📁

Fayile Fritzing