Close
0%
0%

Unix Time Clock

A clock displaying the accurate count of the number of seconds that have elapsed since the Unix epoch

Similar projects worth following
This project's hardware is a ESP32-controlled 10 digit display. The hardware was inspired by another project, but was almost entirely redesigned by me. The software is the part that really makes this project shine. I wanted the display to update *exactly* in line with the actual time update, so I spent over a year tinkering with the code until I was happy with it. Read on for the details!

Hardware

The hardware is a fork of the Maniacal Labs Super 7 Seg Kit. I really liked their design, but didn't need all 12 digits. I could've just cut off a display, but I also wanted to change the controller, so I modified their design to only fit five two-digit displays. Their controller was set via serial, would would require some other method to set the time anyways, so I completely redesigned that board to use an ESP32. It was perfect because it's powered by +5V USB, connects to WiFi to get the time, has enough pins to drive the display (more on that later), is programmed via Arduino (which actually be a downside after spending so much time messing with the software), has dual cores (one for WiFi, the other for controlling the display), hardware timers for accurate time keeping, and PWM pins to control the brightness of the display. I wrote a separate post about how I used TopoR to autoroute this PCB.

My hardware files are located on my GitHub.

When I received the PCBs, I started writing code and realized I had made an error on the controller board. Although the documentation refers to pins 34 and 35 as “GPIO”, they are input-only. I didn’t have any extra output pins on the board, so I was forced to remove the decimal point pins. 

Software

My software was written using the Arduino environment. I thought this would make it more simple, but the lack of debugging really hindered me as I dug deep into the internals of this chip. A simple breakdown of my software is as follows:

  1. Sets up the pins as PWM outputs to control the display (currently set at full brightness)
  2. Creates a background process on another core to connect to WiFi and get the time
  3. Until the time is received, it displays an animation on the screen
  4. Here's the important part: it waits until the moment that the second changes to being displaying the time. After the time is initialized, it will continue to be aligned forever.
  5. After the time is received from an NTP server, it continuously displays the time. It reads the time via the "time.h" header.
  6. A one-hour hardware timer kicks off a function so that the device reconnects to the internet and re-synchronizes to the current time to prevent any drift.

My software files are located on my GitHub.

This video shows the completely synchronized time in the newest code:

Mount

I also designed and 3D-printed a simple mount for this board so I can mount it to my desk.

My CAD files are located on my GitHub.

More details

This description was condensed from my original blog post on the project

  • 1
    Buy PCBs and components

    The hardware files are open sourced. I used OSH Park to manufacture my PCBs. I have some extra displays and parts. Reach out to me if you want to build your own!

View all instructions

Enjoy this project?

Share

Discussions

Dan Maloney wrote 12/20/2019 at 17:33 point

Will Y2.38K be like Y2K? Will old coots get dragged out of retirement to fix COBOL programs all over again? I guess we'll see.

  Are you sure? yes | no

Dan Maloney wrote 12/19/2019 at 22:58 point

Will it just roll over to zero in 2038? I mean, not a huge, pressing problem - more than 18 years at this point. Just curious. And nice project, BTW!

  Are you sure? yes | no

Dillon Nichols wrote 12/20/2019 at 13:50 point

I didn't think about the 32 bit constraint. I did calculate that 8 digits will last until 2286 so I figured I'd be OK. None of my other electronics projects have been in use for more than 10 years, so I haven't had to think about super long term use. I think I'll just have to reprogram it when the time comes because it doesn't seem like there's consensus yet if the recommendation is to re-use the 32 bit counter with an offset or to move to 64 bit storage.

  Are you sure? yes | no

Ken Yap wrote 12/20/2019 at 14:35 point

time_t has been defined as a 64-bit type on Linux systems for many years now. So you ought to be using 64-bit time variables in your program. Question is whether NTP has a rollover date.

  Are you sure? yes | no

Dillon Nichols wrote 12/21/2019 at 01:34 point

I looked into it some more and the ESP32/Arduino time library uses a 32-bit long int for storing the time so there's not much I can do on my side unfortunately.  

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates