3. Code - G-Paul/ARGB_Clock GitHub Wiki

Uploading the Code:

Download the code from this repo, and open it in the Arduino IDE.

Make the following changes:

  • ssid: your Wifi SSID name
  • password: your WiFi password. The device needs internet connection to fetch the current time using NTP.
  • gmtcOffset_sec: the offset from GMT for your timezone (in seconds)
  • daylightOffset_sec: If you have daylight saving time.

Select the board from the boards manager menu and upload the Code.

Make sure that ESP32 SDK v2.0 is installed (not above that), and FastLED v3.7.0 is installed
Otherwise there might be compilation errors.

Things to take care of:

For the Waveshare ESP32 S3 Mini:

Before uploading the code, make sure the following settings are set:

  • Set the board as ESP32S3 Dev module
  • Set Tools -> USB CDC on Boot to "Enabled"

LED GPIO pins:

If you are using any other GPIOs for the LEDs, make changes in the void setup():

// Digit 1
  FastLED.addLeds<NEOPIXEL, 3>(leds[0], NUM_LEDS_PER_DIGIT);
  // Digit 2
  FastLED.addLeds<NEOPIXEL, 4>(leds[1], NUM_LEDS_PER_DIGIT);
  // Digit 3
  FastLED.addLeds<NEOPIXEL, 5>(leds[2], NUM_LEDS_PER_DIGIT);
  // Digit 4
  FastLED.addLeds<NEOPIXEL, 6>(leds[3], NUM_LEDS_PER_DIGIT);
  //Status LED
  FastLED.addLeds<WS2811, 21, RGB>(statusLED, 1);

Light sensor readings:

Note the minimum and maximum brightness values that the device can observe.
To do so, upload the Arduino IDE Example code ( Examples -> iarduino_APDS9930 -> HardwareWire -> getLight_average.ino ) to the ESP-32, and check the light value for both the darkest and brightest conditions.

Then input them in this part of the code (minLuxValue and maxLuxValue):

float luxFactor           = 50;       // Increase/decrease factor for brightness change (higher - slower reaction to light change)
float luxValue            = 0;        
float minLuxValue         = 0;        // Minimum Lux value (need to experiment)
float maxLuxValue         = 25;      // Maximum Lux value (need to experiment)
uint8_t ledLightValue     = 0;        // Light value used for brightness by FastLEDs
uint8_t minBrightness     = 60;       // Min brightness of the LEDs
uint8_t maxBrightness     = 220;      // Max brightness of the LEDs

The minBrightness and maxBrightness values are the minimum and maximum brightness of the LEDs. You can set them accordingly (maximum 255).

Other Settings:

If you are installing the clock in a relatively accessible spot, I recommend turning the OTA update OFF. This will disable WiFi after it fetches time from NTP at startup. Most of the other settings can be found in this part of the code:

// Configs related to LED Strip
#define NUM_DIGITS            4       // Number of Digits
#define NUM_LEDS_PER_DIGIT    14      // Number of LEDs per digit
#define NUM_SEGMENTS          7       // Number of segments (7 for 7 segment display)
#define NUM_LEDS_PER_SEGMENT  2       // Number of LEDs in each segment
#define SERIAL_DEBUG          true    // true - serial 
#define STATUS_LED            false   // true - enable status led
#define ENABLE_OTA_UPDATE     true    
#define FORMAT_12HR           true
#define FIXED_BRIGHTNESS      250     // Comment for auto brightness adjustment
#define SHOW_FIRST_ZERO       true