Introduction: Desktop Equinox Clock

Measuring Time

The human mind has been fascinated by devices that keep track of time for thousands of years. A wide range of ingenious methods have been employed by different cultures including Chinese marked candles, Egyptian sundials and Roman clepsydrae, that used water pouring from a container to mark the passing hours. The classic hourglass (still useful for boiling an egg) led on to more sophisticated mechanical clocks from Europe. The development of these technologies has continued in search of ever-more accurate means to measure the passage of time. The evolution of the cheap wristwatch at the end of the 20th century used quartz crystals to keep time and they became the dominant timekeeping technology until the arrival of the smart phone. Today, we have atomic clocks that can keep an accuracy of one second in 300,000,000 years!

Coordinated Universal Time

The internet provides an opportunity to connect a range of devices that can sense the real world, talk to each other and exchange information thereby forming the internet of things (IoT). Of course, clocks are now one of the many devices that can access the internet to retrieve a time signal to display the time accurately anywhere in the world. In the internet age, Greenwich Mean Time, the world standard has been overtaken by coordinated universal time (UTC) to regulate clocks (and computers) around the world. In order to synchronise computer systems around the world, the Network Time Protocol (NTP) was invented and can ensure a computer has the correct time within a few milliseconds of UTC. As we now have the technology to accurately measure time from any location with an internet connection, perhaps our efforts should be put into creative ways to display the time – after all, we don’t have to worry about replacing the candles or turning the hourglass upside down any more. This clock design is based on LED neopixels (WS2812) which are strips of connected lighting elements. Each element is made up of red, green and blue (RGB) LEDs and the brightness of each colour can be independently controlled, providing a possible 16.8 million colours. A microprocessor is needed to retrieve the time from the internet and decode which LEDs to illuminate. It needs to generate the binary codes that are sent down a single wire to switch the individually addressable LEDS on and off. Neopixels are available as long flexible strips and matrices but this design uses a neopixel ring made up from four quarters that each have 15 neopixels. When soldered together into an almost continuous ring, the 60 neopixels can easily represent the 60 minutes found on a traditional clock face.

Supplies

3D print the clock housing - files can be found on Thingiverse

Quarter circle neopixels WS2812 15 pixels x 4

ESP8266 Wemos D1

Resistor 470Ω

Electrolytic capacitor 1000μF

M3 x 12 countersunk machine screws x 2

M3 Nuts x 2

Multistrand cable

Single strand wire (for soldering bridges)

Superglue

Female Power Jack Socket 5.5mm x 2.1mm

M2 x 3 self tappers x 2

5V 3A power supply

Step 1: Design Decisions

Design Decisions

The physical housing for the desktop clock is based on the dimensions of the neopixel ring. I wanted the design to have a minimalist feel about it and to have sleek design lines so that it not only told the time, but also created an attractive desk ornament in the form of a piece of art. No switches or buttons were included to maintain this style. When it is powered up, it should just work! (of course, there would be a lot of technical things going on in the background to make this happen). The clock would need to be powered by a mains supply as batteries would quickly need replacing due to the current consumption of the neopixels. I calculated that each LED would require 15mA and there were three colours on each neopixel. For the whole ring, I may need a maximum current of 45mA x 60 = 2.7A if all LEDs were on full power, which would not happen very often, and only for short bursts of time. I opted for a 5 Volt 3 Amp plug-in adapter, which provided ample power to operate the device.


The casing was designed using FreeCAD and consists of two key components. The ring holder is a protective housing for the neopixels and only exposes the front face of the neopixels, hiding the wiring connections at the back. The main body houses the microprocessor and power jack. These items were joined with cyanoacrylate superglue and the electronics can be accessed with a panel in the base of the unit. The ESP8226 microprocessor was chosen for this project as it was fast enough to produce the required bitstream at 800KHz to turn the lights on and off. It also has a built-in antenna and can communicate wirelessly with the network. This is essential as it will be able to update the time signal regularly to ensure it displays an accurate time. These devices are cheap to buy and easy to program using the Arduino IDE platform.

Step 2: Network Time Protocol

Network Time Protocol

A key task for the microprocessor is to connect to the internet and retrieve UTC time from a time server using the network time protocol (NTP). An exemplar NTP client is included in the Arduino IDE to help you get things working. The way it works, is to retrieve the IP address of a random time server from a pool of available ones which means you will always be able to retrieve the time, even if one of the time servers goes offline. The microprocessor then sends a packet of data to the time server, which requests the time and waits for a 48-byte data packet to be returned. Once received, the packet is broken down into bytes to recover the timestamp. This is converted into a number and represents the number of seconds since 1st January 1900.


For example, here are a typical 48 bytes returned in the data packet: 28 1 13 227 0 0 0 16 0 0 0 32 78 73 83 84 227 40 119 255 0 0 0 0 0 0 0 0 0 0 0 0 227 40 120 43 108 18 197 183 227 40 120 43 108 18 234 100

