Introduction: Chess Clock - Open Source 3D Printed and Powered by ESP32

About: I am an informatics Student that enjoys technology, 3D Modeling, tinkering, chess and the outdoors.

In this guide you will learn how to build you own chess clock! You might also learn a bit about 3D printing, circuits, soldering and programming.

The motivation behind this project is that I have been playing chess more often over the past couple of years and wanted an upgrade to the off the shelf chess clock which I have. Sadly, I found out that capableclocks are quite expensive. While searching online I couldn't find any open source project either, so, I decided to create one of my own. The idea was to be able to set any time or increment (extra time you get after taking your turn). Additionally I wanted it to be capable of setting a bonus time after a certain turn and also a different increment. That is common in tournament style games where you have 90min to begin with and usually get a bonus after turn 40. And also you might have no increment in the first part but 30s in the second part. I also came up with the idea to track the time per turn, as you can in online games and export it to your PC using Bluetooth. The latter can be very useful to analyze your own time management.


I used FreeCAD to creating all the parts and Arduino IDE to develop and test the code.

Supplies

TOOLS :

  1. A 3D printer or a friend with one. works with A1 mini.
  2. A cross head screwdriver
  3. Pliers
  4. Multimeter
  5. USB data cable for flashing the ESP32
  6. (Optional) Breadboard
  7. Soldering supplies
  8. Soldering iron
  9. Solder (get lead free)
  10. Flux
  11. Wire brush for tip cleaning
  12. Electrical tape
  13. Toothbrush and 99% alcohol
  14. (optional)
  15. Helping hands
  16. solder wick if you make mistakes
  17. Tweezers
  18. FPP2 mask
  19. wire stripper

COMPONENTS :

  1. PLA or PETG filament, i did it in 2 color but you can go from 1 to 100
  2. 8 magnets - round 10mmX3mm
  3. 13 Screws - 3,5mmX17mm wood screws
  4. 6 buttons - 6x6x6mm
  5. 2 TM1637 displays - i got these
  6. 1 - ESP32-WROOM-32 module - mine is from az-delivery
  7. 2 batteries - 16850 with pads for soldering
  8. 1 tp4056 battery charger with protection and Type-C like this one
  9. Leftover packaging foam
  10. For the extension board
  11. 1 perf board - 5cm x 7cm 1 sided is enough
  12. 2 connectors - 40pin 2,54mm JST Connector strip male and female
  13. Some wires for connections - any cable
  14. 5 resistors - 68k ohm or anything between 47k and 100k ohm
  15. 2 resistors - 1M ohm
  16. 3 resistors - 100k ohm
  17. 2 diodes - IN4001
  18. 1 transistor - C945 or other npn
  19. 1 mosfet - NDP6020P or any p-mos with a low Rds(on) at 2,5
  20. 1 voltage booster from ~3V to 5V like this

The total cost of building the clock was 18 euro including filament and shipping. Excluding my time, the tools and solder. Some of the parts I bought in bulk.

Step 1: 3D Printing

I have provided a profile (.3mf) for printing all the parts so you don't need to tune anything. Just follow the instructions. If you are using it you also won't need to open any of the other files. If not, I have provided the original .step file and instructions on how to print each part.

Tips for the once not using the .3mf:

I recommend printing with 3 Wall loops and 5% infill. Use brims for mouse years for the main body and the bottom as they can warp. Supports are only needed for the main body and can be very minimal if custom drawn.

Step 2: Printing the Turn Switch

There is a pause right before the cavity in this part is closed. During the stop you need to place 2 magnets stacked in each slot. Place them in opposite polarity as it will make the next step easier. Then continue the print.

Tips for the once not using the .3mf:

You need to add the stop right before the cavity in this part is closed. For me its at 20.8mm or layer 104. Print on the side.

Step 3: Printing the Body

There is also a pause while printing the main body to add a stack of 2 magnets in each hole. If you placed the magnets in the previous step using opposite polarity, do the same here. Otherwise, make sure the Turn switch is attracted on both sides of the main body.

Tips for the once not using the .3mf:

You once again need to add the stop while the holes for the magnets are still accessible. For me its layer 167 or 33.4mm of the build plate. Print on the face where the screens will go and add a little support on the back as seen in the picture. If your printer is better at bridging you can use less supports.

Step 4: Print Buttons

If you have a multimaterial printer you can directly print them. No worries if you don't, I don't either. Without moving the buttons, delete all the white parts (the button itself). DON'T SAVE the project now. Print only the symbols and leave them on the plate. Then undo all the deletes and delete the symbols instead. Change the filament and print the buttons.

