Converting a $3.88 analog clock from Walmart into a ESP8266-based Wi-Fi clock

Published: (February 9, 2026 at 11:26 AM EST)
3 min read

Source: Hacker News

Introduction

This project uses a WEMOS D1 Mini ESP8266 module and an Arduino sketch to connect to an NTP (Network Time Protocol) server to automatically retrieve and display the local time on an inexpensive analog quartz clock. The ESP8266 reconnects to the NTP server every 15 minutes, keeping the clock accurate, and automatically adjusts for daylight‑saving time.

Clock face
Clock back

WEMOS D1 Mini ESP8266 Module with EERAM IC and components on a piece of perfboard

Schematic

Animated clock

Hardware

I’m using an analog clock with a quartz movement I found at my local Walmart for $3.88. Whatever analog clock you choose, its quartz movement must be modified so that it can be controlled by the ESP8266 module.

  1. Open the movement (most snap together without fasteners).
  2. Disconnect the internal coil of the Lavet stepping motor from its quartz oscillator.
  3. Solder a wire to each of the coil’s leads to make connections for the ESP8266.

The coil wires are typically thinner than a human hair and extremely fragile, so handle them with care. Articles showing similar modifications can be found by searching the web.

Modified clock movement

Software

The sketch AnalogClock.ino operates as follows:

  • Ten times each second the ESP8266 compares the time displayed on the analog clock to the actual time retrieved from an NTP server.
  • If the analog clock lags, the ESP8266 advances the second hand until the clock matches the actual time.
  • If the analog clock is ahead, the ESP8266 waits for the actual time to catch up (the hands cannot be moved backwards).

The ESP8266 advances the second hand by generating bipolar pulses (alternating positive and negative) to the Lavet motor coil. Because mechanisms vary, you may need to adjust the PULSETIME constant in the sketch by a few milliseconds. For the author’s movement, 30 ms worked best.

Storing Hand Positions

Cheap analog clocks provide no feedback on hand position. If power is lost, the ESP8266 “forgets” the current positions. To solve this, the positions of the hour, minute, and second hands are stored in a Microchip 47L04 Serial EERAM (4 Kbit SRAM with EEPROM backup) and updated each second.

On the first run, the ESP8266 serves a simple web page that lets the user set the initial hand positions. After that, the stored values are used to “remember” the clock’s state.

Setup page

Arduino Serial Monitor during startup

Status Page

Once initialized, the ESP8266 serves a status page showing the clock’s current state. The page can display:

  • An SVG rendering of the clock face
  • An HTML Canvas rendering
  • Text‑only output

Status page – SVG

Status page – Canvas

Status page – Text only

0 views
Back to Blog

Related posts

Read more »