Time synchronisation under Linux with DCF77 radio clock module in ntpd
Linux systems can obtain time information via the Internet using the Network Time Protocol (NTP) and the NTP service ntpd, thereby keeping the local system time up to date. If a system does not have network access, a PC radio clock with USB interface can be used for time synchronization. In this article, we present the configuration of such a radio clock using the example of a Expert Mouse Clock USB II 0107 under Ubuntu 16.04 with Linux kernel 4.4 on a LES v3.
Hardware installation and alignment of antenna

The radio clock module is directly connected with an USB port of the Linux system. As soon as the module receives power via the USB interface, it starts to pick up the bits of the DCF77 radio signal [1] on longwave from the computer independently (77,5 kHz).
For the best possible reception, please note the following:
- Electromagnetic interference from nearby power supplies, CRT monitors, electric motors, other electrical devices, or metal plates can significantly disrupt radio/longwave signals. Therefore, the radio clock module should not be located near such devices.
- The spatial alignment of the module to the transmitter is very important. The module receives long-wave signals from the Mainflingen transmitter via the built-in ferrite antenna.[2] A horizontal and perpendicular alignment to the transmitter location is highly recommended.[3] This ensures that the best possible signal strength is achieved on the module.
- Status of operating LED: If the operating LED blinks irregularly fast on the module, the radio connection is disrupted. In this case, no time synchronisation is possible. During normal operation, the LED flashes slowly, alternating between red and green every second.
Set up time server NTP daemon
The ntp daemon supports multiple radio clock modules including the Expert Mouse Clock USB II 0107 module used in the test.
The NTP daemon is installed under Ubuntu via apt:
sudo apt install ntp
In order for the module to be addressed by the NTP daemon, the configuration file /etc/ntp.conf must be modified as follows (for example via nano /etc/ntp.conf):
driftfile /var/lib/ntp/ntp.drift server 127.127.8.0 mode 19 prefer logfile /var/log/ntp logconfig =all
The supposed network address 127.127.8.0 is not an IP address, but a stored pseudo IP. The first part "127.127.8" refers to the generic reference driver.[4] The rear part "0" refers to the device under which the radio clock module is addressed. (/dev/refclock-0).
Set up udev rule
To automatically create the device file /dev/refclock-0 for the radio clock module at system startup, a udev rule is required. The USB ProductID is required to set up the rule that can be requested via lsub:
tk@testsystem:~$ lsusb [...] Bus 001 Device 004: ID 0403:e88a Future Technology Devices International, Ltd Expert mouseCLOCK USB II [...] tk@testsystem:~$
Now, the respective rule (for example via sudo nano /etc/udev/rules.d/05-DCF77.rules) can be created with the following content in the /etc/udev/rules.d/ folder:
KERNEL=="ttyUSB*", ATTRS{idProduct}=="e88a", SYMLINK+="refclock-0"
This creates a symbolic link /dev/refclock-0 for the USB device with the ProductID e88a.
The link is then available by calling sudo udevadm trigger:
$ ls /dev/r* /dev/random /dev/refclock-0 /dev/rfkill /dev/rtc /dev/rtc0
Configure AppArmor

AppArmor must be configured accordingly so that the NTP daemon can access the serial USB TTY interface bound to "/dev/refclock-0".
Use "sudo nano /etc/apparmor.d/tunables/ntpd" to set the following entry (comment out other devices):
@{NTPD_DEVICE}="/dev/ttyUSB*"
After this, it is recommended to perform a reboot of the system to verify the correct functionality after a restart.
Verification of the DCF77 module functionality
The function of the module can be verified with the following command:
ntpq -c cv -c rv
Example output after a short runtime:
associd=0 status=0020 2 events, clk_unspec, device="RAW DCF77 CODE (Expert mouseCLOCK USB v2.0)", timecode="---#-#-#-#####---D--S12--1--P1----2p1--8-2-241--8----81---P", poll=4, noreply=0, badformat=1, baddata=0, fudgetime1=425.000, stratum=0, refid=DCFa, flags=0, refclock_time="df5a4d5e.00000000 Sat, Sep 29 2018 19:13:34.000", refclock_status="DST; TIME CODE; (LEAP INDICATION; CALLBIT)", refclock_format="RAW DCF77 Timecode", refclock_states="*NOMINAL: 00:01:35 (42.98%); BAD FORMAT: 00:02:06 (57.01%); running time: 00:03:41" associd=0 status=c218 leap_alarm, sync_lf_radio, 1 event, no_sys_peer, version="ntpd 4.2.8p4@1.3265-o Fri Jul 6 20:10:51 UTC 2018 (1)", processor="x86_64", system="Linux/4.4.0-135-generic", leap=11, stratum=1, precision=-22, rootdelay=0.000, rootdisp=453.861, refid=DCFa, reftime=df5a4d41.5497ee34 Sat, Sep 29 2018 21:13:05.330, clock=df5a4d5f.07b18724 Sat, Sep 29 2018 21:13:35.030, peer=11255, tc=6, mintc=3, offset=0.000000, frequency=0.000, sys_jitter=8.319076, clk_jitter=5.563, clk_wander=0.000
In the above example, the module needs several minutes to perform a complete time synchronization in poor reception conditions. The poor reception conditions can be seen in the following line:
refclock_states="*NOMINAL: 00:01:35 (42.98%); BAD FORMAT: 00:02:06 (57.01%); running time: 00:03:41"
The following screenshot shows the output with optimal alignment of the integrated ferrite antenna (NOMINAL 99,32%, BAD 0,67% with approx. 13 hours of runtime):
References
- ↑ DCF77 (de.wikipedia.org)
- ↑ Transmission stations in Mainflingen (de.wikipedia.org)
- ↑ Spread of DCF77 Signalt (file:Dcf weite.jpg) (de.wikipedia.org)
- ↑ Generic Reference Driver (doc.ntp.org)
|
Author: Wilfried Seifert Wilfried Seifert, working in the Systems Engineering department at Thomas-Krenn, is responsible for system/prototype development in his work area. LPIC 3 certified, deals with construction / programming of embedded / GPIO systems; in his spare time he likes to repair old home computers, attends Linux conferences or is on the road with his bike (MTB) for sporting compensation.
|
|
Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.
|


