A Clock With Potential

by ShehanW_5 in Workshop > 3D Printing

1247 Views, 2 Favorites, 0 Comments

A Clock With Potential

clock main.jpg
butttons open.jpg
buttons closed.jpg

I'm quite sure that pretty much all of us have struggled with phone addiction while trying to get work done. I had heard of lock boxes in which you could lock a phone in for a certain period of time, but I always thought a better solution was possible. So, I tried to make a device which works as a clock, doesn't look half bad, and can be used to lock an overly distracting phone away for a set period of time.

Supplies

ESP32 - (could use an arduino nano and an RTC for time keeping, but I wanted to stuff around with WIFI as well so I got one of these)

144LED p/meter WS2812 Light Strip

28-BYJ48 Stepper Motor - (any stepper motor would be fine, and probably more accurate, but the design would have to be changed)

  • also, I modded mine to a bipolar stepper motor and used an A4988 driver
  • Ardufocus | 28BYJ-48 Bipolar Mod - link for doing this mod
  • Everything will work perfectly fine if you don't mod anything and use the default uln3003 driver.

SG90 Servo Motor

4 5mmx5mm buttons

Prototyping Circuit Board: 5pcs Strip Board Printed PCB Circuit Board Vero Prototyping Track Stripboards | eBay

An old usb cable you are willing to part ways with

Lots of female to male/female dupont cables (I used probably around 20)

Access to a 3D printer and Laser Cutter (optional but I think does give a better finish)

10cm of 3mm rod

1x M3*30mm

2x M3*50mm

1x M3x12mm

3x M3 Nuts

5 3mm M3 set screws

2x 3x8x4mm bearings

1x 6x10x3mm bearing

Solder

Printing Out the Parts

mainbody print.jpg

After what feels like days in Fusion360, I came up with the final STLs. I printed everything on an Ender 3 with a Microswiss Direct Drive, but they should really print on any printer. I used PLA for everything including the gears. I don't believe that the slicer settings need to be very specific, but the only caution is to use a raft for the gears and hour hands to prevent elephants foot from reducing the hole diameters. Also, all parts except the RGB Hub and the Main Body should print without supports.

There isn't anything too crazy with the model, but the one thing which I found after much frustration with sticky gears is that by cutting around 0.3mm from the end of the all teeth of the gears really helps to ensure a smooth gearbox.

The front and back plates can be printed, laser cut, or cut by hand, as long as they are 3mm thick.

Assembling the Parts

buttons.png
side cover.png

