Introduction: Tetris Time Clock on a RGB Matrix With ESP8266
I had this RGB LED matrix lying around for a while. I used it with a arduino mega (works good but no easy internet connection) and raspberry pi (flexible, but a big overhead and long startup time). So I was looking for a better solution and I found it when I saw this article on hackaday: https://hackaday.com/2017/11/28/a-minimalist-weath...
Dominic Buchstaller built a neat library for the ESP8266 to drive these RGB LEDs matrices. So connecting to the internet for NTP sync is no problem anymore. It also boots up instantly and can be powered off without shutting the system down before.
I had the idea to build a NTP synced clock and was looking for a creative way to display the time using available colors. After some googling I found a monocrome version of the tetris clock in some china shops. So I decided to build something similar using colors.
Step 1: Parts List
For this build you need the following parts:
- Wood strip 9 x 20 mm from the local DIY store (link)
- Acrylic glass 22 x 13 cm from the local DIY store (link)
- One-way mirror foil for windows (grey) (link)
- NodeMCU ESP8266 board (e.g. LoLin) (link)
- Micro USB <--> USB cable, maybe you have one spare from your phone
- USB power supply with at least 2 A power to drive the matrix
- Adafruit 32x16 RGB LED Matrix (link) or a cheaper version from china (link)
Please note: These matrices exist in different pitch sizes P10 means 10mm and results in 32x16 cm panels. The latest build is based on a P6 matrix that is roughly 20x10 cm in size. - Dupont jumper cable female to female (link)
- 3D printed parts from https://www.thingiverse.com/thing:2846368 (Fitting for a P6 matrix)
- Matrix grid
- Grid clamps
- Left and right stand
- ESP8266 holder
Step 2: Optional: Making the Matrix Flat
In the first version I wasn't very happy with the clearness of the pixels. The matrix isn't flat, because the front plate has thin horizontal ridges the lat the light flow to neighbor pixels.
Dominic Buchstaller gave me a hint:
You can loosen all the screws of the panels (see images) so that the front plate can be taken away. Then you have two options:
- Leave the front plate and just rescrew the matrix. Then the LEDs fit nicely into the printed grid.
The drawback is that you can't use a diffusor between matrix and printed grid. - Turn the front plate around so that a flat surface is created and then resrcew it.
I chose this option and it looks much better.
Step 3: Hardware Assembly
For assembly follow the next steps as shown in the images above:
- Cut the wood strip to two pieces of 23,5 cm and two pieces 14,5 cm length with 45 degrees angles.
- Glue the pieces together with wood glue to get a wood frame that's big enough for the matrix.
- Cut the acrylic glass to size.
- Apply the mirror foil to the glass.
- Hot glue the glass to the frame.
- Hot glue the printed matrix grid to the glass
- Optional: Cut a piece of paper to the size of the matrix as diffusor.
- Put the LED matrix into the grid.
- Hot glue the clamps to fix the matrix into the grid.
- Screw the stands to the LED matrix using the M3 screws.
Be careful that you don't hit the PCB with the screws if they are too long. - Screw the ESP holder to the LED matrix.
- Wire everything up with dupont cables. You find instructions on the wiring in the PxMatrix library description. Depending on the type of the board (black or green PCB) the labeling my be different.
For the power supply of the matrix I took the power directly from the ESP and soldered a dupont wire directly to the power input of the matrix. These two cables can then be connected to "GND" and "Vin / VV / 5V" of the NodeMCU board.
Step 4: Software Setup
This project is built on platform.io. All dependencies are automatically installed, if you buildit. I recommend to use it together with Visual Studio Code and the PlatformIO extension. It's also possible to use the Arduino IDE, then you have to install the required libraries manually (see tetris_clock.ino).
Install Arduino IDE with ESP8266 core
If you have not already installed it, download and install the arduino IDE from here.Then open the preferences and enter http://arduino.esp8266.com/stable/package_esp8266... into Additional Board Manager URLs field.Open the Boards Manager via "Tools > Board" menu and install esp8266.
Install Visual Studio Code and PlatformIO IDE extension
- Download and install official Microsoft Visual Studio Code. PlatformIO IDE is built on top of it.
- Open the VSCode Package Manager
- Search for and install the official "platformio-ide" extension.
You find detailed instructions here: http://docs.platformio.org/en/latest/ide/vscode.h...
To configure PlatformIO IDE, select your board type and COM port as shown in the screenshot.
Flashing the software
You can get the tetris clock software here: https://github.com/toblum/esp_p10_tetris_clock/ Download it as ZIP or clone it via git.
Open the project in Visual Studio Code and build it with the check mark in the bottom bar. All needed dependencies should be installed automatically. When the build succeeds, click the right-arrow sign to start uploading. If everything is correct, the upload terminates succesfully.
Wifi connection
The project uses the great WiFiManager library. So you can setup the Wifi connection very easy. If you boot it up the ESP opens a own hotspot with the name "tetris_clock". Use a device to connect to that hotspot. Use the wifi password "tetromino". Then open the address "http://192.168.4.1" in your browser. This opens up a configuration page. Enter here your home wifi credentials. The ESP reboots and is now connected to the internet.
Step 5: What's Next?
There are many possible extensions for the future:
- Temperature / humidity sensor
- Weather station
- Youtube counter
- Alternative watchface
- Configuration page
Do you have further ideas or want to contribute? Let me know.
Step 6: Step 6: Extend It
Extend the project as you like:
In 2020 I built a version with a 32x32 matrix that fits perfectly in a IKEA Ribba frame. I used Brians D1 matrix board to make cabling more reliable: https://www.tindie.com/products/brianlough/d1-mini-matrix-shield/ Have a look at the boards he's offering.
18 Comments
10 months ago
compiling error on both arduino ide and platformio
drawing.h:250:1: error: control reaches end of non-void function [-Wreturn-type]
drawing.h:297:1: error: control reaches end of non-void function [-Wreturn-type]
Question 2 years ago
Hello Tobias, I hope you're doing fine.
Thank you for this great project. One of my favourite.
I only have 2 question if you could answer:
In your video animation happens on all numbers every minute, but in my case animation goes only on the "changing number"...
Can't find in code where to change that. could you help?
And the intro text "TETRIS TIME" is not work for me too.
otherwise it works like a charm. thanks again ;)
Reply 2 years ago
Hi @FrancesDK,
thank you for the feedback. Always nice to hear that other people have fun with the project.
To answer you questions:
This is the place in the code where it's determined if a number has changed: https://github.com/toblum/esp_p10_tetris_clock/blo...
I didn't try it out, but commenting that line should make all number update everytime.
Not sure what could be wrong with the intro. Does it show up at all?
Greetings!
Reply 2 years ago
Hi @TobiasB48,
Thank you for your quick reply.
Perfect!! All numbers are changing every minute now. Just great :)
About the intro:
If I got it right, it should only be present while/before ESP8266 is connecting to internet... But everytime I upload the code, it always start by updating the 4 numbers:.. No intro text at all.
I'm very newbie with ESP, I think it might be related with some WifiManager or ntp_h wrong configuration...
I've tried to put the "drawIntro();" command before "void setup ()", but not succeed. Same thing happens.
I don't think it's a code issue.
Anyways, I'm very happy with this 1st project on ESP. I'll definitely try to learn more about it.
Congratulations for your great work. Thank you again for your all your help.
Cheers ;)
Reply 2 years ago
Great! Good that it works as expected.
And yes, the intro should work that way. Maybe call display_updater() directly after drawIntro(), but that's the only idea I have currently. I can't try it out at the moment as I don't have any unused matrices laying around.
Greetings!
Question 5 years ago
WHICH SCAN METHOD IS APPLY FOR THIS TYPE DISPLAY?
I TRIED WITH SOME COMBINATIONS ,BUT STILL GET GARBAGE ON SCREEN.
OUTPUT OF BOTH >> PATTERN_TEST.INO AND TETRIS_TIME.INO BOTH IMAGES ARE HERE....
Answer 5 years ago
I had the same scrambled output. I need to add D definition and change initialization to correct it (just try some combinations if mine doesn't works):
// on definitions.h
#defineP_D12
PxMATRIX display(32,16, P_LAT, P_OE, P_A, P_B, P_C, P_D);
// on tetris_clock.ino
display.begin(4);
display.setScanPattern(ZAGGIZ);
display.setMuxPattern(STRAIGHT);
Answer 5 years ago
I had the same scrambled output (8266, 32x16 matrix)... I have to add D definition, and change initialization:
// on definitions.h
#defineP_D12
PxMATRIX display(32,16, P_LAT, P_OE, P_A, P_B, P_C, P_D);
// on tetrisclock.ino
display.begin(4);
display.setScanPattern(ZAGGIZ);
display.setMuxPattern(STRAIGHT);
Answer 5 years ago
Hi @Kml_s Lab,
I'm using PATTERN4 but every display might be different. I suggest opening an issue at the PxMatrix library project: https://github.com/2dom/PxMatrix/issues I think you will get help there as the owner of the library has more insight in this as me.
Best regards
Tobias
5 years ago on Step 5
some issues.
5 years ago
Awesome work Tobias! Definitely going to try this out on my 64x32 version
Question 5 years ago
Hi, may I use a D1 mini board from wemos?
https://wiki.wemos.cc/products:d1:d1_mini
It exposes d1 ... d8 mcu lines so I should be able to wire it correctly to the LED module.
Thanks
Answer 5 years ago
It works for sure!
Answer 5 years ago
Hi amaze1,
I haven't tried it out with an D1 so far, but as far as I can sse the D1 has the D0 to D8 tied to the same ESP ports, so it should work. You may also ask at the PxMatrix project, if the auther already has experience with this board.
Regards
Tobias
Question 5 years ago
I like this and I'm ready to jump in with both feet. Problem is my feet have just got into arduino and I'm very newbie. Could you post instruction on programming using the arduino IDE instead? Thanks!
Answer 5 years ago
Using Arduino IDE shouldn't be a problem. I used this also when I started. But please keep an eye on platform.io, it's great.
Just install the following libraries in your IDE:
Adafruit GFX Library (via Arduino Library Manager) PxMatrix (https://github.com/2dom/PxMatrix.git) WiFiManager (via Arduino Library Manager)NtpClientLib (via Arduino Library Manager)
Then flash it, using a NodeMCU Board Setting.
5 years ago
Another use: a computerized battery charger that displays cell voltage in an artistic way, so you never get any more complaints about leaving your "junk" out on the living room table.
Reply 5 years ago
Yes, why not? Everything get's a higher WAF if it features a wooden frame. :-)