Tips for the once not using the .3mf:

Just add all the buttons and make sure the first layer is 0.2mm. Then print as described above.


PS. Taste_2 is the correct shape with no symbols if you want to create your own icons.

Step 5: Printing the Rest of the Parts

The rest of the parts require no special attention. Just print.

Tips for the once not using the .3mf:

You need to print:

  1. 1 Bottom - add mouse years or brim
  2. 1 ESP_Clamp
  3. 2 Battery_Clamp
  4. 4 Display_Holder

Step 6: Flashing the Esp32

For those that haven't yet flashed an ESP the easiest way is using Arduino IDE.

You need to connect your esp32 to the PC using a USB cable. Check in device manager if the board is recognized. Mine shows Silicon labs CP210x usb to uart (COM X). X here is a number of the com port. Remember that.

Download and install Arduino IDE. When you open it got to File>Preferences and find a field named Additional Boards Manager URL and add https://dl.espressif.com/dl/package_esp32_index.json .

Then go to Tools>Board>Boards Manager and search for esp32 by Espressif Systems.

Once you have installed the module you can go to Tools>Board and select ESP32 Dev Module

The last step is to install 1 library that is used for controlling the screens. Go to Tools>Manage Libraries and search for TM1637. Install the one from Avishay Orpazas seen in the picture.

Finally you are ready to install the code onto the board! To do so click the arrow to the right just below edit that says upload and you are done.

If you followed a guide and imported the board and it is still not working check these out.

Common problems:

  1. Missing usb drivers, Check in device manager.
  2. USB cable with only power. Try a different one.
  3. Incorrect port in the arduino IDE. Go to tools and look for Port. Set the one you see in device manager.


I am going to upload the code to github and probably add features in the future so you can also check this link for newer versions.

https://github.com/curlyman98/ChessClock-ESP32

Step 7: Prepare the Connectors

You need to break the 40 pin in sections of different lengths. Its is easy using pliers.

  1. 2 female connectors of length 20 pins - for the esp32
  2. 1 female connector of length 6 pins - for the displays
  3. 1 female connector of length 3 pins - for connecting buttons to board
  4. 1 female connector of length 2 pins - for connecting charger to board
  5. 1 male connector of length 5 pins - for the buttons
  6. 2 male connectors of length 4 pins - for the displays
  7. 4 male connectors of length 1 pin - for the booster
  8. 2 male connectors of length 2 pins - for the battery charger
  9. 1 male connector of length 12 pins - for the plugging all connectors to the board

Not all required lengths are in the pictures!

Step 8: General Soldering Tips

You can skip this if you already know how to use a soldering iron.

  1. Make sure the tip of the iron is clean and solder sticks to it.
  2. Don't make it too hot or it will degrade.
  3. Tin all cables and connectors before soldering them together. This makes it MUCH easier.
  4. If you notice the solder doesn't stick to something add some flux and apply heat using the soldering iron.
  5. Add always have some thin on the soldering iron when working with it.
  6. Don't use too much tin as the joints can merge and cause problems.
  7. Isolate cables with electrical tape.

Step 9: Prepare the Perf Board

Plug the 2 connectors of length 20 on the ESP32 and put them trough the perfboard on one end on the board. Leave one row beside the esp and break of the rest. You can score the cut line using a knife to make it break cleaner. After breaking it solder the Pins to the perfboard to keep them in place.

Step 10: Prepare the Boost Module

Place 4 single pins in a breadboard an the booster board on top. Then solder the pins to the booster board.

Step 11: Prepare the Batteries and Charger

Make sure that the batteries have the same voltage! If not charge one and equalize thembefore soldering them together. Place the batteries on the bottom to get the correct distance and solder + to + and - to -. Also add a wire to each that connects to the battery charger. Prepare the battery charger by soldering the 2 pin pairs to the out+ and b+ and to out- and b- in a similar fashion to the booster in step 10. Solder the wires from the battery to the b+ and b-. Then solder 2 wires to the out+ and out- on one end and the prepared 2pin female connector on the other side. Place some foam on the batteries and screw in the Battery_Clamps. Slide the charging module in place and the bottom of the build is ready.

Step 12: Soldering the Displays Together

The screens are mounted with the text to the top. First you need to solder the to 4 pin connector to the displays next to each other as seen in the picture. Then connect the GND and 5V of the displays with a short wire. As a last step you need to create the connector for the displays using the male 6 Pin connector and longer wires (10cm). It has GND on one end and 5V on the other. The middle pins are the DIO and CLK of the 2 displays. Their order doesn't matter as the pins can be swapped around in the code later on. When you are ready wrap all connections.

