Search Code

ESP32-S3 RGB LED મેટ્રિક્સ ઇન્ટરનેટ ઘડિયાળ પ્રોજેક્ટ - તારીખ સાથે 3 રાત્રિ રંગ

ESP32-S3 RGB LED મેટ્રિક્સ ઇન્ટરનેટ ઘડિયાળ પ્રોજેક્ટ - તારીખ સાથે 3 રાત્રિ રંગ

ESP32-S3 RGB નિયોમેટ્રિક્સ ઇન્ટરનેટ ઘડિયાળ સ્વચાલિત દિવસ/રાત્રિ તેજ સાથે

આ પ્રોજેક્ટ એક ESP32-S3 RGB મેટ્રિક્સ ઇન્ટરનેટ ઘડિયાળ છે જે દિવસ અને રાત્રિ દરમિયાન તેજ આપમેળે સમાયોજિત કરે છે. ESP32-S3 Wi-Fi સાથે કનેક્ટ થાય છે, NTP સર્વરથી વર્તમાન સમય સિંક્રનાઇઝ કરે છે, અને 8×8 RGB નિયોમેટ્રિક્સ પર HH:MM ફોર્મેટમાં સમય સ્ક્રોલ કરે છે. ઘડિયાળ ડિસ્પ્લે ટેક્સ્ટ માટે નિશ્ચિત અથવા ચક્રીય RGB રંગોને પણ સપોર્ટ કરે છે.

આ ઘડિયાળ શું કરે છે

પાવર ચાલુ કર્યા પછી, ESP32-S3 તમારા Wi-Fi નેટવર્ક સાથે કનેક્ટ થાય છે અને ઇન્ટરનેટથી વર્તમાન સ્થાનિક સમય મેળવે છે. સમય LED મેટ્રિક્સ પર સરળતાથી સ્ક્રોલ થાય છે. રાત્રિના કલાકો દરમિયાન, ડિસ્પ્લે આપમેળે ઓછી તેજમાં ઝાંખું થાય છે, જ્યારે દિવસ દરમિયાન તે ફરીથી તેજસ્વી સ્તર પર સ્વિચ થાય છે.

ESP32-s3_internet_clock_animation

વપરાયેલી લાઇબ્રેરીઓ

આ સ્કેચ નીચેની લાઇબ્રેરીઓનો ઉપયોગ કરે છે:

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

Arduino લાઇબ્રેરી મેનેજરમાંથી Adafruit NeoMatrix ઇન્સ્ટોલ કરો. Adafruit GFX Library અને Adafruit NeoPixel જેવી બધી જરૂરી નિર્ભરતાઓ આપમેળે ઇન્સ્ટોલ થશે.

મહત્વપૂર્ણ વપરાશકર્તા રૂપરેખાંકન

Wi-Fi SSID અને પાસવર્ડ (કેસ-સંવેદનશીલ)

નીચેના મૂલ્યોને તમારા પોતાના Wi-Fi ઓળખપત્રોથી બદલો:

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

મહત્વપૂર્ણ: Wi-Fi SSID કેસ-સંવેદનશીલ છે. "Book" નામનો SSID "book" જેવો નથી. જો મોટા/નાના અક્ષરો બરાબર મેળ ન ખાય, તો ESP32 કનેક્ટ થવામાં નિષ્ફળ જશે.

NTP સર્વર, સમય ઝોન અને ડેલાઇટ સેવિંગ

ઘડિયાળ નીચેના NTP સર્વરનો ઉપયોગ કરીને સમય સિંક્રનાઇઝ કરે છે:

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

સ્થાનિક સમય આ ઓફસેટ્સનો ઉપયોગ કરીને ગણવામાં આવે છે:

const long  gmtOffset_sec     = -5 * 3600; 
const int   daylightOffset_sec = 3600;
  • gmtOffset_sec તમારા UTC ઓફસેટને સેકંડમાં વ્યાખ્યાયિત કરે છે
  • daylightOffset_sec ડેલાઇટ સેવિંગ સમય સક્રિય હોય ત્યારે એક કલાક ઉમેરે છે (જો જરૂર ન હોય તો 0 વાપરો)

