A Test in Time

A Test in Time

My Clock Making Adventure begins. . . 

IMG 2228

Clocks seem to be one of the good-ole-standbye projects. And why not? They are useful and it is easy to get creative with them. In this post I show you how I have started on my journey of time. 

I have looked at my options for keeping time. Micro controller a yes and then a time source. Micro controllers themselves are terrible timekeepers over long periods of time. A popular option is an Arduino Uno (or other such board) and a RTC (Real Time Clock) such as the DS3231 or DS1307. Once it is configured, it does keep time quite well and over a long period of time. It uses a backup battery to keep time if power is lost. There is some drift in the clocks, but over a year it is fairly small. 


I played around with it, but I have been having fun with the ESP-01. It is a fun little chip. It is part of the ESP8266 family. I found my controller and way for time, NTP (Network Time Protocol) to keep accurate time. The ESP requires an active internet connection for it to keep time, which is the con(?) of this project, but the time is kept spot on. 

I have used the LED and OLED displays in the past and like using them. In this project I wanted the display to be simple. My main focus is to learn about time. The packet getting the time, picking the packet apart, and displaying the correct time for where I am at. For that purpose I picked a 4-digit, 7-segment display using a TM1637 chip to drive it. And I had one in my displays drawer. 

IMG 2134


From the schematic above the pin to pin table is:

      Display -> ESP-01

  • CLK -> IO2
  • DI0  -> IO0
  • Vcc  -> 3.3v
  • Gnd -> Gnd

As a quick test here, you can plug everything into 3.3volt power and the display should read 0123. Now it is time to move on to the code. 

I am not sure where I found the core time code I am using (if anyone recognizes it let me know and I will give due credit), but I started with a code base that would get a NTP UDP packet from a NTP time server. This method does not use one of the NTP libraries, but relies on decoding the packet and calculating the time. One other feature I added was the WiFiManager library. It is a wonderful addition to any wireless project as it makes setting up wireless a breeze and you don’t have to have people edit the sketch. I like to give away some of my projects and this makes it easy for the people I give the to. All they need is a web browser to set it up and get it running. 

My code can be found over at my GitHub

Taking a break. I will be back to update this soon. . .