Arduino LCD Master Clock




This clock is designed as a stand alone clock or as a master clock to drive slave clocks and is portable with battery backup. See the clock's website for further details LCD Master Clock Home Page

Update- Automatic Summer advance and Winter Retard button added to the version using Udo Klein's DCF77 library. Press button once to watch the clock advance or Retard 1 hour.

This clock uses an Arduino 328 Microprocessor to decode Time from the DCF77 "Atomic" Clock in Mainflingen near Frankfurt Germany. Time is displayed on a modified skeleton clock controlled by the microcontroller and a Blue 4x20 LCD display. Clock pulses to drive slave dials are monitored on an LED panel. 3 x 1.5volt AA cells provide battery backup when disconnected from the mains. The main board has a USB to UART connector so the clock software can be updated from a PC or even a Mac. Serial code is included for monitoring over the USB but is commented out.

Updated code included to run Udo Klein's DCF77 library. Udo Klein's DCF77 library keeps the clock in sync and keeps perfect time even with a massive amount of noise on the received DCF77 signal. The DCF77 library also continually "Auto Tunes" the quartz crystal so in the rare event the signal can't be decoded the clock remains accurate within 1 sec over many days. This is crucial for a Master clock that drives 1 second slaves as seconds drift will cause the slave clocks to lose sync with the Master Clock time.

Code for the standard library is also included if you have a very good DCF77 signal.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Making the Case

The case is a modified BORRBY candle lantern from Ikea.

The case is modified as follows:

1 Drill out the welds holding the top to the main frame

2 Remove the top

3 Cut out the ventilation grill on the front to make space for the LCD display

4 Cut wood or metal sheet to fill the ventilation grills that remain

5 Fill gaps between base and frame with wooden strips. The base circuit board sits on this wood. Remove candle spike from base and add four feet.

6 Add a new plywood top and fix with hinges a the back. A recess will need to be cut in the top to take the top of the LCD circuit board that protrudes from the base.

7 Add a handle and cut a hole in the base for the cables.

8 Fix LCD display in cutout

9 Fix Skeleton Clock movement by suspending from top

10 Slide in PCB and LED display panel

Step 2: LCD Display Using Udo Klein's DCF77 Library

The LCD display has the following specs.
· Operating voltage: 5V· Alphanumeric character set· 4 lines of 20 characters· Blue Backlight· Module size: 98 x 60 x12mm· Display size: 75 x 25mm· I2C 2-wire connection· Built-in Contrast Adjustment

LCD Display using Udo Klein's DCF77 Library

The code uses a PIR movement detector to turn the LCD display on and off. This Library is able to decode the DCF77 signal even if it contains a massive amount of noise. The library also "auto tunes" the Arduino Quartz crystal in the rare event the DCF77 signal is lost (no backup RTC required). For this Library to work your Arduino must use a Quartz crystal as a timebase not a problem if you build your own Arduino as I have. If you are using an Arduino Uno a Quartz crystal can be added my modding the UNO board. See how to do it here Mod standard Uno

Row 1 always shows the current time and date
Row 2 Clock Name, also shows the makers name and software version number. Row 2 then switches to show Slow and Fast 1 second pulses.

As this clock drives other slave clocks as well as the built in analogue display this row monitors the main decoded display and it detects a jump in the seconds backwards or forwards. These will be shown as fast or slow seconds on Row 2 along with the date and time they were detected. On initial power up there are no fast or slow pulses so Row 2 Slow Pulse will be "0" and the date and time indicates when the clock was first power up and synchronized. The Fast Pulse will also show "0" but the date and time will show as "Never" The only time you would expect to see a Slow or Fast pulse detected is if the DCF77 signal was removed for several days then reconnected or if a leap second is injected (fast pulse)

Row 3 DCF77 decoder state

Row 4 Sig Match - Once locked into the DCF77 signal Udo Klein's library can predict what the next signal pulse should be. The Signal Match displayed as a percentage shows the quality of the received signal. 100% being a perfect match to the predicted signal.

Row 4 also shows the "auto tuned " quartz frequency.
When receiving the normal DCF77 signal Udo Klein's library uses this to work out how well the internal quartz crystal is running. It will then tune the quartz frequency up or down to allow it to keep almost perfect time if the DCF77 signal is lost.

Row 4 also shows the tuned accuracy of the quartz crystal. Once the clock has run for a number of days the accuracy of the quartz crystal is tuned until it reaches a max accuracy of 1Hz.
The attained accuracy is displayed. This is fully dynamic so the quartz crystal is continually tuned no matter the temperature or age drift of the crystal. Remember this is not the accuracy of the clock but the accuracy of the quartz crystal if the DCF77 signal was to fail.

Row 4 also shows Winter/Summer time.

Step 3: LCD Display Using Standard DCF77 Library

The standard DCF77 library and code display is shown above.

This code also switches the LCD display off overnight. On start-up the clock attempts to decode the DCF77 signal and will show the "Waiting DCF77 Sync" screen image 1.

Once the signal is decoded the display switches to full time, date and data display. image 2 and 3.

