I bought some dcf77 modules in Germany from Pollin.
I have the idea from Thijs Elenbaas
and i wanted it to try it out. In the script you can find the location of the libraries. I used in this script on of his
example script and added a DS3132 rtc module from ebay for storing the time and i attached a 6-digit 7-segment display
controlled by a max7219 led driver chip (see script for library location).
dcf77_clock.ino
/*
* InternalClockSync.pde
* example code illustrating time synced from a DCF77 receiver
* Thijs Elenbaas, 2012
* This example code is in the public domain.
This example shows how to fetch a DCF77 time and synchronize
the internal clock. In order for this example to give clear output,
make sure that you disable logging from the DCF library. You can
do this by commenting out #define VERBOSE_DEBUG 1 in Utils.cpp.
*/
#include <Wire.h>
//#include <SPI.h>
#include "max7219.h" //https://github.com/Rene65/max7219
#include "DCF77.h" //https://github.com/thijse/Arduino-DCF77
#include "TimeLib.h"
#include "RTClib.h"
#define DCF_PIN 2 // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0 // Interrupt number associated with pin
RTC_DS3231 rtc;
/*
Now we need a max7219 to work with.
***** These pin numbers will probably not work with your hardware *****
pin 7 is connected to the DataIn (DIN)
pin 6 is connected to the CLK (CLK)
pin 5 is connected to LOAD (CS)
We have only a single MAX72XX.
*/
#define NBR_MTX 1 //Number of displays
MAX7219 max7219=MAX7219(7,6,5, NBR_MTX);
time_t time;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);
unsigned long lastupdate = now();
unsigned long currenttime = now();
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
Serial.begin (9600);
DCF.Start();
if (! rtc.begin()) {
Serial.println("RTC is NOT running.");
} else {
Serial.println("RTC is running.");
DateTime now = rtc.now();
setTime(now.unixtime()); //Set system clock from ds3231 once.
}
for (int i=0; i< NBR_MTX; i++){
max7219.shutdown(i,false);
/* Set the brightness to a high value */
max7219.setIntensity(i,15);
/* and clear the display */
max7219.clearDisplay(i);
}
delay(100);
max7219.clearAll();
}
void loop(){
time_t DCFtime = DCF.getTime(); // Check if new DCF77 time is available
if (DCFtime!=0)
{
Serial.print("DCF77 has set the system clock on ");
setTime(DCFtime);
rtc.adjust(DCFtime); //Set ds3231 from system clock.
lastupdate = now();
currenttime = now();
unsigned long lastupdateHour = hour(lastupdate);
unsigned long lastupdateMinute = minute(lastupdate);
unsigned long lastupdateSecond = second(lastupdate);
unsigned long lastupdateYear = year(lastupdate);
unsigned long lastupdateMonth = month(lastupdate);
unsigned long lastupdateDay = day(lastupdate);
if (lastupdateHour<10) Serial.print("0");
Serial.print(lastupdateHour);
Serial.print(":");
if (lastupdateMinute<10) Serial.print("0");
Serial.print(lastupdateMinute);
Serial.print(":");
if (lastupdateSecond<10) Serial.print("0");
Serial.print(lastupdateSecond);
Serial.println(".");
}
unsigned long newHour = hour();
unsigned long newMinute = minute();
unsigned long newSecond = second();
unsigned long newYear = year();
unsigned long newMonth = month();
unsigned long newDay = day();
int hour1 = (newHour%10);
int hour10 = (newHour/10);
int minute1 = (newMinute%10);
int minute10 = (newMinute/10);
int second1 = (newSecond%10);
int second10 = (newSecond/10);
int year1 = (newYear%10);
int year10 = ((newYear/10)%10);
int year100 = ((newYear/100)%10);
int year1000 = (newYear/1000);
int month1 = (newMonth%10);
int month10 = (newMonth/10);
int day1 = (newDay%10);
int day10 = (newDay/10);
max7219.setDigit(0,2,hour10,false);
max7219.setDigit(0,3,hour1,false);
max7219.setDigit(0,4,minute10,false);
max7219.setDigit(0,5,minute1,false);
max7219.setDigit(0,6,second10,false);
max7219.setDigit(0,7,second1,false);
delay(500);
}