Reinvigorating/ recycling a handsome old clock and making it super-accurate, internet optional. Uses a Raspberry Pi Pico and a radio antenna (or a Pico W and no radio antenna) to emulate a signal from a Mother clock. You can define the pulse interval as a parameter, so it works with a broad range of clocks (most take 60 seconds intervals, but some take 30 second or 1 second pulses).
The DCF77 signal is a radio signal that carries information from some Atomic Clocks. The signal covers most of Europe and is accurate to within a second over about 300,000 years (the DCF77 signal has been broadcasting the time since 1973 and in 2021 it was agreed to be continued for at least 10 more years).
The script also has (untested) code for WWVB, the signal used in the United States. To apply WWVB, change the region
parameter in main.py from DCF77
to WWVB
. If you test it and it works, let me know.
(Japan uses JJY. Adding code for this is on the todo list)
A variation that involves WiFi, fewer components, less code and uses a Pico W.
There is no need for a Real Time Clock (RTC) or Ferrite receiver as everything is done with a quick connect to WiFi and uses the Pico's RTC.
To use this variation, save the code in webtime.py
as main.py
on the Pico W. You will also need to save your WiFi login credentials as secrets.py
on the Pico W in the format shown in secrets_example.py
.
- Old 'nebenuhr' clock with secondary mechanism (a mechanism that is controlled by pulses from the mother-clock)
- A ferrite receiver for the DCF77 signal if you're in Europe (or one for the WWVB signal if you're in the US)... Not needed if you're using Pico W
- A microcontroller (Raspberry Pi Pico or Pico W)
- Real time clock (backup for any radio signal issues)... Not needed if you're using Pico W
- H bridge (LN298) or a 2 channel SPDT Relay Switch, for the polarity switch that triggers the clock mechanism. For higher voltage clocks, the relay is the better option
- Step-up module to send correct voltage pulse to the clock (or a dc power supply, as used in the video)
An overview of how the clock works:
How the pieces are assembled:
Assemble the Pico, step up transformer and H bridge. Note that the voltage of the step up tranformer may vary depending on the clock you're using.
The antenna also needs 3.3V power and GND. They were omitted in order to keep the diagram tidy. If you're using the H bridge (rather than a SPDT relay) and are sending more than 12V (we used 24V) to the clock then make sure you remove the 5v jumper from the H-bridge.
Copy the files from this repository
git clone https://github.com/veebch/clock
cd clock
Only if you're running the code on a Pico W and want to sync to time online
mv webtime.py main.py
mv secrets_example.py secrets.py
and edit secrets.py so that it contains your WiFi credentials.
Send the files to your Pico using ampy
ampy -p /dev/ttyACM0 put ./*
Edit the file firstruntime.txt
to show the time that the clock is showing before the first run. This should be the only time you need to do this, the code will keep track of time after power-off.
The code in main.py executes as soon as the Pico is powered on.
If you run while connected to Thonny then you will see the terminal output. On the radio version this shows the signal as it is decoded. If the bars look irregular or have gaps in, then there is an issue with the radio signal. A clear signal will look something like this:
The DCF77 part of the code was based on demogorgi/set-rtc-using-dcf77-via-dcf1.
WiFi version that runs a web server for easy tweaks to the time via smartphone.
GPL 3.0