Skip to content

samm-git/clock-controller-esp

Repository files navigation

Slave clock controller based on ESP8266 hardware

This project is intended to implement a slave clock impulse driver using ESP32 hardware with an OLED display. The time source is NTP, so no RTC module is needed. The code supports timezone and DST rules. The state of the slave clock is stored in the Non-Volatile memory to survive power loss or reboot. Board time as well as slave clock time is displayed on the OLED screen.

See my blog posts for the additional details.

Requirements

Software

Hardware

How it works

  • L298N driver is used to generate 12V impulses to drive the clock and to provide 5V power to the ESP board. It also allows to invert output polarity, so no relays needed.
  • After startup ESP trying to connect to WIFI and get time from the NTP
  • If time is synced - ESP compares it with slave time in the Non-Volatile memory and updates the slave clock
  • Slave status is stored in Non-Volatile memory every minute, using Preferences library on the NVS partition to optimize wear-out. Probably using the I2C FRAM module for that would be a better choice.
  • Code respects configured timezone and automatically synced to NTP every 5m
  • There is a special "init mode" to sync hardware slave with the controller
  • At the moment we are using only one (first) channel of the L298N. The second could be used for the alarm or led backlight.

Init mode

As ESP has no information about the slave clock position - we need to sync them. To do this - connect PIN_INIT (15) pin to GND and restart ESP. It will move arrows every second. Wait until the clock shows 12:00 and immediately unplug the wire. The clock will be synced with ESP and will switch to normal mode.

Final result (not yet in a box)

Clock and controller

Related links

About

Slave clock controller based on the ESP32 board

Resources

License

Stars

Watchers

Forks

Packages

No packages published