RTC DCF77 synced 24-NeoPixel Clock

Introduction

Building a clock usually is one of the first more elaborate projects when programming Arduinos. However, the idead came with a circled NeoPixel LED strip.

Besides displaying the current time via the LED strip, I also had a DCF77 receiver which is capable of receiving the current time via radio.

In addition to this, an RTC keeps time even when power was lost and the DCF signal is not being received properly due to antenna positioning or noise.

As the RTC and DCF signal also contain the current date, the clock is also supposed to show it.

Components we need

Although the actual development took place on a mega board, I have used an Arduino Nano with an atmel328p controller as they are cheap and quite sufficient for the project.

Neopixel LED Strip

The main component of the clock is a 24 NeoPixel LED strip. Each of these LEDs actually consists of three LEDs (red, green and blue; RGB) which can be controlled individually. They are quite easy to use via a library from Adafruit.

The strip only has VCC and GND as well as two data lines of which we only need the DATA IN.

DS1302 RTC

There are lots of different RTC models out there. I had a bad experience with the TinyRTC models. However, due to looking at low-cost, a DS1302 model seems suitable.

DS1302 RTC Module

DS1302 RTC Module

This device is not accessible via SPI or I2C, but has its own protocol. Fortunately, there are different libraries out there doing the job.

DCF77

Getting a DCF77 module was a little trickier. According to Wikipedia, the technique of spreading time and date via radio is different all over the world; So in case you e.g. live in the US, you will need something alike the module I used.

DCF77 Module

DCF77 Module

There is more information available on the signal and coding e.g. here. However, the important thing is that the date and time information is sent periodically each minute.

I do not want to bother you with details as even for this purpose, there are lots of libraries out there. I have used this.

4×7-Segment display

In order to also show the current date, I decided on using a 7-segment display. You may either just use single 7-segment displays and drive them by a shift register each (this is lots of wiring etc.), but I also had this nice little things that lets you multiplex the segment wires.

4 Digit 7-Segment Display

4 Digit 7-Segment Display

4 Digit 7-Segment Display

4 Digit 7-Segment Display

Generally, this is not as comfortable as we must update the signal periodically (each digit at least about 20-30 times per second), but turns out working quite easy.

The timer to use will be Timer 1 as it has 16bit. For this purpose you can either set a couple of registers or just use another library that simply lets you hook a callback for the timer ISR at a specified period (see here).

Putting the hardware together

Using the hardware with the Nano board is quite straight forward. This holds at least for the NeoPixel LED strip and the RTC.

Complicated is the DCF module because of two reasons:

  • It is very sensitive to a non-stable supply voltags (3.3V here).
  • It only provides very little output current.

I have solved the issue by stabilising the supply and although the device has been working without any issue in combination with he mega board, we must amplify the output for the Nano.

I have tried certain transistor combinations etc., but did not have anything suitable and working here. So I ended up using an opamp for this purpose which is used as an open comparator:

DCF Driver Circuit

DCF Driver Circuit

Casing

As the hardware components plugged together with jumpwires does not look very pretty, I have created a clock face and a wooden plate on which I mounted the LEDs:

Clock Plate

Clock Plate

Clock Face

Clock Face

(There are additional holes in the plate which I do not need, but I will cover this up by a paper sheet with numbers anyway.)

You can download the .pdf here.

Coding the clock

Basically, we do not need much for running the clock. At first, the libraries must be set up:

We furthermore need to initialise them:

This allows us in a loop to check the DCF receiver whether is has a new update for us and set the RTC accordingly and furthermore get the current time from the RTC which we are going to display:

Now the clock update is quite easy:

However, the trickiest part and most work was displaying the date. Therefore, we need lots of wires being defined as follows:

Having the codings prepared, we just need to display them:

In order to have the date displayed, we finally need to setup the timer:

Doing fancy stuff with the LEDs

AdaFruit brings along with the library lots of examples of fancy effects. Feel free to choose some on your own.

My clock now looks as follows:

So have fun. Here is the code.

Leave a Reply