Making a Smart LED Minecraft Clock in Real Life
by thatRoland in Circuits > Clocks
86 Views, 1 Favorites, 0 Comments
Making a Smart LED Minecraft Clock in Real Life
I couldn't deny that Minecraft was a quite big part of my childhood (and to be fair, it still is).
The simplistic, blocky graphics just give themselves for DIY projects. One of the ideas I've always thought about was making a working Minecraft clock in real life. I remember that I've started building it many years ago, but I've never got to finish it, mainly because of the lack of resources and tools. However, armed with much more knowledge, experience, and a 3D printer, I've decided to give it a go one more time!
For those who are unfamiliar with the game, a quick introduction to the item in question: the clock is a device, it shows the in-game time in a curious way. In Minecraft, a day is 20 minutes long, divided into two equal parts of day and night. The clock's dial represents the location of the moon and sun, and as such, the time of the day, and shows how the day turns into night then back (there are other dimensions in the game, where there are no celestial bodies. Here the clock spins around wildly, as the time of day is not interpretable).
For this project, I've decided to use an LED matrix as the clock's face, and a WiFi capable microcontroller as the brain, so we can also add some interesting things beside it being a clock. I wish to add the following features:
- Reading the accurate time from the internet using NTP (Network Time Protocol)
- Displaying time as a 24 hour clock
- Displaying time as a 20 minute clock (i.e. the Minecraft behaviour, for decoration)
- Displaying a Nether Portal while attempting connecting to WiFi
- Wild spinning when no exact time was received, but a WiFi network is available
- The animation is smooth, programmed as a damped oscillation.
Supplies
For the project, you will need some tools:
- A soldering iron/soldering station (preferably one with variable power/temperature)
- A 3D printer (or a good friend/teacher/provider who can 3d print for you)
- Plier
- Trimmer
And you will need the following resources:
- Gold filament (I've used Gold Silk PLA filament, sourced locally)
- Any other filament (I've used Black PETG, but any non-transparent will do, sourced locally)
- For the diffusor, either:
- White PLA (sourced locally)
- A white sheet of paper
- An ESP32-C3 SuperMini Development Board (From Aliexpress)
- Or any other similar ESP32 boards, but I've designed around this one
- A 3cm x 7cm prototype circuit board (From Aliexpress)
- A power connector, either:
- A connector with female USB,
- Or a USB cable you don't mind sacrificing (sourced locally)
- 1 meter 60 pcs/m WS2812 LED strip (we will use 50 leds in total, from Aliexpress)
- A logic level converter module (from Aliexpress)
- WS2812 LEDs expect a 5V logic level, but ESP32 uses 3.3V logic level
- 8 M3x8mm screws (sourced locally)
- 8 M3xL4xOD4.2 heat set inserts (from Aliexpress)
- 24 AWG solid core wires for wiring (sourced locally)
- Superglue (sourced locally)
3D Printing the Parts
First, start with 3D printing the parts. This is a more lengthy process (on my Ender 3V2, it took around 20 hours total), and while the parts are being printed, we can start preparing the electronics of the device. I've used the following settings on my 3D printer:
- A klipperized Ender 3V2 printer
- 0.6 mm nozzle
- 0.2 mm layer height
- 15% grid infill
- PrusaSlicer
- Auto supports turned on
The recommended order of printing:
- Backplate
- LED Grid
- LED Diffusor
- Frontplate
- Frontplate decoration
The backplate and frontplate are both around 26 cm wide, just barely too wide for my 3D printer. I've designed the model in a way, that it can be easily split into two, and I've added notches for the connectors. If required, you can do the cut in your choice of slicer software (see the images). I've used snap fit connectors.
Some tips for the printing:
- I recommend brims to prevent uplifting and warping of the corners, especially if you are printing in PETG.
- I had to turn off printing a skirt in the slicer to fit the model, even after cutting it in half. This is not ideal, but sacrifices had to be made.
- Go slow and hot with silk filaments, that's what gives them their unique silk effects.
- I had to form a little bit the snap connectors with a plier, so they would fit.
While you are waiting for the backplate to finish printing, let's get to the next step.
Assembling the Electronics
Luckily, most of the electronic components are readily available on breakout boards, so we don't have to do much soldering. The following diagram will show how to connect up the components on the prototype PCB, but I will also walk you trough.
You will have to connect the following pins:
- ESP32 3V3 -> Logic Level Shifter LV
- ESP32 5V -> Logic Level Shifter HV
- ESP32 GND -> Logic Level Shifter GND (2x)
- USB connector 5V -> ESP32 5V
- USB connector GND -> ESP32 GND
- USB connector 5V -> LED strip 5V
- ESP32 GND -> LED strip GND
- ESP32 pin 7 -> Logic Level Shifter L1
- Logic Level Shifter H1 -> LED strip DIN
After all the connections are made, make sure there are no short circuits by looking trough all soldering points carefully. The end result should look something like the picture.
Once the assembly is complete, we can proceed to uploading the code to the microcontroller!
Upload the Code to the ESP32
It might seem a bit early to upload the code on the microcontroller already, but there's a good reason for that: once you start placing and soldering the WS2812 LED strip, you will need to be able to test if your soldering is fine and the LEDs are connected well. The easiest way to do this is to have some code on the ESP32 that drives the LEDs, and at that point, you can upload the actual code.
For development I've used VS Code with the PlatformIO extension. PlatformIO is a more powerful alternative to the Arduino IDE, which provides the same functionality, while also having access to the vast ecosystem of VS Code plugins and extensions.
To flash the code, you will have to download VS Code, install PlatformIO, and then download the code for the project.
The code is available in this GitHub repository: https://github.com/csroland/minecraft_led_clock
Once you are done with downloading, open the project in PlatformIO. Change the SSID and Password in the main.cpp variables to your own WiFi's credentials, plug the ESP32 in you PC, and then hit upload.
Once you uploaded the code, you should see the LEDs light up, in a purplish colour. That means the code is working!
Assembe the Backplate
For this step, you need to have the backplate fully printed. If it's not done yet, take a break! After both parts are printed, remove the brims around the object. Use a plier and a knife for that.
After gently removing everything unnecessary, snap the two pieces together. It might not be an easy snap, I used my plier to form the snap connectors a little bit.
In the meantime, start printing the LED separator grid.
Creating the LED Matrix
Once you have the backplate, then let's start assembling the LED matrix!
The WS2812 LEDs (datasheet) are RGB LEDs, that also have a control chip, which can individually address and set the color of these LEDs (these are called individually addressable LEDs). For this, the WS2812 uses 4 pins: +5V, GND, and the Data In (DIN) and Data Out (DOUT) pins. You need to connect one LEDs DIN pin to the other's DOUT pin for them to be able to communicate.
The LED matrix takes somewhat of a weird shape.
The WS2812 LED strip can be split between any two LEDs. You will need to cut pieces of different lengths from the LED strip:
- 1×2 LED
- 2×3 LED
- 1×6 LED
- 2×8 LED
- 2×10 LED
Be careful and split the copper pads in half, we will need to solder them! Then, arrange them in the pattern as above. The places of the strips are marked on the 3D model, so it shouldn't be too hard to assemble it. The first LED of the strip will be the bottom right LED, and the strip will face the left direction. The line above that will face in the opposite direction (this back-and-forth will be handled in the code).
Gently remove the cover from the bottom of the strips, and push the firmly onto their places, securing them with the adhesive tape on their bottom. Once you glued all of them into their place, time to solder!
Soldering the LED Matrix
First, we want to pre-solder all connections on the LED strips. Grab your soldering iron, set it to high heat. Once it's hot enough, press it onto a copper pad, and then press the soldering tin as well. It should flow onto the pad, and leave a little blob of tin, adhering to the copper. Do not heat it for too long, it can damage the LED strip and the 3D print under it. Repeat this to all ends of the LED strip:
Once you are done with that, connect them using the solid core wire. You will have to connect 5V to 5V, GND to GND and DOUT to DIN at the ends of the strips. Measure roughly how long wire you need, cut it, remove the insulation in the ends. Put the exposed wire on the solder blob, melt it with the soldering iron, and then remove it and let it cool. After you added a line to the matrix, plug the microcontroller in and see if the newly added LEDs light up. If yes, all good, if not, check the connections you made. In the end, you should have something like this:
Once the LED separator is finished, you can snap it into it's place.
At this point, we are done with the electronics and code of the project, only some more printing and assembling is left.
Assembling the Front Plate
Next we will need the diffusor. You can either print it out using white PLA, or just simply cut it from a white sheet of paper. Once you have it, glue it onto the LED separator grid, aligning the holes.
Once you are done with that, start printing the front plate using the Gold Silk PLA. The front plate is the same size as the back plate, so you might need to perform a cut in the slicer.
Next, after the print finished, we will have to insert the heat set inserts. We will use the soldering iron for that as well. We will have to align the inserts to the their holes, and then gently put the soldering iron into the insert, and push it into the it's place while melting the plastic. Remove slowly the soldering iron. Repeat this for all holes.
Printing the Decorational Parts
The decorational parts are simply for giving a bit of depth and texture on the front. Strictly speaking, it's not needed for the clock, but it doesn't hurt if it looks better!
I've cut the model into 4 parts in the slicer. I've also turned on ironing, to hide the layer lines on top, and give the clock a more finished and smooth look.
Putting the Clock Together
Grab the front plate, and snap it onto the back plate. The heat set inserts should align with the holes on the backplate. Take the screws and a screwdiver, and screw them to their places. Attach it firmly, but do not use too much force on the screws, the clock is still plastic.
Glue the Decoration Parts on the Front
After the decorational parts are complete, remove the brims and glue them to the front plate while carefully aligning. With this, the clock is complete! Plug it in, and it should start displaying the time.
Settings Menu
The ESP32 also hosts a settings panel as a very basic website you can access. After the clock connecting to WiFi, check your router for connected devices, one of them should be the ESP32. Note the IP address associated with it. You can also bind the IP address to the device, so it will have to same IP address always.
Write the IP address into your browsers address bar. You will be greeted with the settings on the picture.
It's Done
I hope you enjoyed the project and found it inspiring :D. I definitely enjoyed building it.
There are definitely places for improvement, feel free to remix or build new features upon the code and design!
Happy hacking.