


The RTC is configured to output a square wave at 1Hz with the falling edge being the second boundary. If the time offset is more than a threshold, and I’m using 20ms currently, the RTC is updated using a method that aligns its second boundary to where NTP says it should be. The way this works is that the ESP8266 wakes up at a configurable interval and makes an NTP request and computes the time offset. I chose an ESP8266 as the main controller to manage configuration, NTP synchronization as it’s a really cheap (less than $3) wifi module with a flash-able microcontroller and multiple I/O pins. I selected a DS3231 as a real time clock (RTC) as it is low power, has integrated temperature compensated crystal oscillator, supports a 1Hz square wave output, and has an i2c interface. I used all 6 of the I/O pins: 2 to drive the clock motor, 2 for i 2 c communication, one for a 1Hz signal to time clock ticks, and 1 to signal a power outage so that the clock position and state can be saved. Its an 8 pin microcontroller with 8k bytes of flash, 512 bytes of RAM, 512 bytes of EEPROM and 5 I/O pins, 6 when you configure the reset pin as I/O. I actually built a few clocks using this until I realized that I could use pulse-width modulation ( PWM ) to control power when directly driving the motor with two of the microcontroller pins. These spikes can cause tick failures and I was forced to delay disabling the DRV8838 for up to 50ms which increases the overall power usage. The downside is that the DRV8838 draws more than a milliamp when enabled and when it’s disabled the active mitigation vanishes leaving you with spikes as seen here: While testing I found that the DRV8838 does active mitigation for inductive spike coming from its load. (photo of testing operation of the DRV8838 ) I found a small low power motor controller ( DRV8838 ) that supported motor voltages including 1.5v and decided to use that. Testing driving directly meant using 3.3v or 5v depending on what micro-controller I was using at the time and I was concerned with using too much power since this was designed to be used with a 1.5v battery. I ran a number of experiments both attempting to directly drive the clock from microcontroller I/O pins and using an H-bridge type circuits. This can be done with a half H-Bridge type of circuit. Driving one of these requires us to alternate polarity each second. Most quartz clock movements use a Lavet type stepping motor to physically drive the clock hands. I went shopping with the wife and bought two fairly cheap ($10) analog clocks and survived “the look” when I immediately disassembled them upon arriving home. This one also uses too much power and does not have network connectivity. It uses a real time clock module to keep accurate track of the correct time. It did however have a really nice description on how standard quartz clock movements work. This remained lower power but had no network connectivity to keep the clock synced with an external time source. The problem for me was I wanted battery operation and the ESP8266 cpu/wifi module uses 70 milliamps on average – much too much for the battery powered device I wanted.Īnother interesting one I found was “Crazy Clock”: ( ). I found two that were similar to what I wanted: ( and. Many were digital and while interesting did not help much. Internet searches turned up quite a few clock projects. Started with checking if anyone had done this type of clock sync or something similar. Inexpensive – less than $20 in parts, not including the clock & batteries.Remember clock position/state on power loss.Automatic Daylight Savings Time adjustments.No two clocks should differ more than 100ms, they should all appear to tick at the same instant.Correct and accurate time via NTP (Network Time Protocol).Thinking about what I’d want this to do I came up with a few goals: I’d been thinking about what my next electronics project would be. Yes, all the second has were wildly different and the minute hands were all slightly off too. He took one look at the five analog wall clocks set to timezones for various offices and said “I hate that”. Synchronized Clocks: Someone has to be blamed…