The time stamp is stored in four bytes starting at byte 40 (in bold). These are then converted into a binary number b11100011 00101000 01111000 00101011 = 3811080235. Unix time starts on 1st January 1970, but the calculation we have made is referenced to 1st January 1900, so we need to take away 70 years’ worth of seconds (2208988800).

(time since 1 Jan 1900) - (1 Jan 1970) = (time since 1 Jan 1970)
     3811080235     –      2208988800   =     1602091435 

When we calculate 1602091435 seconds since 1st January 1970, this number converts into 17:23:55 on 7 October 2020. In real time, this whole process of making the request, sending the data packet and doing the calculation takes a few milliseconds, so we now have an accurate time for our microprocessor to display.

Step 3: Clock Hand & Light Show

Clock Hands

Each ‘hand’ of the clock is represented by a different colour neopixel, red for hours, blue for minutes and green for seconds. If you look at a traditional clock, it is easy to understand how the minute and second hand move as there are 60 divisions in the circle. The hour hand is a bit more interesting as it also progresses slowly around the clock face and will move proportionately between the hours. For example, when it is 01:30, the hour hand is half-way between the 1 and 2. This feature will be built into the clock’s hour hand too, so that it slowly rotates around the ring.

Lightshow

In the same way that a cuckoo clock marks the quarter hours, the Equinox Clock puts on a lightshow on the quarter chimes. Every 15 minutes it runs through a different set of lightshow routines, with a longer set of effects at midday and midnight. Adafruit have developed some great animated lighting effects and these are freely available when their neopixel library is installed (Examples → Adafruit Neopixel → strandtest). It’s always fun to try out some of your own ideas too. I have added the equivalent of a ‘chime’ at the end of the light show that displays as a white chaser LED filling up the quarter hours.

Step 4: British Summer Time

British Summer Time

If we were using a Raspberry Pi to control this clock, we could easily use the system time as the operating system would make sure this is kept up date. It would even sort out the time shift when we change from Greenwich Mean Time (GMT) to British Summer Time (BST) and back again. However, our microprocessor does not have the facility to take the time from a sophisticated operating system and in fact, we only ever retrieve UTC, which never uses the daylight saving time-shift. We will need to include a routine to change the time when the clocks fall back in the Autumn and springs forwards an hour in the Spring. We will need to code this from first principles, so we need to have a set of rules for when the clocks change in the UK.

The rule is that British Summer Time begins at 01:00 (GMT) on the last Sunday of March and it ends at 02:00 (BST) on the last Sunday of October.

This does make things more complicated, as this is not a consistent day every year. For example, BST ends on 25 October 2020 and on 31 October in 2021.

Pseudocode (for calculating if we are in British Summer Time)

#Find the last Sunday in March as the day the time switches to BST
Working backwards from March 31
    Calculate the day of the week #use Sakamoto’s algorithm
    If the day is Sunday #The first one you find is the last one in the month
        then store the BST_begins timestamp
#Find the last Sunday in October as the day the time switches back to GMT
Working backwards from October 31
    Calculate the day of the week #use Sakamoto’s algorithm
    If the day is Sunday #the first one you find is the last one in the month
        then store the GMT_begins timestamp
Calculate the Unix timestamps for the switchover dates (changeover time = 1:00am)
Retrieve the current timestamp
If the current time is between the switchover dates
    then it is BST (+1 hour)
else it is GMT (+0 hour)

Sakamoto designed an algorithm that could return the day of the week based on any given date and this was implemented as a function in the code, so that it could check all the dates at the end of the month until it found a Sunday.

Step 5: Neopixel Ring

Neopixel Ring

One of the first things to do when building the clock is to assemble the four neopixel quarters. The PCB needs to be gently broken apart and the rough edges can be filed smooth with a diamond file. These four quarters should precisely form a circle, so they can fit inside the printed casing, but they also need to be soldered together, so that the neopixel data can be transferred serially along the neopixel strip. In order to secure the neopixels, a temporary circle template was printed and masking tape held the pieces in place whilst the contacts were soldered together. An offcut of single strand bell wire was used as a bridge for the solder joint. All of the contacts are soldered together but one of the joints will be left. This is the point where the data enters the neopixel strip and it will eventually be located in the 6 o'clock position, where the wires enter the base unit. This was an effective method and the final ring fitted perfectly into place in the ring holder. It should not be glued into place until you are sure that the neopixels are working properly.

There are three wires to prepare. They are soldered at right angles to the ring. The red is for +5 volt supply (Vcc), the black is for ground and the green wire is for the serial data input. It must have a 470Ω resistor soldered in-line to protect the neopixels from excess current. This is covered with a heatshrink sleeve to stop it shorting out on any other wire contacts inside the unit.

Step 6: 3D Print the Case

The base, ring holder, base cover and ring template need to be printed out.

The ring was printed out with a brim as it is quite a narrow component and this helped to secure it to the heated printer bed without any warping.

Step 7: Assembling the Unit

The powerjack can be inserted into the rear of the main body and secured with the locking nut.

