DCF-77 clock receiver

The Playground has an interesting article and source code to make use of a DCF-77 clock receiver for Arduino.

I recently decided to try it out, and I got it working quite fast.
However, from my location it seems like it is very important that the antenna is lying in the right direction, or I wouldn’t get a clear signal.

I noticed that in my case, the long intervals were often interrupted for a very short time, causing the library to detect it as 2 signals rather than one.

This means that it takes a lot longer to get an accurate clock signal, but also that the clock counts drifts further from the actual position because without a new correct clock sometimes 2 seconds would be added instead of one.

By making some very small changes to the library I’ve managed to make it work a lot better for me, so I hope that my update is useful for other people as well.
I’ve also sent an e-mail to the author of the library, so maybe he will update the library too.

Here’s the change to DCF77.cpp in scanSignal():

/* We detected a raising flank, increase per one second! */
int thisFlankTime=millis();

if (thisFlankTime - previousFlankTime > 300)
#ifdef DCF_DEBUG
if (thisFlankTime - previousFlankTime > DCF_sync_millis) {
#ifdef DCF_DEBUG
      Serial.println("#### Begin of new Minute!!!");
} else if (thisFlankTime - previousFlankTime < 300) {
#ifdef DCF_DEBUG
      Serial.println(": Double flank detected");
      if (bufferPosition < 0)
            bufferPosition = 0;
if (thisFlankTime - previousFlankTime > 300)
#ifdef DCF_DEBUG
Serial.print(": DCF77 Signal detected, ");

So basically, I assume that there has to be 1 second between 2 rising flanks, so if it is less than 0.3 seconds it is probably not correct, and I ignore that flank and wait for the next falling flank to update the current buffer position.


Has your code been added to the library? It looks like that but the code I have downloaded ( Arduino DCF77 decoder v0.2.1) is quite different from suggestions.