Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsThe ESP32 can fetch the real date and time from an internet time server, so no clock module is needed. The sketch converts your target date into a time stamp and subtracts the current time. The OLED shows days remaining in large digits with hours and minutes below. Good for exam days, festivals or a launch day. Indian time has a fixed offset of five hours thirty minutes and no daylight saving.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB phone charger.
countdown.inoVerify & upload in Electrolark#include <WiFi.h>
#include <time.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
const char* SSID = "YOUR_WIFI";
const char* PASS = "YOUR_PASSWORD";
const int TARGET_YEAR = 2027, TARGET_MONTH = 3, TARGET_DAY = 1;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void setup() {
Wire.begin(21, 22);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) delay(300);
configTime(19800, 0, "pool.ntp.org"); // UTC+5:30, no daylight saving
}
void loop() {
struct tm now;
if (getLocalTime(&now)) {
struct tm target = {};
target.tm_year = TARGET_YEAR - 1900;
target.tm_mon = TARGET_MONTH - 1;
target.tm_mday = TARGET_DAY;
long secs = (long)difftime(mktime(&target), mktime(&now));
oled.clearDisplay(); oled.setTextColor(WHITE);
if (secs <= 0) {
oled.setTextSize(2); oled.setCursor(0, 20); oled.print("It's today!");
} else {
long days = secs / 86400, hrs = (secs % 86400) / 3600, mins = (secs % 3600) / 60;
oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Days to go");
oled.setTextSize(4); oled.setCursor(0, 16); oled.print(days);
oled.setTextSize(1); oled.setCursor(0, 54); oled.printf("%ldh %ldm", hrs, mins);
}
oled.display();
}
delay(10000);
}
getLocalTime waits for the first NTP sync, usually a few seconds.
The count runs to midnight at the start of the target day.
Check the I2C wires.
No, it re-syncs from the internet each start.
Yes, switch between them with a button.
It will not update until it reconnects. Add a DS3231 module for an offline clock.
4 parts: ESP32-WROOM-32 38-Pin Development Board, 0.96" OLED Display 128x64, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 1 hour. The build on this page has 6 steps.
No. This page has the complete, tested code (countdown.ino).
About ₹595 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Getting time with configTime and getLocalTime; Using mktime to turn a date into a time stamp; Calculating days, hours and minutes left.
Ideas that reuse this build: ESP32 NTP alarm clock. They are listed under Take it further on this page.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Learning project. Check every circuit and the datasheet of each part before you power it up.