The ESP8266 should have two holes drilled in the pcb to enable it to be secured to the main body. If you hold up the circuit board to the light, you will see where you can safely drill the holes.

The wires attached to the neopixel ring can be threaded through the hole in the front of the main body. The neopixel ring housing can now be superglued to the body and held in place with some tape whilst the glue quickly dries.

Wiring up the circuit is simple. An electrolytic capacitor had its legs bent into shape and it was then soldered to the power terminals of the ESP8266.The protruding wire legs of the capacitor then provided a useful way to connect the power leads from the jack socket with red connected to the 5v and black connected to the Gnd pin. The data output pin, D4 was connected to the green wire going into the neopixels.

The power can now be connected. The device will be able to draw enough power just from the usb connection, but it is a good idea to use the 5v power adapter whenever you want to illuminate the LEDs, so this can safely be plugged in when the unit is being programmed.

Step 8: The Code

This is the code you will need to upload to the device.

I have now created a new sketch for use in North America with central standard time.

You should be able to upload the sketch and it will work straight away (I have changed my British Summer Time variable to Daylight Saving Time throughout too - BST --> DST).

India does not have a daylight saving time throughout the year, so lots of the code that does this calculation can be deleted. The time zone is 5.5 hours ahead of GMT.

New Zealand code now added too

Step 9: Putting It All Together

Once you have uploaded the code to the ESP8266 and you know that it is working properly, you can glue the neopixels inside the printed ring holder by dripping a few drops of superglue around the border of the neopixels.

You won't need to access the usb connector now, so the ESP8266 can be screwed into the base unit with some M2 self tapping screws.

Tidy up the wires and the bottom plate can be attached with some M3 machine screws and some nuts that are held captive in slots.

Step 10: Topsy Turvy Time

Although the LEDs are in the shape of a ring, they are in fact just a sequence of LEDs. The ring is not electrically connected all the way around, so there is a beginning and an end to it. Initially, I decided to put the start of LED sequence at the top of the circle, representing 12 o’clock, as this made it easy to program. As time progressed, the LEDS would light up in a clockwise sequence. The problem was that I had set myself a physical design goal of being minimalist to provide a delicate sculpture yet I had to run wires to the top of the ring, which were quite bulky. It would be much better to connect the microprocessor data and power wires at the point of entry, which was at the bottom of the ring. I tried it and it worked well physically. The wiring was nice and tidy (invisible in fact) but the clock was telling the time ….upside down! The solution was quite straightforward as it could be implemented in software. All I needed to do was shift the calculated positions of the hours, minutes and seconds LEDs by 180 degrees, which meant that the data entry point of the ring represented the 6 o’clock position instead of 12 o’clock. I achieved this by adding 30 to each of the calculated values and performing some modulus arithmetic in case the values were now greater than 60. This sent the illuminated LEDs to the opposite side of the clock, effectively inverting it. It worked perfectly, with the correct time showing and tidy wiring.

I decided to build the equivalent of a power-on-self-test (POST) which is commonly found on a PC - it beeps a number of times if there is a problem at start-up. Different beep sequences indicate specific problems with the PC. I had not designed a buzzer into my clock but I could build some simple visual effects into the start-up routine. When the device is switched on, it builds a circle of red light to show them all working. It then tries to connect to the internet and once connected, it will light up a circle of green light. The next stage is to retrieve a timestamp from a time server. Whilst it is waiting for this data to be returned, it displays an amber ‘theatre chase’ effect. With a strong wifi signal, I have found these processes to be almost instantaneous, so from turning on, the clock goes red, green then shows the correct time in a couple of seconds.

As the Equinox Clock has no hands, it is not always immediately obvious to the casual observer, that it is indeed a clock. The regular pulsing and movement of the green LEDs might give the first clue that it is marking time and I have watched with glee as the observer slowly deciphers the progression of the lights around the ring. It is interesting that they often double check the time on their own watch, or more often, their smart phone to confirm their horological skills. I have also noticed that the light shows every quarter of an hour, can make passers-by stop and stare at the spectacle, ironically proving Benjamin Franklin right: Lost time is never found again.

References

Burgess, P. (2020) Adafruit Neopixel Library. Available at: https://github.com/adafruit/Adafruit_NeoPixel

Sakamoto, T. (1992) ‘Date & Day of week conversion’. Google newsgroups:comp.lang.c, 11 December.

Woodward, A. (2017) ‘The most precise atomic clock ever made is a cube of quantum gas’. New Scientist, (5 October), Available at: https://www.newscientist.com/article/2149568-the-most-precise-atomic-clock-ever-made-is-a-cube-of-quantum-gas/


Original inspiration from Bram Knappen’s Equinox Clock https://www.bramknaapen.com/equinox-clock/

How to wire up neopixels from the Adafruit NeoPixel Überguide https://learn.adafruit.com/adafruit-neopixel-uberguide/powering-neopixels

Make it Glow Contest

Participated in the
Make it Glow Contest