Simple WiFi NTP desktop clock with a large 7-segment display. Built on Raspberry PI Zero.
With LED dot NTP synchronization indicator...
- Computers and mobile devices have been using NTP, GSM/GPRS, GPS/GNSS to synchronize time for decades. Desktop / wall and alarm clocks still live in 19th century.
- Changing time twice a year due to retarded DST sucks ass.
- I want to have an indication to see if the time is accurate (synchronized) or not.
- Maybe I want to have Stratum 1 desktop clock.
- Raspberry PI Zero with WiFi and GPIO Headers
- Adafruit 1.2" 7-Segment Display with I2C Backpack
- Breadboard Wires
- Optional Abelectronics RTC Pi Backup Hat
- Optional Adafruit VEML7700 Lux Sensor
- USB power supply and cable
- Case, either 3D printed or make your own
- Screen, Size: 120 x 50 x 3mm
- RPi
3.3V
to 7-Segment DisplayIO
(V_IO) - RPi
5V
to 7-Segment Display+
(+5V) - RPi
GND
to 7-Segment Display-
(GND) - RPi
SCL
to 7-Segment DisplayC
(SCL) - RPi
SDA
to 7-Segment DisplayD
(SDA)
RTC is not required and almost never used while using NTP. However in case of power loss AND internet/wifi/router not being up before Raspberry PI boots, you will get time from fake-hwclock, which is no use. RTC backup will make your time accurate in this rare circumstance.
There are many RTC backup modules available on the market, this one is Pi Zero sized.
Install RTC Hat between PI GPIO and wires going to the display. Make sure you install the coin battery before powering it on. The vendor warns that operation without battery will damage the board. Follow instructions below for software setup.
A complete overkill but you can also get time from:
- GSM tower via NITZ (no paid subscription required)
- GSM network location (CLBS / CIPGSMLOC)
- GPRS network location (AGPS)
- GNSS/GPS/COMPASS/etc. GPS based time
You can use one of these hats or similar. MAX-M8Q has passthrough GPIO and awesome Raspberry PI and NTP setup instructions.
GSM/GPRS time penetrates buildings like normal cell phone. GPS requires an open sky access but is less dependent on ground infrastructure.
Rpiclock is set to change brightness based on time of day. A more advanced case would be to use a I2C based Lux sensor to measure ambient light and change display brightness based on input from the sensor. Example sensor VEML7700.
Download and 3D Print rpiclock.stl or design your own case.
-
Linux. The ubiquitous Raspberry Pi OS (formerly Raspbian) is quite of a bloat and slow to boot but otherwise works pretty well. Disable wait for network to speed up boot. Faster options are Alpine, piCore or instant-pi.
-
FreeBSD - maybe. Super slow to boot and no wlan support on rpi zero.
-
NetBSD - no wlan support.
-
Plan 9 - https://periph.io/ is not supported
Check if Raspberry PI is not experiencing low voltage. You can run vcgencmd get_throttled
, it should return 0x0
.
Make sure I2C interface is enabled. On Raspbian this is done using raspi-config
under Interface Options
. Run i2cdetect -y 1
. It should show value 70
on position 70
.
Make sure to configure WiFi, Locale, Timezone and DST. On Raspbian this is done using raspi-config
.
A real NTP daemon supporting RFC5905 is required to be able to get leap indicator and show whether the clock is synchronised or not. You can still use rpiclock without NTP but it will not show the status.
$ apt install ntp
Skip this if not using an RTC HAT.
RTC/hwclock also depends on which OS you are using. Following instructions are for Raspbian:
$ sudo apt install i2c-tools
$ sudo apt remove fake-hwclock
$ sudo echo dtoverlay=i2c-rtc,ds1307 >> /boot/config.txt
$ sudo echo rtc-ds1307 >> /etc/modules
$ sudo echo '5 * * * * * root /sbin/hwclock -w' >> /etc/crontab
Edit /lib/udev/hwclock-set
, remove following lines:
if [ -e /run/systemd/system ] ; then
exit 0
fi
Reboot, check if hwclock works:
$ i2cdetect -y 1
should show UU
on position 68
.
$ sudo hwclock -r
$ sudo hwclock -w
Download the binary from Releases.
If using systemd
Download Service File and move in to ~/.config/systemd/user/rpiclock.service
. Make sure the right path to the binary is specified.
$ loginctl enable-linger $USER
$ systemctl --user daemon-reload
$ systemctl --user enable --now rpiclock.service
- This is not an officially supported Google product.
- Copyright © 2021-2023 Google LLC