Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsAn ESP32 can ask an internet time server for the current time, so a clock needs no RTC chip and never drifts. The sketch uses the built-in configTime function with the Indian time zone, which is UTC plus 5 hours 30 minutes with no daylight saving. The 0.96 inch OLED shows the time in large digits and the date underneath. Because it re-syncs automatically, it stays right through power cuts.
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 or power bank.
ntp_clock.inoVerify & upload in Electrolark#include <WiFi.h>
#include <time.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const char* WIFI_NAME = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void setup() {
Wire.begin(21, 22);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
oled.clearDisplay(); oled.setTextColor(WHITE); oled.setTextSize(1);
oled.setCursor(0, 0); oled.println("Connecting..."); oled.display();
WiFi.begin(WIFI_NAME, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) delay(300);
configTime(5 * 3600 + 1800, 0, "pool.ntp.org", "time.google.com"); // India: UTC+5:30
}
void loop() {
struct tm t;
if (getLocalTime(&t)) {
char hm[8], sec[4], date[20];
strftime(hm, sizeof(hm), "%H:%M", &t);
strftime(sec, sizeof(sec), "%S", &t);
strftime(date, sizeof(date), "%a %d %b %Y", &t);
oled.clearDisplay();
oled.setTextSize(4); oled.setCursor(4, 8); oled.print(hm);
oled.setTextSize(2); oled.setCursor(100, 44); oled.print(sec);
oled.setTextSize(1); oled.setCursor(0, 54); oled.print(date);
oled.display();
}
delay(500);
}
Try address 0x3D, check SDA and SCL, and make sure the OLED is powered from 3V3.
Check the offset in configTime: 5 hours 30 minutes is 19800 seconds for India.
It is waiting for the first NTP reply. Check that your router allows outgoing UDP port 123.
Not while Wi-Fi is available. For a clock that must work without Wi-Fi, add a DS3231 module.
Yes. Change the strftime format from %H to %I and add %p.
India has none, so the fixed offset is correct.
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 45 minutes. The build on this page has 5 steps.
No. This page has the complete, tested code (ntp_clock.ino).
About ₹595 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Getting the time over NTP on an ESP32; Handling a time zone offset; Drawing text on an SSD1306 OLED.
Ideas that reuse this build: ESP32 MQTT temperature dashboard. 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.