Step 13: Soldering the Buttons Together

You need to wire the buttons as shown in the diagram. The 5 PIN is the male 5 pin connector and the 3 PIN is the female 3 pin connector. The red wire going to the 5 pins is 3,3V, take care to place it in the middle of the connector. The red and black wires are about 10 cm. The short once connecting the buttons to each other are ~5cm. The wires connecting the buttons to the 5 pin are all with different lengths. the one on the left in the diagram is the shortest and the other ones get longer. Look at the assembly video to gauge the length required.

Step 14: Soldering the 12 Pin Connector to the Board

The longer side of the 12 pin connector should be bent at 90° as close to the black part as possible. Alternatively, you can use already bent connectors if you have them on hand. Then solder them to the extension board facing outwards so you can plug the connectors in.

Step 15: Making the Extension Board

We are almost there but this is probably the biggest task. Soldering everything on to the perfboard.

The first picture show the logic of the circuit. In a nutshell the batteries are boosted to 5v to power the ESP and the displays. The P-MOS disconnects the booster from the rest so there is no power draw when the device is off. The power button turns the MOSFET on and the ESP powers the NPN transistor to keep it self on regardless of the button. The ESP can also detect if the power button is pressed and upon holding it, power itself off.

The second picture shows how the resistors and diodes should be placed to save space.

The last is the most important one. It shows the layout and how everything is connected. The borders are separations and the red connections are connected to the other red square with the same number. Only the 2 1M ohm resistors should be laid flat on the board as the will end up under the booster. So make sure to solder them before the booster.

Step 16: Soldering the Buttons Connector

Align the 5 pin female connector with the pins and solder them together.

Step 17: Clean the Extension Board and Checking It

Use a toothbrush and 99% alcohol to clean the board, as left over flux can cause shorts. Using a multimeter, check if some of your solders are touching and fix them if it is the case.

Step 18: Assembly

Its time to put everything together! Its probably hard to explain so I made a video of the assembly. Start with the screens, then the buttons. Continue with the esp and its clamp and at the end the extension board. Make sure to not plug the the usb and the power cable at the same time. For testing i first assembled it with a usb cable and without the batteries connected. You can arrange the buttons in any order you like except for the power button as it is wired differently.

Step 19: Tuning and Finalising

If you assembled it with the USB cable you can plug the cable in a computer and see if everything works. If the screens aren't working properly check and update the corresponding pins. Once the screens check if the buttons correspond to the correct version if you moved the buttons or the cables around that might be the case. Just change the button_x pins and it should work properly.

Once that is done, you need to calibrate the hall sensor as all chip, magnets and filament are different. Hold the battery button and press settings. You will enter the calibration mode. One screen will show cali. Press play and it should start. Switch the Teeter_Totter to the side of the fully lit screen. Pay attention as you need to change it once during the calibration. When its done you will be back at the cali point. Press settings to move on. You will first see the current readings. Then the calculated values for both sides. You are able to change them with + and -. When you exit the values will be saved and you won't need to do that again.

Once all buttons are correctly assigned you can unplug the usb from the esp and plug the batteries into the extension board.

Step 20: Using the Clock

Its finally time to have fun with the clock.

To turn it on, hold the power button. It's the same for powering it off.

When it is on you have several options on how to change the settings. Firstly, when the game is not running you can just press + and - to add time. If you press settings you can change the increment, the bonus after certain turns, the inc(2)rement after the bonus turn, and finally the bonus turn. You go trough them by clicking settings. This changes it for both players. If you want to set different times you can hold settings and you will enter the complete menu. There you can set H m and s for P1 and P2 as well as bonus and increment before and after the bonus turn.

You can also hold battery to see the battery level. While holding battery, you can use + and - to change the brightness of the screens.

If for some reason the turn switching doesn't work perfectly, you can run the calibration once again or tune the threshold values in the calibration menu.

You may start the game with play and then you can pause it. During pause, you can press settings to reset the game. If the game ended and someone flagged, you can press play to reset the clock.

Step 21: Final Thoughts

Thank you for coming along for the ride!

I hope you make one for yourself! Enjoy the process and the final product. Make sure to check back on the github for updates as I intend to make a compatible app so that you can view your game times on your phone and export your games as timestamped PGNs. I will be happy to see your suggestions and contributions.

Thank you and bye!

baiblagoi