I first inserted the servo mount and buttons, putting the screws through the holes on the end, tightening into screws placed onto the part. You will also need to cut the 3mm rod to size ____. Next, I screwed the stepper motor into place using a m3 screw (only one screw fits, the other interferes with the gears, but just one tight screw seems to do the job just fine. The gear going onto the stepper motor does require some force, and I carefully used a screwdriver and hammer to get it on. Then, you will have to place the other gears onto their axles and through both the seperate piece the stepper attaches onto and into the mount which is part of the main body. Also try to put the slider on its railing on the main body at this step, but it can be done after connecting the side and main bodies, but will require some fiddling. Also attach the servo attachment to the servo before placing it into its mount. Finally, you will have to assemble the button assembly which I have provided a photo of to show you how it works. The pushbuttons need to be inserted into the button base. Screws will then have to go through the button assembly and servo mount to hold them in place.

Then you can connect the side piece to the main body using the 4 slots which go into holes in the main body. This definitely will require the careful use of a hammer. However, if you line up the two parts and it clearly seems like the slots will not go into the holes, you may have to use a chisel to reduce the sizes of the slots slightly. I had some rather significant warping so one hole was much smaller than it should have been. The slots are quite strong, but still take care. I actually managed to break 2 off, but it still all went together fine.

The bearings really aren't that necessary as there isn't much motion occurring, but without them, the rods won't fit straight. If you want me to provide some modified STLs without the bearings let me know and I will happily oblige.

You will have to cut 30 leds from the strip and place them in the RGB holder. Next you will have to place the cover with the clockface on the side of the gears, and insert the slots of the RGB holder into the holes of the side and main bodies. I would do this after soldering wires to the light strip, and place these through the cutout. You may have to rotate all the LEDs so that the start and end point of the strip is adjacent to the cutout. Again a hammer may be required to get this piece into the holes.

Lastly place the hands onto the plastic mounting point on the gear and the 3mm rod.

I will say, a better finish could definitely be achieved by sanding, priming and painting the 3d printed parts, which also allows for pretty much unlimited customization


Electronics

Circuit Diagram.png
bottombuttons.jpg
shared pcb.jpg

There are really many ways you can do this. I have provided a rather basic circuit diagram below. I tried to make it as less permeant as possible, but unfortunately I didn't have a small enough bread board to fit inside the clock. Instead I just cut 2 strips of a prototyping soldering board to use as a common ground and +5V. I would advise to take significant care with the wiring, especially of the A4988 stepper driver, as doing it wrong can destroy some components. I had to cut the ends off some female-female/male du pont wires and solder them to the prototyping board, and used the female ends to connect to the ESP32 and A4988. I also cut, and soldered female du pont wires to the stepper motor, servo motor and push button to make them easier to connect. It is probably best to use the circuit diagram below and my picture for reference, but it is quite crowded. It doesn't really matter how you make the connections though, as long as they are made. For the wires connecting to the ESP32, it doesn't really matter what pins they are connected to, as long as it is a Da pin (where a is some number). You will have to change the values for the pins at the top of the code though.

I used a usb cable to provide power. Simply cut the cable somewhere along, and strip back the insulation. There should be a black and red wire which are all they you need, and solder your own wire to these. Just use a multimeter to check that you have got the right wires.

Also, I would be careful when wiring the RGB strip as some models don't have reverse current protection so you could blow the whole thing. I cut a few LEDs and did a test just to make sure I had the right polarities.

Code

Again, there isn't anything too special with the code, and there defintely are many features I want to code in the future, or that you can make.

  • a pomodoro timer
  • using the ESP32 as a server and changing its settings remotely
  • a working timer -> and a clock which can switch back to the correct time after the timer finishes.

I used the Arduino IDE, and you will have to download some libraries.

You will also have to install the ESP32 board to the IDE. Below is a great resource I followed to do this:

Installing ESP32 in Arduino IDE (Windows, Mac OS X, Linux) | Random Nerd Tutorials

One thing I got stuck on in this process was I couldn't figure out how to install the CP 210X drivers after installing them. You have to download them (link in the above resource), unzip, right click on one of the two (try both) and click install.


You will have to change the SSID and password at the top of the code to your WIFI name and password.


If you go to the setLights function, you can change the colours which can be set as the backlight. I have commented the colours which I have set, but you can change the RGB values in the different if statements to suit whatever colours you would like. Try not to add more if statements as you won't actually be able to access them.


The entire operation of the clock is managed through 4 buttons, so I will explain how I have set it up to work

  1. Long press on the top button to enter calibration mode. Use the top and bottom buttons to move the stepper until the hour hand is at 12. Then move the minute hand by hand so that it also is at 12. This may have to be done every so often if you find that the time etc. seems out of whack. Press the right button to leave this mode.
  2. Double press the left button to turn on/off the lights. This isn't really sensitive, so you might need a couple goes.
  3. Long press the left button to cycle through the different colours for the clock backlight. Use the up and down buttons to cycle through, and press the right button to leave this mode.

Now that comes to the end of my coding ability. I wanted to have a long press of the right button enter a "timer setup" mode where the user can set how long it is, decide whether they are using the lockbox, and whether they want the lights to follow the timer. However, I couldn't not get all this functionality coded, and faced the large problem that I could not then figure out how to accurately get the hands back to the right clock time. Hence, I need to go and spend some time to figure this out, and if anyone has any suggestions or even reckons they know how to do it, I would be happy to hear. And I apologize in advance if the code is really messy, programming definitely isn't my strong suit.


Downloads

Conclusion

So thats it. Hopefully you have a working clock with potential to do many cool things in the future. This definitely isn't the end of this project, and I will for sure add to this as I figure out how to add the other features I want to. There is still a lot I want to improve this clock, like painting it, making the RGB leds follow the hands in clock and timer mode, and coding in some more features to it, so keep looking out for further updates to this instructable.

Also, I placed some holes in the main body with the idea of putting magnets in them so that other objects, like a stationary holder can be designed and magnetically attached to the clock, so I will also be exploring that as well

This is my first instructable so this definitely isn't going to be the best one out there, but I am happy to provide any details I can if asked for.