検索コード

ESP32-S3 RGB LEDマトリックスインターネット時計プロジェクト - 2つの時計の多色時間と日付の表示

ESP32-S3 RGB LEDマトリックスインターネット時計プロジェクト - 2つの時計の多色時間と日付の表示

ESP32-S3 RGBネオマトリックスインターネット時計 時間と日付表示付き

このプロジェクトは、現在の時間を表示するだけでなく、定期的に日付も表示する強化されたESP32-S3 RGBマトリックスインターネット時計です。ESP32-S3はWi-Fiに接続し、NTPサーバーから時間を同期し、スクロールします。HH:MMまたは日付(例えばSEP 21) 8×8のRGB NeoMatrix全体に。ディスプレイは自動的な昼夜の明るさ調整とカスタマイズ可能なRGBカラーをサポートしています。

ESP32-s3インターネット時計アニメーション

この時計の機能

Wi-Fiネットワークに接続すると、ESP32-S3はインターネットから現在のローカル時間を取得します。時計は通常、時間をスクロール表示しますが、固定の間隔で日付を表示するモードに切り替わります。テキストの色は1色に固定することも、ユーザー定義の複数の色を自動的に循環させることもできます。夜間は明るさが自動的に低下し、ディスプレイが目に優しくなるよう配慮されています。

使用されたライブラリ

このスケッチは以下のライブラリに依存しています:

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

インストールAdafruit NeoMatrixArduinoライブラリマネージャーから。必要なすべての依存関係として、Adafruit GFX LibraryそしてAdafruit NeoPixel自動的にインストールされます。

重要なユーザー設定

Wi-Fi SSID とパスワード(大文字と小文字を区別)

Wi-Fiの認証情報を自分のネットワーク情報に置き換える必要があります。

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

重要なこと:Wi-Fi SSIDはケースセンシティブ例えば、名前が付けられたSSID"Book"ですない同じです"book"大文字と小文字が正確に一致しない場合、ESP32は接続に失敗します。

NTPサーバー、タイムゾーン、サマータイム

時計はインターネットタイムサーバーを使用しています。

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

ローカル時間はこれらのオフセットを使用して計算されます:

const long  gmtOffset_sec     = -5 * 3600; 
const int   daylightOffset_sec = 3600;
  • gmtOffset_secあなたのUTCオフセット(秒単位)(例:UTC-5 =-5 * 3600)
  • daylightOffset_sec使用3600DSTまたは0DSTが使用されていない場合

これらの設定は以下の方法で適用されます:

configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);

明るさ調整(昼 / 夜)

このプロジェクトは、時間に応じて明るさを自動的に調整します。

const int DAY_BRIGHTNESS = 40;
const int NIGHT_BRIGHTNESS = 5;
const int NIGHT_START_HOUR = 22;
const int NIGHT_END_HOUR = 6;

午後10時から午前6時の間、暗い環境で画面が気にならないように明るさが低下します。これらの値は好みに応じて調整できます。

RGBカラ―構成

時計は固定カラー モードと自動カラー サイクリングの両方をサポートしています。ユーザー定義のRGBカラーは配列に保存されます:

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
};

各色は、0から255までのRGB(赤、緑、青)値を使用します。これらの数字を変更することで、ディスプレイ用にほぼすべての色を作成できます。もしuseFixedColor設定されているtrue, 時計は常に一色を使用します。設定されている場合はfalse色は、各フルスクロール後に自動的に変更されます。

希望する色の正確なRGB値を迅速に見つけるには、RGBカラーピッカーツールを使用してください。RGBカラーピッカー.

日時のフォーマット

時間は次のようにフォーマットされていますHH:MM小さなキャラクターバッファに保存されます。日付は、次のような大文字の文字列としてフォーマットされています。SEP 21ディスプレイは、固定された間隔で自動的に時間と日付を切り替えます。

8×8ディスプレイのスクロールロジック

8×8のマトリックスはテキストを一度に表示するには小さすぎるため、スケッチはテキストを横にスクロールします。テキストが完全に表示から離れると、色が更新され、必要に応じてコンテンツが時間と日付の間で切り替わります。

デモンストレーション