આ મૂલ્યો આ સાથે લાગુ કરવામાં આવે છે:

configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);

સ્વચાલિત દિવસ / રાત્રિ તેજ

ડિસ્પ્લે તેજ વર્તમાન કલાકના આધારે આપમેળે બદલાય છે:

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

રાત્રે 10 વાગ્યાથી સવારે 6 વાગ્યા સુધી, મેટ્રિક્સ તેજ ઘટાડવામાં આવે છે જેથી શ્યામ વાતાવરણમાં તે આરામદાયક રહે. તે કલાકોની બહાર, સંપૂર્ણ દિવસની તેજ પુનઃસ્થાપિત થાય છે. તમે તમારા રૂમની લાઇટિંગને અનુરૂપ આ મૂલ્યોને સમાયોજિત કરી શકો છો.

RGB રંગ રૂપરેખાંકન

ઘડિયાળનો ટેક્સ્ટ રંગ RGB (લાલ, લીલો, વાદળી) મૂલ્યોનો ઉપયોગ કરીને વ્યાખ્યાયિત થાય છે, જ્યાં દરેક ચેનલ 0 થી 255 સુધી હોય છે. બહુવિધ રંગોને એરેમાં સંગ્રહિત કરી શકાય છે અને આપમેળે ચક્રિત કરી શકાય છે:

uint8_t userColors[][3] = {
  {17, 43, 171},  // હળવો વાદળી
  {255, 0, 0},    // લાલ
  {0, 255, 0},    // લીલો
  {255, 165, 0},  // નારંગી
  {255, 0, 255}   // મેજેન્ટા
};

જો useFixedColor true પર સેટ હોય, તો ઘડિયાળ હંમેશા એક રંગનો ઉપયોગ કરે છે. જો false પર સેટ હોય, તો સમયના દરેક સંપૂર્ણ સ્ક્રોલ પછી રંગ આપમેળે બદલાય છે.

કોઈપણ રંગ માટે ચોક્કસ RGB મૂલ્યો ઝડપથી શોધવા માટે, RGB કલર પિકર ટૂલનો ઉપયોગ કરો: કલર પિકર .

સમય પ્રદર્શન અને સ્ક્રોલિંગ

વર્તમાન સમય HH:MM તરીકે ફોર્મેટ થાય છે અને નાના કેરેક્ટર બફરમાં સંગ્રહિત થાય છે. ડિસ્પ્લે માત્ર 8 પિક્સેલ પહોળું હોવાથી, ટેક્સ્ટ જમણેથી ડાબે સરળતાથી સ્ક્રોલ થાય છે. સમય સંપૂર્ણપણે ડિસ્પ્લે છોડી દે તે પછી, આગલા પાસ માટે આગલો રંગ (જો સક્ષમ હોય તો) પસંદ થાય છે.

પ્રદર્શન

સ્કેચ અપલોડ કર્યા પછી:

  • ESP32-S3 Wi-Fi સાથે કનેક્ટ થાય છે
  • સમય ઇન્ટરનેટથી સિંક્રનાઇઝ થાય છે
  • વર્તમાન સમય RGB મેટ્રિક્સ પર સ્ક્રોલ થાય છે
  • તેજ દિવસ અને રાત્રિ વચ્ચે આપમેળે બદલાય છે
  • ટેક્સ્ટ રંગ તમારી સેટિંગ્સના આધારે નિશ્ચિત રહે છે અથવા ચક્રિત થાય છે

ડાઉનલોડ્સ અને લિંક્સ

સંપૂર્ણ સ્ત્રોત કોડ આ લેખની નીચે આપવામાં આવ્યો છે. ભાગો, સાધનો અને ડેટાશીટ્સની લિંક્સ આ લેખની નીચે ઉપલબ્ધ છે.

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
870-ESP32-S3 RGB LED Matrix Internte Clock Project 3 - Night Color with Date
Language: 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();
  }
}

Things you might need

Resources & references

Files📁

Fritzing File