This is the code for a wordclock which runs on an ESP32 with WiFi functionality. It uses the Arduino framework.
The code is written to work on a clock with a Dutch layout. For other languages the code for displaying the time, in showtime.cpp, (and the front plate of the clock of course) need to be adapted.
- Display a word clock with words for every five minutes.
- Display one LED for each minute after the five minutes. So 19 past one would display as a quarter past one and four additional lights.
- Synchronize with a time server at boot and every five minutes. This also ensures summer and winter time is set correctly. (this may be considered as too often but did fix a few issues with incorrect times being shown)
- Change brightness depending on the brightness of the surroundings. Brightness is lower in a dark environment.
- Run a local webserver for the following functions:
- Show a webpage in a browser (see image below)
- Show current brightness level.
- Change color of the LEDs (startup color is the default color, not the last set).
- Display a glass of beer.
- Run animations:
- Filling wine glass.
- Filling cocktail glass.
- stroboscope effect (hidden effect, not selectable in the web interface). Use <ipaddress>/strobo to see it.
- Display a test pattern (actually, set all LEDs to green) for checking functions. This is also a hidden effect, you need to change the url manually to <ipaddress>/test to see it.
- ESP32 development board (any should do, I used a Esspressiv ESP32 DevKitC V4)
- WS2812B LED strip, 10 x 11 + 4 LEDs = 114 LEDs (I used a 144 LED strip and cut it to size)
- 5V power supply capable of delivering at least 2A, a regular phone charger (more is better, if you want maximum brightness)
- Light sensor (Just a simple LDR will do)
- Miscellaneous: wires, soldering iron, front plate with laser cutted openings for the words, structure to hold everything together.
- PlatformIO IDE (extension for VSCode)
- Arduino framework for ESP32
- Libraries:
- FastLED: LED strip control.
- WiFi: ESP32 Wi‑Fi support.
- LittleFS: onboard filesystem for data assets. (use
platformio run --target uploadfsto upload files to the ESP32 LittleFS, these are not part of the standard PlatformIO Upload routine) - WebServer: Arduino synchronous web server (served files with server.streamFile() / serveStatic()).
- time / libc time functions: configTime() / getLocalTime() / setenv/tzset for NTP/timezone handling.
- Procedure to connect to WiFi access point through web interface when no saved access point is available (currently you need to hardcode your SSID and password in the code). See here.
The final clock. As mentioned, it is in Dutch. Also the design is the first prototype. Can be improved with, for example, a steel or glass plate. This is 3 mm plywood with laser cutted openings. Other improvements are in the design of structure behind the front plate, to allow more light to go outside and to prevent 'leakage' to other letters.
This is the webinterface on a mobile device:

