Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsThe Pico has an internal clock but no battery, so it forgets the time every power-up. The Pico W solves this by asking an internet time server for the time at start-up using MicroPython's ntptime module. The sketch adds the Indian offset of five hours thirty minutes and shows the time and date on a 0.96 inch OLED. India has no daylight saving, so the offset is fixed.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power adapter.
main.pyimport network, time, ntptime, machine
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
SSID = "YOUR_WIFI"
PASSWORD = "YOUR_PASSWORD"
OFFSET = 5 * 3600 + 30 * 60 # India: UTC+5:30
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
def show(*lines):
oled.fill(0)
for i, t in enumerate(lines):
oled.text(t, 0, i * 12)
oled.show()
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(SSID, PASSWORD)
show("Connecting...")
while not wlan.isconnected():
time.sleep(0.5)
last_sync = 0
while True:
if time.time() - last_sync > 3600 or last_sync == 0:
try:
ntptime.settime() # sets the RTC to UTC
last_sync = time.time()
except OSError:
pass
y, mo, d, h, mi, s, wd, _ = time.localtime(time.time() + OFFSET)
show("%02d:%02d:%02d" % (h, mi, s), "%s %02d-%02d-%d" % (DAYS[wd], d, mo, y))
time.sleep(0.5)
Check the I2C wires and that the driver is installed. Address 0x3C is the usual one.
The sync worked but the offset was not applied; check the OFFSET line.
The Pico W has no internet. Check the Wi-Fi password and that the router allows NTP (UDP port 123).
Not while Wi-Fi is on. For a clock that works without Wi-Fi, add a DS3231 module.
Yes. Use h % 12 and show AM or PM.
India has none, so the fixed offset is right.
4 parts: Raspberry Pi Pico W Microcontroller 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 (main.py).
About ₹885 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Setting the RTC from NTP; Applying the Indian time zone offset; Drawing text on an SSD1306 OLED in MicroPython.
Ideas that reuse this build: ESP32 OLED internet 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.