ESP32 based old clock controller, with NTP sync

I have been able to find an old “slave” clock from 1960 (according to the serial number).
It is Pragotron PJ 27, 12V version. They have been produced in Czechoslovakia during
196x years and using the PS-1 mechanism.

This type of clocks usually been used in organizations with central time management systems, e.g. schools, factories, etc. To drive them initially big mechanical “master” clock has been used, later such systems been replaced by digital one.

The clock mechanism is very simple and expects 1m impulse with different polarity on every run to move the arrows. There are also 6V, 24V, and 60V versions.

Making new clock controller hardware

After cleaning up clocks from the dust I tested them with a 12V power supply and found
that they are still working. As I don`t have any master clock to drive them – I
decided to build my controller. I had already an ESP32 controller with an OLED screen
on-board, so decided to utilize it. Also, I found a 220V → 12V/1A power supply left
from another project.

To generate 12V impulses with different polarities i decided to buy L298N DC Motor Driver Module.
It should be more reliable compared to a set of relays, polarity could be set using
TTL inputs and the module itself is very cheap (1-2$). Also, it provides a 12v → 5v converter,
so we can power our ESP32 board from it. I am currently using only one channel to drive clocks,
the second channel could be used for the alarm or clock in a different timezone.

Wiring, in this case, was very simple: 12V is wired directly to the L298N controller, 5V L298N
output and GND → to the ESP32 5V and GND, and L298N IN1 and IN2 are connected to the GPIO
pins 12 and 13. Clocks are connected to the L298N OUT1 motor output.

Software part

As ESP32 does not have real RTC I decided to use NTP over WIFI as a precise time source. This way I can avoid using an additional RTC module with battery.
To store slave clock status I am using ESP32 flash. I built software for the controller
using the Arduino IDE. Some of the features implemented:

  • On boot, it connects to WIFI and using NTP to get actual time. After initial sync
    time is updated from NTP every 5 minutes.
  • Timezone support is implemented using Timezone.
  • Actual time, slave clock status, wifi status, and NTP sync status is displayed on the OLED screen.
  • There is a special “init” mode which is enabled by touching GPIO15 and reboot.
    In this mode, impulses are generated every second. When the slave clock set to 12:00
    the pin needs to be released. This mode is useful for the initial setup or testing of the slave.
  • State is saved every minute to the ESP32 Flash using the “Preferences” library. It is requesting
    “nvs” partition which implements basic wear leveling. To make it more efficient I changed the NVS partition size to 1Mb.
  • To avoid OLED degradation in a 10m screen goes to the “screen-saver” mode. To exit screensaver – touch GPIO15 pin.

Code is available on the samm-git/clock-controller-esp github repo, comments are welcome.

Summary

It was an interesting journey to add NTP and wifi support to the device from 1960.
I was able to find a case from the old-time relay which now hosts my controller.
Maybe in the future, I will add more devices to this master.

Tagged , ,

7 thoughts on “ESP32 based old clock controller, with NTP sync

  1. candid moe says:

    OLED is organic; it degrades and fade out over time (two or three years) if you leave it allways on.

  2. […] These days, everything’s got a clock in it, and a good proportion of those clocks are automatically syncronized to high-accuracy Internet time servers. Back in the past, things weren’t so easy. Often, institutions that required accurate time would use a single highly-accurate primary clock to drive a series of secondary clocks around a facility. Without the primary clock, the secondary clock has no signal to drive it. [Oleksii Samorukov] had just such a clock, and whipped up a controller to stand in for timekeeping duty. […]

  3. very good written article. It will be a good support to anyone who utilizes it including me. Keep doing what you are doing can’t wait to read more posts very nice article 만남사이트

Leave a comment