The LCD display shows;
Time and Date Last time the clock sync'd to the DCF77 signal The sync status Last time the clock missed a pulse ( and was corrected by adding a pulse) Number of pulses missed in last 24hrs Pulse length 100ms = 1, 200ms = 2 Cycle length 1000ms and EOF (end of field) indicator The clock will shutdown the LCD after midnight and will turn back on at 06:00hrs. This can be easily changed if required by editing the code.

Step 4: Analogue Skeletal Display

Apart from the LCD display the clock also tells the time on an analogue display driven and controlled by the Atmega microcontroller.

The skeletal display is a modified quartz unit. The quartz crystal board is cut out and the 1 second drive from the main board is connected direct to the drive motor.

The hour and minutes are set from the standard knob on the back of the movement but the seconds are set by using 2 switches on the rear the the clock case. 1 stops the seconds and the other advances the seconds.

Step 5: Code V1 Using Udo Klein's DCF77 Library

LCD Master Clock using Udo Klein's DCF77 library or download from here Download code

Note this clock uses Udo Kleins Release 2 library download here DCF77 Release 2

Step 6: Code V2 Standard DCF77 Library

DCF77 master Clock using the DCF77 library from

Download the code from here

Step 7: Video

Short Video clip showing the clock operating and chiming from 23:59:55 to 00:00:32

Chimes are via separate circuits but can be electromechanical or samples via a sound board.

Step 8: Pulse Monitor Display

LED panel shows the slave clock and chime pulses output from the clock. See panel above.

Step 9: Vero Board

The clock is controlled by a Atmega 328 the same as a Arduino UNO.

Vero Board layout
The cut out on the right of the board goes to the back of the case and allows cable access to sockets to all pins. Outputs are included to enable feeds to other clocks via transistor drivers as required.

There is a 3.3v power module on the board that feeds the DCF77 aerial/receiver.

The board also contains a USB to serial adaptor so the Atmega IC can be updated.

zip files contain full size board layouts

Step 10: Schematic

zip file contains full size schematic

Reuse Contest

