Retro Analog Wall Clock With Internet Clock Control
by hausofpayne17 in Circuits > Clocks
122 Views, 1 Favorites, 0 Comments
Retro Analog Wall Clock With Internet Clock Control
My grandparents always had this elegant 1950s vintage wall clock in their house. It never kept accurate time. You frequently had to take it down and shake it to get the rotational pendulum running again.
Eventually the works were replaced by a battery powered module but again, my grandmother had a hard time taking it off the wall and changing the battery.
I've had this clock sitting idle over my workbench for over 30 years, hoping to spruce it up some day. That day finally came. I decided to convert it to an Internet Clock.
Advantages:
- The clock is powered by an AC adapter so there is no battery to be changed.
- After a power failure, the clock automatically resets itself.
- The time is always accurate.
- The clock compensates for Daylight Savings Time automatically.
- It has a configuration web interface allowing the user to connect it to the home WiFi and to set Time Zone and DST status via a web page rather than having to hardcode the credentials and settings into the firmware. As a result, it will work anywhere in the world.
Disadvantage:
The 3D-printed gearbox is not a precision brass gearbox and the stepper motors are not perfectly accurate, so there's a bit of gear slop that shows up during the course of an hour. Not a big issue as the clock hands re-home every time they get to 12. There is the ability to partially compensate for this slop in the software.
I want to express my appreciation to Erich Styger for his Analog Clock project. He designed a great set of 3D-printed and Laser-cut clockwork parts that made it possible for me to do this project. I modified his files for this application.
For a further explanation of how the web-interface library works, I recommend the excellent Dronebot Workshop tutorial.
Supplies
An analogue clock to upgrade
An ESP32 DevKit or other ESP32 with sufficient pins for:
- 2x Hall-effect sensors
- 2x BYJ-48 Stepper motors (8 data pins)
- 1 Push button for entering Configuration (web-interface) mode
- Built-in WiFi (you need to make sure your available pins for the motors/button aren't needed when WiFi active)
I just used a very inexpensive 32 pin standard/generic ESP32 Dev Board. It does not have to be a modern one (like an S3 etc).
- 2 - BYJ-48 Stepper Motors and Controller boards and mounting screws.
- 1 - SPST Momentary Contact Switch.
- 2 - 3441 Hall Effect Sensors (or similar)
- 2 - 7mm x 4mm x 1mm Neodymium magnets to calibrate the two hand gears
- 1 - 5V ~1 Amp DC power adapter with appropriate female power jack.
- 1 - Small Prototype board (ex. 50mmx70mm is fine).
- 1 - Piece of 3mm rod (solid or hollow) that will act as the minute hand shaft. About 150mm of material is more than enough for this project and will give you extra. One kind of material that works is "pushrod tube" used in radio control airplanes. It's like a plastic straw. It typically comes in 36"/1 metre lengths from a hobby shop. Solid material is fine as well.It just has to be of sufficient diameter to fit through the hour gear shaft without binding.
- 4 - 6-32 x 2" machine screws and nuts for assembling the clock works. 3mm screws are fine as well. In both cases you may need to drill out the holes to enlarge them slightly. (3mm screws are also fine if you get them over 50mm length)
- Thread lock adhesive if desired.
- 3D filament to print the gearbox parts.
- Glue as appropriate (I used hot glue, super glue and epoxy in different sections).
- Extra hardware to mount the clockwork module to your particular clock. I used a 3/8" threaded lamp rod segment and nuts to mount my module to the clock face.
- Thin gauge wire for the circuit.
I prefer to use female terminal strip to mount my ESP32 module to the circuit board as it minimizes the chance of damaging the board during soldering and it allows swapping out the module as needed. This is just personal preference.
This is not a beginner project. It assumes you are very familiar with programming an ESP32/Arduino and with 3D printing and soldering.
This tutorial will take you through printing and assembling the gearbox and then uploading the Arduino sketch to run the clock.
You may then take this generic gearbox/module and put it in your own clock.
LET'S GET BUILDING!
Build the Clock Works
Watch the assembly video provided. The parts are printed in contrasting colours for demonstration purposes only.
Print off the parts for the clock works as provided. I used about 10% infill. Since the clock is not moving quickly, the gears should not wear excessively but over years, the gears may start to get more 'slop' in them from wear.
You'll notice there are different types of spacer tubes. The ones with the sliced-off sections are for the sides of the module where the backs of the stepper would interfere with the regular full tubes. They may need to be adjusted slightly for your particular motors. Print two of each.
Mount the motors in the their respective mounting plates as per the photos. Try to get them as parallel to the mount services as possible so the gears will all be in plane.
You may want to enlarge the motor case holes somewhat so the motors will not bind against the mounts and thus be out of alignment.
Assemble the clock works as per the diagram. Start by inserting the gear bearings and gluing them with epoxy or super glue. It's recommended you scuff up the mating surfaces a bit to get the best adhesion. The holes to receive the bearings may be about 0.5mm larger than the bearings. When gluing I try to have both bearings touching the same side of the holes for both the top and bottom mounts so they'll be as best aligned as possible. Don't do any more gluing of gears, magnets or side-panels at this point as you'll want to experiment with the entire assembly and the circuit to make sure your gears move as freely as possible while being well-aligned.
You will likely have to enlarge the screw holes slightly. I used a 1/8" drill bit to enlarge sufficiently. You may also want to enlarge/extend your motor mounting holes slightly if you find there is too much slop between the motor gear and the hour/minute gears.
Do NOT mount the magnets in the gears UNTIL you have completed the circuit construction and you've built the Hall Effect sensor cables. You'll need to experiment with the orientation of the magnets so they'll be properly oriented to trip the sensor as they pass by.
When mounting the gears to the motor, use either hot glue or epoxy. Either is fine but the advantage of hot glue is you can pull the gear off again if you must.
The RearPanel.stl file is optional. It may be used if you have mounted your motor controllers on the provided motorControllerMount.stl parts and mounted them on the sides of the gearbox.
Build the Circuit
Use the provided diagrams to help you assemble the circuit. Notice that the table of available pins shows the pins that are not available on the Dev Module as they are used by the WiFi on ADC2.
In particular, the Signal pin of each Hall Effect Sensor is pulled HIGH to 3 or 5 volts. The sketch works by detecting a LOW value to indicate the magnet / gear is in the "12" or "home" position. Each signal pin has a 10K pull UP resistor goes to the 5 or 3 volt rails in your circuit.
The button has a 10K pull DOWN resistor that also joins the signal side of the button (typical configuration).
In the photos you see all this hot glue all over the wires. I make my own patch cords and use the hot glue to secure the soldered joints. I also soldered the wires to the terminal strips at 90 degrees to minimize their profiles to keep the gearbox compact and small.
Once assembled, attach the stepper motors and Hall effect sensors to the circuit. You'll test the circuit to determine the polarity of the magnets.
Load the Test Sketch and Test the Circuit
Load the ClockHallEffectCalibration.ino sketch on to the board. It runs both motors for several revolutions.
Open the Serial Monitor and use this sketch to try passing the magnet by the hall-Effect sensors and change the orientation until the sketch stops. When you see "Magnet detected", use a marker or some paint to indicate the edge of the magnet that will pass by the sensor to indicate the clock's hands are at the "12" position for calibration.
When you've got the magnet sides identified, mount the magnets in the two hand gears with the coloured edge UP and towards the teeth of the gears. Hot glue is recommended as you can adjust and remove/replace as needed.
Now attach the minute hand shaft to the minute hand gear with some glue and attach the Hall effect sensors to the sensor mounts with some hot glue. You want the more narrow part of the sensor pointing towards the gears. You will need to adjust them a bit in the housing so they are close enough to the gears to detect the passing magnet without binding with the magnet as it passes. Take your time.
Try the entire assembly with the test sketch to see that the gears move as freely as possible without too much play in the gears. The gears are not precision and there will be some play and that's okay. If there is too much play, you can use a Dremel-type tool to extend the screw holes for the motors towards the hand gears so you can swing the motors inwards a bit to reduce the slop.
Downloads
Testing / Tuning the Clock Sketch
Load the clock sketch on to the Dev Board. Read through the ample comments. The 'configSave.h' file contains the code for generating the WiFi Access Point for configuring your clock and for saving/reading the configuration settings and WiFi credentials in the storage area on the ESP32.
The basic way it works is:
setup() block:
If the momentary contact switch is held down during power up/reboot, the sketch goes into Config mode. This has the board launch a WiFi Access Point that broadcasts itself as a network. You go into your network browser on your device/phone and you can pick the WiFi network to have the clock attach to and enter the login credentials. The access point is called, "aClock AP". If you wish to change the name and password, you'll find that AP broadcast statement in the 'configSave.h' file.
At this point you can also specify the time zone for the clock with reference to Greenwich Time (UTC).
Any point WEST of Greenwich, England is a NEGATIVE number for time zone hour adjustment. Anything EAST of Greenwich (ex. Belgium) is a POSITIVE number.
You can also specify if your location uses Daylight Savings time. '1' = Yes, '0' = No.
When you click 'Save Settings' on the screen, it will write those settings to file system space on the board. Every time the ESP32 boots, it tries to read these values and use them to log the clock on to your WiFi and configure the clock to get and display the correct time.
Otherwise, the clock starts, attempts to join the WiFi network and gets the time from an ntp server. Then it runs a homing function to calibrate the hands to the "12 o'clock" position. Note that the minute motor runs backwards compared to the hour motor because of its orientation inside the clock works. The minute hand swinging backwards at the beginning of homing is just to try to make sure it's not near 12 so that it will home to 12 as accurately as possible.
There is some delay time built in to the sketch with a "Stop" message that shows in the Serial Monitor that you'll use to turn OFF the module with the gears in the 12 o'clock position so you can mount/glue your clock hands properly at 12 o'clock.
loop() block:
This is a pretty simple section. It just checks every second to see if the time on the built in real time clock has changed.
It then updates the hand positions appropriately.
setMinuteHand() function:
Besides moving the minute hand appropriately, this function also lets the hour hand creep along to show the passage of time for the hour hand.
As well, this method attempts to compensate in the slop in the minute gear especially when the minute hand is moving from 6 up to 12. In this lower part of the hour, the longer limb of the minute hand is being pulled downward by gravity and it can show an inaccurate minute value compared to the top half of the hour. You may wish to adjust the interval advance a bit to make it work as well as possible for your particular stepper motors and gear setup.
Note: This is NOT a precision brass gear gearbox. There will be some minimal gear slop. But over the course of an hour, the minute hand will be quite accurate and it always re-homes whenever either the minute or hour hand re-approaches 12.
Installing in Your Own Clock Housing
Now that you have the clock works and sketch all working, install the module in your particular clock. In my project, I designed a conformal mount that attached behind the clock, that had a printed recess in to which the clock work module mounts with hot glue. I attached this mount to the clock face using some 3/8" threaded lamp rod and nuts.
Your particular clock will dictate how you mount the module.
Once the module is installed, you can use that "Stop" message time in the sketch to turn off the module and mount the hands at the 12 position.
If you don't like the light from the stepper controllers , you can just cut off the 4 resistors that join to the LEDs on the modules.
If you don't want the power light on the ESP32 on, just careful desolder the LED from the Dev module or carefully snip it off with flush cutters.
Final Thoughts
This was an important project to me personally because I was able to resurrect my grandparents' wall clock that was a constant presence in my childhood.
It was another opportunity to use the WiFiManager library for provisioning credentials into the module instead of having to hard-code the login and time zone credentials into the sketch. It's a great library for adding flexibility and ease of use to your WiFi-enabled projects.
In our modern world, there are no shortages of clocks for us to check the time. But this is a way to bring modern accuracy and resilience to an attractive analog timepiece.
Enjoy!