I have a really old clock that has been in my family for ages, it has a simple battery-powered clock motor that is too old to work any longer. I could just buy a new cheapo battery-powered clock motor and get it working again. But, I thought it would be really cool if I could build an ESPHome device that mounts to the clock to drive the hands. That way when daylight savings time adjustments come around twice a year, I wouldn’t have to fix the clock myself! Talk about quality-of-life-improvments!
I found this bka30d-r5 double stepper motor which can be used to drive two hands in either direction. It seems like it’d work pretty well for this application. However, I don’t really look forward to trying to figure out how to map time stamp time to motor movement…
I’ve watched a few videos of people using these types of motors to implement standard analog clocks and they use Arduino libraries (like AccelStepper: AccelStepper library for Arduino). Unfortunately, I’m not sure how to use that kind of thing with ESPHome or if that’s even possible. The motor is expecting PWM signals to move the hands about:
Instead of twice a year adjustment, you likely end up doing it twice a month.
There’s not such a thing like translating NTP time to stepper position. Any hiccup and position is lost.
Actually, there are different models depending on how much rotation you need. For a clock, I’d get the 2x360° model.
Your statement makes me think of how amazing my 3D printer is. It can run literally for days moving a print head around in 3D space (7 separate stepper motors humming away in concert) with zero feedback and at the end, out comes a perfect representation of a 3D model. I feel like you may be glossing over the possibility here with your statement.
Also, I found someone’s post about “The Wife Clock”. This gentleman implemented something similar to what I want with a couple of IR sensors to include feedback for the two hands (I’m guessing for periodic recalibration, if needed). Again, this solution is in Arduino space.
I made a cat feeder with esphome using a stepper motor and gear ratios. Ideally you could use just one motor and have that motor run the minute hand, which runs the hourhand with 60:1 gear ratio. 3d Printer or finding the gears would be required
Did you know that battery powered wall clock mechanism uses stepper motor as well?
But it has quartz ticking the steps instead of esp. You know “component x took too long…”, power interruptions, safe mode, reboots…
If you add some absolute position feedback, you can synch the time every time you get NTP.
Esphome has support for common stepper drivers.
ps. it took me more time to post this than it takes to update time of my wall clock for next 10 years..
Youtubers are looking for viewers, not practical solutions.
Is it going to be a clock in the end, or do you plan to use the clock face and hands for something that is not time telling? I see it can be done, but not sure why one ever need to drive the hands independently… if the intension in the end still being a clock.
So, an alternative & (very) rough idea:
Instead of using a stepper motor to drive the hands directly, you can instead hack a typical clock movement kit
There are obviously many many different styles, depends on how fancy you want it to be, so for illustration only here… and use an ESP32 to:
Cut the power from the battery for exactly 1 hour, for when you need to turn the clock back for daylight saving
And when you need to turn the clock forward, you use the stepper motor to (not drive the hands directly but) instead drive the clock adjustment wheel in the back.
(Well, I guess you can use the step motor to do #1 above, without cutting the power from battery, also)
You can even fit a small magnet to one of the hands, and do a hall effect sensor (or reed or IR or lux sensor) in the background, and then with some math you can adjust / calibrate your clock on the fly.
How do you plan to power your ESP32? From a bigger battery pack? Directly from some AC power source near or behind the clock? PoE? I’m asking because if you have long enough continuous power you can also do temperature / humidity measuring, and/or bluetooth proxy, and/or even voice settelite. Also you can do either the AA battery low voltage monitoring using the ESP32, or get rid of the AA battery and power the clock movement kit from your ESP32 (via a DC-DC step down buck converter).
This is fun
Good luck @SpikeyGG and definitely share your outcome.
And out of curiosity, could you share a photo of what you analog clock look like today?
Putting a stepper motor (infinite rotation, not angle limited) on the manual adjuster of an existing clock mechanism sounds like a nice idea. As discussed, a couple of Hall effect sensors behind the dial & rare-earth magnets on the hands to allow you to reset to 12:00 would ensure registration. You can then also use them to automatically calibrate how many turns of the manual adjuster - or more usefully how many steps of the stepper motor - correspond to a given angle on the hands.
Just disconnecting the battery for an hour would mean the clock would be showing the wrong time for the whole hour during ‘Fall Back’ - may or may not be an issue at that time of day!
Since most of these clock mechs use 1.5V AA batteries, you could replace it with a little 1.5V regulator module powered from the ESPHome device’s 3V3 or 5V rail - if the regulator has an ENABLE pin you could cut the power while making adjustments without needing a separate relay or FET. Saves on batteries but means the clock stops during power cuts!
I too would be interested in seeing what you end up doing whether you go this way or via the double-stepper you first envisioned, which I agree is a more elegant solution if you can get it working.
Great suggestion. I’ll see if I can run with this. Thank you for sharing the code to your cat feeder, it gives me a good starting point.
yeah, I had this idea, too. I even already have the movement from the existing broken battery-powered setup. The hand movement still works, there’s an exposed gear on the back I think it’s used to set the time when the battery is replaced (like in the photo you shared). I could try to hack it but I liked the idea of having separately movable hands to make setting the hour forward/back for DST much simpler.
Here’s a photo of the clock face I am referring to. It’s a bit cheesy but I remember it from my childhood as do all my siblings. There are actually two hands but the small hand was behind the big one in this photo…
Because much of the face is black, I could probably include a couple of IR sensors in it. I’m not sure I like the IR solution though because the room I’m planning to use this clock in is also used for VR (with lighthouses). I’m thinking the reed switch + magnet solution may be viable for periodic calibration…
I would use ESP32 in arduino to program it. It would be much easier (IMHO) to create a working clock. You already reference examples using ‘Stepper’ library.
Then incorporate MQTT to set and adjust it from HA.
Send NTP time every hour and let the ESP timekeep inbetween. If you send the NTP time a few seconds after the hour, it will automatically set the correct time with the seasonal change when NTP changes.
To drive the dual stepper motor in esphome is totally doable.
There are six partial steps per revolution (/180).
So you drive 3 pins with logic levels like this:
101 → 001 → 011 → 010 → 110 → 100 → 101 → …
You need 3 of them to make one minute (6degrees), so it’s just 18 steps per minute.
But Esp32 voltage is slightly below datasheet (3.5-10V) and since there’s no information about flyback protection, I think such approach is experimental. Of course you can use driver instead.
But the fundamental part is feedback, it would be silly to think esphome is running it forever without loosing position.