How an internet-synced clock actually works

A £6 microcontroller, a two-wire display, and a protocol from 1985 that is still how almost everything knows what time it is.

The microcontroller

An ESP8266 is a 32-bit processor with a Wi-Fi radio on the same die, which is why it costs a few pounds rather than a few tens. It runs your code directly with no operating system underneath.

Joining the network

On boot it associates with your Wi-Fi and gets an address by DHCP. Until that succeeds it has no idea what time it is — there is no battery-backed clock inside.

Asking the time

It sends an NTP packet to a time server and gets back the number of seconds since 1900. NTP corrects for the round trip, which is why it is accurate to milliseconds over a link that is not.

Turning that into a local time

Seconds since an epoch are not a wall clock. Applying your timezone and its daylight-saving rule is a separate step, and getting it wrong is the commonest bug in this build.

Driving the display

The OLED is addressed over I²C: two wires, one for data and one for a clock signal, shared by every device on the bus. The controller holds the pixel buffer and you push updates to it.

Where this comes from

Espressif ESP8266EX datasheet; RFC 5905 — Network Time Protocol version 4. Every stage above is marked with how confident we are in it, and an uncertain one says so rather than reading like the rest.

Questions

How is esp8266 network clock made?

A Wi-Fi clock that sets itself from the internet: a microcontroller, a small display, and a power supply that is already safe. The stages above set it out at the curious adult level.

Can I build this myself?

Yes — the bill of materials lists 4 parts and roughly what they cost. Anything on the refusal list is not here at any depth.