Making a literal digital clock

This is the start of a bigger project, splitting it up in different pieces.
Sit back and relax, its gonna take some time ;-)

Public Chat
Similar projects worth following
Using an ESP32, and double shaft stepper motor x40 I will create an analog clock that despite its looks is digital. I will be 3D printing and designing the whole thing from the ground up. Although you might catch me slippin on the hardware side, as I'm more of a software guy.

What you will see in my project.

- Mistakes

- Mistakes

- Small Progress

- More Mistakes

and then we loop until we are done with the project.

The plan!

To make a smart clock with some cool formations of the pointers!

  • I will use ESP32 as my board. Why you might ask? They have wifi, bluetooth, many IO pins for its size and they are quite inexpensive when bought from china.
  • For the motors I first tried to design my own dual shaft stepper motor with two small stepper motors and many gears! Then after designing for a small month, I realized    that China obviously already have this. I will be testing the X40 china copy of Switec and the less expensive BKA30D-R5.
  • To keep track on time I will either use WiFi or RTC.
  • To keep track on the pointers location, I will try to brute force a software solution with saving the steps in the EEPROM, if this fails I could probably use a retro reflector sensor.
  • To get familiarized with driver motor, I will use the infamous x12.17 stepper driver which also allows microstepping. This allows me to cut the I/O pins needed in half. The driver can control two double shafted stepper 4 wire motors. A double shafted motor, is basically two single shafted motors that use 4 wires, so in total 16 motor wires can be controlled with the x12.17. Each motor needs a direction and how many steps it should take so that's 8 pins, hence the I/O pins gets cut in half.

I might make some sketchy PCB design and solder a prototype.

Then we take our hammer and mallet and put it together, how hard can it be?

  • 1 × ESP32 Microcontroller
  • 1 × X40 double shaft motor Get the version without end stops, to get 360 degrees freedom
  • 1 × DS1307 Module RTC - real time clock But any RTC will probably work
  • 1 × M-S Quad Driver X12.017 THIS IS NOT STRICTLY NECESSARY, but I will be using it. You could drive the motor directly from microcontroller
  • 1 × 3D printer or access to a makerlab

View all 6 components

  • 10-04-2022 Testing the accelstepper library further

    flamefire2 days ago 0 comments

    Short video of testing the accelstepper library with some more precise and smooth movement. 

    I am thinking about homing the stepper motors in reference to the minutes and hours. 

    Next I would like to step on the interrup of the RTC, so that the stepper motors Is moving according to the real time.

  • 09-22-2022 Testing the RTC time accuracy

    flamefire09/22/2022 at 21:54 2 comments

    Basically I tested and followed the tutorial from workshop. However the accuracy of my RTC was at best 30 sec off.

    Instead I made a test where I connect to an NTP server, retrieve the time and set the time in the RTC module accurately. This conveniently also fixes the RTC modules inaccuracy over active time, which I've read could be anything from seconds or minutes a day, depending on the module.

    Picture below is the accuracy of the NTP server, which is basically one to one.

    Testing NTP server accuracy

    The picture below is the RTC time which has been set with the data from the NTP server and very accurate. Will check how much it differs from the real clock over time. But should be no problem because now we can connect to the internet and update it.

    You might be wondering why not just throw the RTC in the thrash where it belongs? We might not always have a secure connection. This is why as soon as we have an connection we just update the RTC. Will this kill the battery? Most certainly it will, but that is tomorrows problems.

    I will push all the test software up on my github when I the project is finished.

    The next I will look at is making an interrupt on the squarewave from the RTC and make the motor move according to the time! :)

  • testing the motor and driver 09/19/2022

    flamefire09/19/2022 at 12:40 0 comments

    First I made some test PCB's for the x12.17 driver. I used 28 SOIC boards and soldered away, and burned my nose, don't ask how! I wired everything up, credit to this guy : check out his other stuff, like how to remove end stops from the motors if you happened to buy them with end stops as I did.

    I tried 2 different libraries to control the stepper motor and manually.

    SwitecX25 / SwitecX12 library

    Guy.carpenter added an extension to the SwitecX25 library to use with motor driver called, its called SwitecX12.

    Conclusion: Couldn't make it work, and I have no idea how.

    I manually pulled step pin LOW and HIGH with correct delays and such according to the datasheet of the motor driver.

    This was actually working, it was smooth and controllable and also microstepping. For a single motor this could suffice.

    Conclusion: Great but probably not ideal for more than one or a couple steppers, they would not be synchronized, as we are calling blocking functions. This would ultimately (probably) screw up the timing and steps in the long run. I could make my own stepper library, calling timers, flags, triggers and what not. But I'm too lazy and I hate low level.

    Video of manual stepping:

    Accelstepper / continuousStepper library

    I used the Accelstepper library to run a simple test on both motor pointers.  Where I use the AccelStepper::DRIVER setup. This seems to work alright, I will try to look more into this library as I believe this is the way to go. This library supports drivers, uses non blocking code, so multiple steppers could be used, and it is quite popular. 

    See AccelStepper documentation here:

View all 3 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates