Dcf77
Noise resilient DCF77 decoder library for Arduino
Install / Use
/learn @udoklein/Dcf77README
dcf77 library
Noise resilient DCF77 decoder library for Arduino.
(c) Udo Klein -- http://www.blinkenlight.net
This repository contains a DCF77 decoder library for Arduino. It was designed with the goal to create the most noise resilent decoder possible.
There are also some ready to run examples.
For the details and background information you may want to consult the DCF77 section of my webpage.
The Library itself and its history are documented in my webpage. This page also contains a short FAQ sections. Please read this page first if you encounter any issues with my library.
Attention: the library requires a crystal oscillator. The Arduino Uno comes out of the box with a resonator. Thus it will not work with this library. "Older" designs like the Blinkenlighty have a (more expensive, more stable and more precise) crystal oscillator.
Getting Started
Required components
The first things you will need is DCF77 module and a crystal based Arduino. Attention: the Arduino Uno is NOT crystal based. Although there is a crystal on the board this crystal is not used to clock the main controller. The main controller only has a resonator. Ensure that you have crystal based controller or the library will not work for you.
Wiring it
The output of the DCF77 module must be connected with the "sample pin" on the Arduino side. The sketches usually use digital pin 19 or analog pin 5 (this is actually the same pin). For the Arduino Due the pin is usually digital pin 53.
Some modules require 5 V and some require 3.3 V as a supply voltage. Some other modules can deal with 3.3 to 5 V. Ensure that the supply voltage matches with your Arduino. Look up the datasheet of your module to figure out what it requires.
A lot of modules come with some "enable" pin. Often this pin is labelled "PON" in the datasheet and must be connected to ground. However your mileage may vary. You definitely need to look this up in the datasheet.
Then there are some modules that require a pull up resistor, some others need no pull up resistor and yet some other modules must not used with a pull up. By default my examples will activate the internal pull up resistor which is in the range of 10-50k and connected to VCC. Thus if your module can drive at least 500 μA you are on the safe side. If your module can not drive this there are two options:
-
The module has a push/pull output. (E.g. the well known "Pollin" module). Then disable the internal pullup.
-
The module is open collector but can not drive 500 μA. Then you need to insert a driver or some transistor after your module. Often the datasheet has example circuits on how to achieve this. Otherwise search the net for examples on how to wire the module.
To disable the pull up resistor set 'dcf77_pull_up = 0;' otherwise enable it with 'dcf77_pull_up = 1;'.
Testing it
Once you have everything ready its time to have a look at the signal. This is most conveniently achieved with the DCF77 Scope sketch. This sketch does not use the library. It is included for basic analysis and troubleshooting purposes.
It mimics some an oscilloscope with a timebase of 1 s and a resolution of 10 milliseconds A "-" or "+" indicates that it sampled a logical low. Any digit d indicates that it sampled a logical high for d milliseconds during a sample period of 1 s. The digits are in base 11, 1,2,...,8,9,X. Thus X indicates that the signal was high for 10 ms or 1/100 s.
If everything went right you should see some output on the serial monitor. The connection speed for all but the MB Emulator is 115200.
Analyzing the test output
What you want to achieve is test output that optimally looks like this:
10, +---------+---------+---------+---------4XXXXXXXXXX3--------+---------+---------+---------+---------
11, +---------+---------+---------+---------4XXXXXXXXXX2--------+---------+---------+---------+---------
12, +---------+---------+---------+---------4XXXXXXXXXXXXXXXXXXXX---------+---------+---------+---------
13, +---------+---------+---------+---------2XXXXXXXXXXXXXXXXXXXX---------+---------+---------+---------
14, +---------+---------+---------+---------3XXXXXXXXXXXXXXXXXXX8---------+---------+---------+---------
15, +---------+---------+---------+---------2XXXXXXXXXXXXXXXXXXXX2--------+---------+---------+---------
16, +---------+---------+---------+---------3XXXXXXXXXX1--------+---------+---------+---------+---------
17, +---------+---------+---------+---------3XXXXXXXXXXXXXXXXXXX9---------+---------+---------+---------
18, +---------+---------+---------+---------2XXXXXXXXXX2--------+---------+---------+---------+---------
19, +---------+---------+---------+---------2XXXXXXXXXXXXXXXXXXX9---------+---------+---------+---------
20, +---------+---------+---------+---------4XXXXXXXXXXXXXXXXXXX9---------+---------+---------+---------
21, +---------+---------+---------+---------+XXXXXXXXXXXXXXXXXXXX---------+---------+---------+---------
22, +---------+---------+---------+---------1XXXXXXXXX9---------+---------+---------+---------+---------
You can see the different pulses of the DCF77 signal and there is no noise interferring with the signal. Also the signal is in phase. There is little to none local clock drift.
What you do not want to see is the signal below.
3, +---------+---------+---------+---------+---------+----2XXXXXXXXXX3---+---------+---------+---------
4, +---------+---------+---------+---------+---------+----5XXXXXXXXX8----+---------+---------+---------
5, +---------+---------+---------+---------+---------+----6XXXXXXXXXX4---+---------+---------+---------
6, +---------+---------+---------+---------+---------+----3XXXXXXXXXX1---+---------+---------+---------
7, +---------+---------+---------+---------+---------+-----XXXXXXXXXX1---+---------+---------+---------
8, +---------+---------+---------+---------+---------+----5XXXXXXXXXXXXXXXXXXXX1---+---------+---------
9, +---------+---------+---------+---------+---------+---2XXXXXXXXXXXXXXXXXXXXX----+---------+---------
10, +---------+---------+---------+---------+---------+---1XXXXXXXXXXXXXXXXXXXX1----+---------+---------
11, +---------+---------+---------+---------+---------+---5XXXXXXXXX9-----+---------+---------+---------
12, +---------+---------+---------+---------+---------+---8XXXXXXXXXXXXXXXXXXX3-----+---------+---------
13, +---------+---------+---------+---------+---------+---3XXXXXXXXXX2----+---------+---------+---------
14, +---------+---------+---------+---------+---------+---1XXXXXXXXXXXXXXXXXXX7-----+---------+---------
15, +---------+---------+---------+---------+---------+---5XXXXXXXXXX2----+---------+---------+---------
16, +---------+---------+---------+---------+---------+---XXXXXXXXXX4-----+---------+---------+---------
17, +---------+---------+---------+---------+---------+--5XXXXXXXXXXXX3---+---------+---------+---------
18, +---------+---------+---------+---------+---------+--5XXXXXXXXXXXXXXXXXXXX------+---------+---------
19, +---------+---------+---------+---------+---------+---XXXXXXXXX9------+---------+---------+---------
20, +---------+---------+---------+---------+---------+--3XXXXXXXXXX1-----+---------+---------+---------
21, +---------+---------+---------+---------+---------+--4XXXXXXXXX9------+---------+---------+---------
22, +---------+---------+---------+---------+---------+--4XXXXXXXXXXXXXXXXXXX6------+---------+---------
23, +---------+---------+---------+---------+---------+--8XXXXXXXXX3------+---------+---------+---------
24, +---------+---------+---------+---------+---------+--9XXXXXXXXXXXXXXXXXXX4------+---------+---------
25, +---------+---------+---------+---------+---------+-3XXXXXXXXXXXXXXXXXXXX5------+---------+---------
26, +---------+---------+---------+---------+---------+-3XXXXXXXXX9-------+---------+---------+---------
27, +---------+---------+---------+---------+---------+--XXXXXXXXXX-------+---------+---------+---------
28, +---------+---------+---------+---------+---------+-2XXXXXXXXXXXXXXXXXXX5-------+---------+---------
29, +---------+---------+---------+---------+---------+-3XXXXXXXXX8-------+---------+---------+---------
30, +---------+---------+---------+---------+---------+-5XXXXXXXXX9-------+---------+---------+---------
31, +---------+---------+---------+---------+---------+-4XXXXXXXXX6-------+---------+---------+---------
32, +---------+---------+---------+---------+---------+2XXXXXXXXXX5-------+---------+---------+---------
33, +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------
34, +---------+---------+---------+---------+---------+-9XXXXXXXXX--------+---------+---------+---------
35, +---------+---------+---------+---------+---------+3XXXXXXXXX9--------+---------+---------+---------
36, +---------+---------+---------+---------+---------+6XXXXXXXXXXXXXXXXXXXX3-------+---------+---------
37, +---------+---------+---------+---------+---------+7XXXXXXXXX7--------+---------+---------+---------
38, +---------+---------+---------+---------+---------+6XXXXXXXXX9--------+---------+---------+---------
39, +---------+---------+---------+---------+---------+6XXXXXXXXX4--------+---------+---------+---------
40, +---------+---------+---------+---------+---------3XXXXXXXXXX2--------+---------+---------+---------
It indicates that the received signal is clean but your local clock drifts way to much. (In this case DCF77 seems to be slow. However since DCF77 is accurate by definition the local clock must be to fast. A drift in the other direction would indicate the local clock as to
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