Participated in the
Reuse Contest

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    28 Discussions


    Question 1 year ago on Step 10

    Hi Brett,

    Just finished my second word clock and now hope to build this Master Clock.

    Would it be possible to post a complete electronic component list for the project, and is the Atmega 32 taken from an Arduino Uno or is it a pre programmed stand alone controller.



    1 answer

    Answer 1 year ago

    Hi David.

    Sorry I don't have a full component list but it should be quite easy to get a list off the schematic.

    The Atmega 32 is the exact same chip used in the Uno. You can buy them off Ebay etc. Just search for Atmega 328P PU with bootloader. I highly recommend the version using Udo Klein's DCF77 Library I have used this library in all my DCF77 clocks.

    I have basically built my own UNO on Veroboard. The difference being I have added a Quartz crystal instead of the resonator found on Uno boards. See the easy mod here if you want to use an UNO

    The quartz crystal is required to use Udo Klein's DCF77 Library.


    2 years ago

    Very nice work !! Congratulations!!


    2 years ago

    would just have you an arduino code to use a module dcf77 pollin to
    have the hour instead of a rtc on 1307 beforehand thank you
    To mitigate the time change.

    1 reply

    Reply 2 years ago

    Hi MichelH13. Not sure what you mean?


    2 years ago

    Awesome! Looks very professional.


    4 years ago on Introduction

    Your clock is really nice and good looking! To drive the analog clock with steppers and avoid the need of setting it would be a really nice upgrade... Still the look is incredible!

    3 replies

    Reply 3 years ago

    Hi plouc have added 1 button summer winter correction now on the version using Udo Klein's DCF77 library


    Reply 4 years ago on Introduction

    Thanks plouc. Not sure if I have the skills to integrate a new stepper motor into the analogue movement. Using the modified quartz stepper motor I have to manually set the analogue clock 2 times a year for winter and summertime. I could just delay the clock for an hour with the Arduino in Autumn and add 3600 extra pulses (in the half second) in spring to auto set for winter/summertime. It would be a great upgrade and will be worth experimenting with. I have implemented a similar thing on my master clock 30 second clock drive. There are some videos on the site showing winter/summer correction.


    Reply 4 years ago

    Hello Oliverb, your clocks are amazing. I am currently building my own, highly inspired by yours.

    The knob on the back of the skeletal turns with the minute hand, so it is not possible to stick a stepper motor to automate the time setting, because the stepper would prevent the minute hand to turn freely the rest of the time...

    I am wondering how you openned the quartz plastic box of the skeletal clock. Did you have to unscrew everything to access the engine ? Mine has the screws unaccessible because hidden by the plastic (metalic color) dial which cannot be unscrewed. I guess I will have to play a little with my Dremel...



    3 years ago

    Hi Again Brett

    I just thought I would give you a followup on the progress of my clock.

    I am now in the final stages of assembly. I have etched a PCB and mounted the front led panel to my clock. Just waiting for a larger skeleton clock insert, the original one I bought was too small. But have now found the larger version.

    I have re-written a lot of the code, I have incorporated one of these cheap audio modules to store and play the chimes, it is under serial control from the Arduino now so that all the parameters are accessible. Using a good quality loudspeaker driver it sounds the part too.

    I have loaded Westminster chimes so that they play on the 1/4, 1/2 and 3/4 hour. As well as a full chime of the hours on the hour. Code is incorporated to silence the chimes during the night, with the mode selected with a tactile switch. I am also using a tactile switch to halt the quartz movement for sync purposes. The way I set the quartz movement is to wait until the movement shows "60" seconds then press the button, this stops the movement until the main clock reaches "01" second the quartz movement then starts again, and I can set the hours minutes using the normal knob at the back, knowing that seconds are in perfect sync.

    This is the audio module I used

    When completed I would love to send you some pictures. Not sure how I can get your email address though.

    Kind regards


    1 reply

    Reply 3 years ago

    Hi Pete.

    That's good news about your clock. I have looked at the audio module and added it to my "clock collection" on ebay.

    The sound module in my clock is quite out of date now. On my latest chiming clock I have used this 1 from Adafruit it is very good quality but expensive.

    That's a very good idea on setting the second hand in my version I have a stop and fast forward switch that takes a bit of practice to get the second hand in sync.

    Look forward to seeing your finished clock. Will you be publishing it on instructables?

    Will send you a personal message with my email.


    4 years ago on Introduction


    This is an excellent article. Thanks so much for sharing.

    I am attempting to have a go at building one for myself, but I cannot for the life of me get the code to compile. I am using the latest 1.6.5r2 release of the IDE for windows

    I have all the required libraries, but am getting all sorts of errors.

    I would be obliged if you can help identify the issue.

    Many Thanks


    Here are the errors reported by the IDE

    DCF77_UdoKlein_2_1:181: error: 'time_t' in namespace 'DCF77_Clock' does not name a type
    DCF77_UdoKlein_2_1:181: error: ISO C++ forbids declaration of 'now' with no type [-fpermissive]
    DCF77_UdoKlein_2_1.ino: In function 'uint8_t Timezone::days_per_month(const int&)':
    DCF77_UdoKlein_2_1:182: error: request for member 'month' in 'now', which is of non-class type 'const int'
    DCF77_UdoKlein_2_1:186: error: request for member 'year' in 'now', which is of non-class type 'const int'
    DCF77_UdoKlein_2_1:186: error: request for member 'year' in 'now', which is of non-class type 'const int'
    DCF77_UdoKlein_2_1:186: error: 'bcd_to_int' was not declared in this scope
    DCF77_UdoKlein_2_1.ino:186:64: note: suggested alternative:
    In file included from DCF77_UdoKlein_2_1.ino:74:0:
    C:\Private Data\Arduino\arduino-1.6.5-r2\libraries\dcf77/dcf77.h:143:13: note: 'BCD::bcd_to_int'
    uint8_t bcd_to_int(const bcd_t value);
    DCF77_UdoKlein_2_1.ino: At global scope:
    DCF77_UdoKlein_2_1:205: error: variable or field 'adjust' declared void
    DCF77_UdoKlein_2_1:205: error: 'time_t' is not a member of 'DCF77_Clock'
    DCF77_UdoKlein_2_1.ino:205:15: note: suggested alternative:
    In file included from DCF77_UdoKlein_2_1.ino:74:0:
    C:\Private Data\Arduino\arduino-1.6.5-r2\libraries\dcf77/dcf77.h:158:7: note: 'Clock::time_t'
    } time_t;
    DCF77_UdoKlein_2_1:205: error: 'time' was not declared in this scope
    DCF77_UdoKlein_2_1:205: error: expected primary-expression before 'const'
    DCF77_UdoKlein_2_1:1501: error: expected '}' at end of input
    'time_t' in namespace 'DCF77_Clock' does not name a type

    6 replies

    Reply 4 years ago on Introduction

    Hi g0pkh.
    The code for this clock was written using Udo Klein's original DCF77 library. I think he has completely re-written the library now and called it version 3.

    Check to see what version of the library you have installed as I don't think my code will work with version 3.

    Let me know how you get on.


    Reply 4 years ago on Introduction

    Thank you so much for taking the time to reply.

    I did suspect that, I noticed that there was a later version of the library available now. Trouble is I cannot find the earlier one.

    Would there be any possibility of emailing the version you used to me?

    I would appreciate it. With such complex code, I would like to get your version working before I try using a later version of the library.

    Many thanks



    Reply 4 years ago on Introduction


    Thankyou very much Brett. Downloading the V2.0 library worked great.

    The code compiles fine now.

    Kind regards



    Reply 4 years ago on Introduction

    Hi Brett

    Just to let you know, I now have a basic clock operating, with just the LCD display at the moment. Have now modified your code to use the V3 DCF library. Have managed to source the same case and skeleton clock.

    I am now experimenting with some of latest audio player modules.

    I don't have any slave clocks, so am concentrating mainly on a chiming stand alone version.




    4 years ago on Introduction

    few times we find a good Instructable with a nice looking outcome.

    Thanks for sharing!