How to Create a Smart Clock Using MAX7219 Dot Matrix and MQTT

A smart clock can display much more information than a traditional digital clock. More importantly, a smart clock is connected to the network or the Internet and can be controlled via a smartphone or a PC. You can also view any text or information on the smart clock.


In this guide, we are going to build a Wi-Fi based smart clock using an ESP8266 microcontroller and a MAX7219 4x8x8 LED matrix. You can use it to display time, date, temperature, humidity, desired text, alerts, Instagram followers, YouTube subscribers, views, animated texts, emoji and other information in a few clicks.


Things you will need

To build a DIY smart clock, you need the following:

  • An MQTT server with Node-Red. You can install and configure a Home Assistant server with MQTT and Node-Red for clock automation and data sending.
  • An ESP8266-based MCU, such as NodemCU or D1 Mini. An ESP32 will also work.
  • MAX7219 4-in-1 or 8-in-1 (preferred) matrix display.
  • DuPont or jumper wires
  • Micro USB cable with 5V adapter
  • A 3D printed hull to assemble all the components
  • A frosted acrylic sheet, preferably black. It should not be opaque. If frosted black sheet is not available, you can use frosted white acrylic sheet with tint film used on car mirrors and butter paper sheet to diffuse the LED light.

Steps to build a smart clock

Follow these steps in the order given to build the DIY smart clock using the MAX7219 die. You can also buy one of these best smart clocks.

Step 1: Download and configure the Arduino IDE

  • Close the Table manager window and navigate to Sketch > Include library > Manage Libraries. Find and install the following libraries.

Alternatively, you can also these libraries as a .zip file and extract them in the Documents > Arduino > libraries case.

Step 2: Compile and Flash Firmware

  • Download the Pixel-Driven MQTT Panel Project from GitHub and extract it in the Documents > Arduino Folder.
  • Open the extracted folder and double-click pixel_led_mqtt_panel.ino case.
  • Go to Tools > Boards > ESP8266 (xxx) Boards and select NodeMCU 1.0 Where LOLIN(WEMOS) D1— depending on the card you are using for this project.

  • Select the COM Port
  • Then make the following changes in the pixel_led_mqtt_panel.ino sketch.
    • Enter your Wi-Fi name, password and OTA password.
    • Enter the IP address, username and password of the MQTT server.

const char* WIFI_ssid       = "EnterYourWiFiName";
const char* WIFI_password = "WIFiPassword";
const char* OTA_hostname = "wLed-panel-01";
const char* OTA_password = "OTAPassword";
const char* mqtt_server = "192.168.xx.xx";
const char* mqtt_user = "mqtt-username";
const char* mqtt_password = "mqtt-password";
  • Also change the following to suit your MAX7219 array. If you have an 8x8x8, keep everything default. However, if you’re using a 4x8x8 matrix like we do, make these changes:

void setup() {
setup_serial();
P.begin(2);
P.setZone(0, 0, 2);
P.setZone(1, 3, 3);
  • Save the sketch, then press CTRL+R to check the sketch. If any libraries are missing, be sure to install them. And recompile the sketch.
  • If the sketch compiles successfully, press CTRL+U to upload it to your NodeMCU or D1 Mini MCU.
  • When the download is complete, disconnect the MCU.

Step 3: Connect the MAX7219 to the MCU

  • Refer to the following diagram to connect the MAX7219 to the D1 Mini or ESP8266 board.

  • Be sure to properly connect the DuPont cables supplied with the display.

Step 4: View smart clock information

The smart clock is ready to display the text or sensor data you want to display via MQTT topics. You can use any MQTT client application to send JSON data to display on smart clocks. To automate the clock, you can install and configure a Home Assistant server with an MQTT broker and NodeRed on a Raspberry Pi.

You can then use it to display various information about the sensors and status of the DIY smart clock. To learn more about the subject and the animations you can use with the clock, refer to the project on GitHub.

Meanwhile, you can use the following NodeRed sample stream, import it into your NodeRed and modify it according to your sensors to display the data you want.

[{"id":"f342606a2cb01a7c","type":"mqtt out","z":"f1f7ad6a657d809a","g":"d0cb3ac3e49ba96d","name":"","topic":"wled/zone0_text","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"d4ab875e8280590a","x":1160,"y":840,"wires":[]},{"id":"d4ab875e8280590a","type":"mqtt-broker","name":"MQTT HA","broker":"192.168.0.171","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"my/pixelit/","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

Integrate your home assistant

MAX7219 is a popular dot-matrix display that you can control via Arduino boards or WIFI-based ESP8266 microcontrollers, such as NodeMCU and D1 Mini, to display desired information or animations.

This DIY guide used a MAX7219 4-in-1 die to build a smart clock. More than that, it can also be used as a notification panel to display information, such as ambient temperature, humidity, tank water level, power consumption and any data or information received through the MQTT topics.

If you have set up a home assistant or any other home automation server in your home, you can integrate this MQTT smart clock panel to retrieve and display all the information received through various sensors and devices that you may have installed in your home and integrated at home. Assistant.

About Florence L. Silvia

Check Also

How to Stream Every ‘Matrix’ Movie in 2022

ex_artist/Shutterstock.com The Wachowskis created a revolution in blockbuster action when they created a genre-blending adventure …