スケッチをアップロードした後:

  • ESP32はWi-Fiに接続します。
  • 時間はインターネットから同期されています。
  • 現在の時間がマトリックスをスクロールしています
  • 日付は定期的に表示されます。
  • 明るさは昼夜に応じて自動的に調整されます。

ダウンロードとリンク

この記事の下に完全なソースコードが提供されています。また、パーツ、ツール、およびデータシートへのリンクもこの記事の下にあります。

画像

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
869-ESP32-S3 RGB LED Matrix Internte Clock Project 2 - Multi Color with Date
言語: C++
/*
 * =====================================================================================
 * ESP32-S3 INTERNET RGB CLOCK (8x8 Matrix) - Project 2
 Multi color
 * =====================================================================================
 watch video https://youtube.com/shorts/4iWjLiD7fS8
 📚⬇️ Download and resource page https://robojax.com/RJT839
 * Author:  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 when text finishes a full scroll.
 * 3. Auto-Brightness: Dims the LEDs during night hours (User-configurable).
 * 4. Periodic Date: Scrolls the date (e.g., "JAN 07") every 2 minutes.
 * * USER CONFIGURATION GUIDE:
 * -------------------------
 * - WiFi: Change 'WIFI_SSID' and 'WIFI_PASSWORD' to your local network.
 * - Colors: Add or remove {R, G, B} sets in the 'userColors' array.
 * - Night Mode: Adjust 'NIGHT_START_HOUR' and 'NIGHT_BRIGHTNESS'.
 * =====================================================================================
 */

#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; 
const int NIGHT_END_HOUR = 6;

// --- 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]);

// --- DATE/TIME INTERVALS ---
unsigned long lastDateShowMs = 0;
const uint32_t dateIntervalMs = 30000; // 2 minutes
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";
char dateText[10] = "";
char currentDisplayText[12] = ""; 
int16_t scrollX = 8;


const char* ntpServer = "pool.ntp.org";
const long  gmtOffset_sec     = -5 * 3600; 
const int   daylightOffset_sec = 3600;

void updateTimeAndDate() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) return;
  
  snprintf(timeText, sizeof(timeText), "%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min);
  strftime(dateText, sizeof(dateText), "%b %d", &timeinfo);
  for (int i = 0; dateText[i]; i++) dateText[i] = toupper(dateText[i]);

  if (timeinfo.tm_hour >= NIGHT_START_HOUR || timeinfo.tm_hour < NIGHT_END_HOUR) {
    matrix.setBrightness(NIGHT_BRIGHTNESS);
  } else {
    matrix.setBrightness(DAY_BRIGHTNESS);
  }
}

void scrollDisplay() {
  matrix.fillScreen(0);
  
  // FIXED LOGIC: Uses currentColorIndex which only changes at the end of a scroll
  int idx = useFixedColor ? fixedColorIndex : currentColorIndex;
  matrix.setTextColor(matrix.Color(userColors[idx][0], userColors[idx][1], userColors[idx][2]));

  matrix.setCursor(scrollX, 0);
  matrix.print(currentDisplayText);
  matrix.show();

  scrollX--;

  int16_t textWidth = strlen(currentDisplayText) * 6;
  
  // THE TRIGGER POINT: This happens only when text is fully off-screen
  if (scrollX < -textWidth) {
    scrollX = matrix.width(); 
    
    // 1. Cycle the color now and only now
    if (!useFixedColor) {
      currentColorIndex = (currentColorIndex + 1) % totalColors;
    }

    // 2. Decide whether to switch between Time and Date
    if (millis() - lastDateShowMs > dateIntervalMs) {
      strcpy(currentDisplayText, dateText);
      lastDateShowMs = millis();
    } else {
      strcpy(currentDisplayText, timeText);
    }
  }
}

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);
  
  updateTimeAndDate();
  strcpy(currentDisplayText, timeText); 
}

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

  if (now - lastTimeUpdateMs >= timeUpdateIntervalMs) {
    lastTimeUpdateMs = now;
    updateTimeAndDate(); 
  }

  if (now - lastScrollMs >= scrollIntervalMs) {
    lastScrollMs = now;
    scrollDisplay();
  }
}

必要かもしれないもの

ファイル📁

フリッツィングファイル