A Super-Accurate Clock Using A Tiny Microcontroller

DCF77 is a German VLF transmitting station that broadcasts a time signal across Europe on 77.5 kHz. Thus a common sight in a European home is a clock emblazoned with the words “Radio controlled”. With the timing broadcast in a simple and low speed digital format it doesn’t require the greatest of hardware to decode, and a small microcontroller can handle the task with ease. And there are few smaller than an ATtiny as used in [kwolf1909]’s decoder. It takes a DCF77 bitstream from a receiver, and shows the time on an I2C display.

The receiver isn’t part of this project, however a single-frequency longwave receiver is not a difficult thing to build. The interface is a push-button, for which a short press cycles between display modes and a long press triggers a DCF77 reset. It also supports an external temperature sensor and real time clock module, if you’re using an ATtiny with enough pins.

We like this project; it’s simple and does one thing well, and it’s a welcome reminder that not every device needs a powerhouse of a processor. If you’re interested enough to build your own, we’ve featured someone doing a deep dive into the signal before.

18 thoughts on “A Super-Accurate Clock Using A Tiny Microcontroller

      1. In case anyone else is wondering how you get a PRN sequence with an even number of bits, it seems that DCF77 uses a 9-bit LFSR to generate a 511-bit PRN sequence and then add an extra zero into the run of 8 consecutive zeros in that sequence to get 512 bits. I guess the practical benefits of having a nice round number like 512 outweight any downside from messing up the correlation properties of the PRN.

  1. DCF77 was nice, I built my first clock with it fully in Flowcode decision trees. However, at the time I found that I was too far away from Frankfurt which did not always give me reliable results. Also, I was told that back then not to expect these systems to be u for much longer. Now at least twenty years later, DCF77 is still up, as are several other ‘obsolete’ systems.

    1. DCF77 won’t die soon, it broadcasts Germany’s legal time and private data for Swiss Meteo Time GmbH; and it has millions of users in DE and the surrounding countries. Even TDF (Allouis) is still up, with much less users.

    2. You’re right, I think. I also heard people telling strange things.
      How comes that people always think that wireless signals must be obsolete? People are weird.

      Most of us carry cellular phones with us every day, some have FM radio chips built-in, but most have WLAN and Bluetooth.
      Wireless technology is as relevant as ever.

      Yet same time, a highly efficient and connection-less VLF signal that propagates via ground wave and through thick walls isn’t,
      just because it has a long history?

      I sometimes think that people so addicted to the internet that they can’t even comprehend other technologies anymore.
      They think they’re progressive, but in reality they’re close-minded.
      And forget that the internet is not reliable.
      Those Linux/server gurus maybe should think about that once or twice. 😉

      Just like cellphone network the internet access folds the very next time a natural dissaster or power outage occurs.
      An FM radio and a radio-controlled clocks merely needs a battery.
      No registration, no IP address, no tracking, so security issues. It just works.

      Makes me glad that here in Germany we still have satellite TV, FM radio, cash and stationary phones and fax machines. 🩶
      Even though the latter two have to rely on emulation (POTS for analog devices; S0 port for ISDN, replaces NTBA).
      Anyway, the infrastructure in the buildings live on (esp. ISDN PBX systems and devices). 😃
      So people can continue to communicate inside the building no matter what. Internet or not.

      1. VLF is as relevant as ever, at least for military applications, it’s still the only reliable way to communicate with submerged submarines over long distances. And sometimes I wish for a LORAN-capable smartphone, satellite navigation has become quite unstable here in Vienna due to the war in Ukraine, many satellites are jammed or transmit crap. (on the bright side, this spoils google’s data collection).
        btw: ntp is reliable with nanosecond precision if set up correctly with a an additional timesource that doesn’t depend on the internet (which currently excludes GPS in some parts of the world). It’s Microsoft’s implementation that still sucks after three decades.

    3. “A sync to DCF-time is performed in the background every 30 minutes”

      Maybe the EU has better luck with their low-freq time transmitters, but here in the US, I am (extremely) lucky if I can get a daytime time-sync from Colorado here in Georgia.

      Maybe use 2 ATtiny85:
      http://www.insidegadgets.com/2011/10/08/how-to-use-a-32khz-watch-crystal-on-an-attiny85/
      – OR –
      design around a ChronoDot in the project:
      https://www.adafruit.com/product/255

      My preference is to receive time from the GPS satellites overhead:
      “Maple Mini GPS Clock_ Color GLCD and Barometric Graphing”
      http://hackaday.io/project/203859/files

      … but, of course, the STM32F103 is very much out of the league of the AT-tiny.

    1. Awful are the antennas used inside DCF77 clocks. A decent loopstick with a longwave coil from the tube era, tuned to 77.5 kHz and properly oriented can fix that. If you’re far away from Mainflingen, a high-Q shielded and tuned loop antenna can do the trick.

      1. +1

        The honey comb coils (3D) or spider web coils (2D, a beer mat or clear dummy CD)
        are better than ordinary air coils (wire on toilet paper roll).

        https://www.helmutheller.de/~heller/SpiderWebCoil/SpiderWebCoil.html

        https://pe2bz.philpem.me.uk/Comm/-%20Receivers/-%20Crystal/Prj-063-GollumsTowerCoils/honeyc.htm

        A wooden frame antenna is another possibility.
        Crystal radio fans used to use them.
        They can be used to receive SAQ Grimeton, too.

        https://pe2bz.philpem.me.uk/Comm/-%20Receivers/-%20Crystal/Prj-063-GollumsTowerCoils/honeyc.htm

        A long-wire antenna in the garden is another solution.
        It may still need a coil (wire wound around a big plastic trashcan, like those on street) or a matchbox (pi filter).

        The high voltage generated through static charge might be an issue for some receivers.
        A tube based DC receiver might be a solution here.

        1. I’d prefer a shielded (multi-turn) loop for LF made from an old printer cable, that eliminates most electrostatic problems. Still needs some protection circuit, otherwise transients picked up from lightning and other disturbances will fry the input transistor.

  2. I once bought a few of those clocks and put in an ATmega, put it back in it’s original case and powered the thing from 24Vdc (SMPS to 5V, and then a resistor and two diodes to simulate the battery for the clock.

    And then I logged the data. During the day I often have no reception for hours on an end (Netherlands, indoors, cheap antenna and such). But during the night there are often several hours that reception works nearly every minute.

    1. I think the idea is to use the super-accurate radio time to update the time on your fairly accurate RTC (once a day should suffice).

  3. Nice. I was curious about this in the states and looked it up – NIST still does some good stuff here but so much has been degraded (intentionally). It’s 60khz – station WWVB. The goto chip/board is apparently the ES100-MOD. The antenna looks awful.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.