Introduction: 8x8 Led Matrix Clock & Anti-Intrusion Warning

In this Instructable we'll see how to build a 8x8 Led Matrix Clock activated by motion detection.

This clock can be used also as anti-intrusion device that send a warning message if a motion is detected to a telegram bot!!!

We'll do with two different objects:

  • The digital clock, controlled by a Wemos D1 mini
  • A central control unit (rasperry) where mosquitto is running (a MQTT broker) that make the interface between the clock and the telegram bot

This architecture is thinked to manage the communication between other devices, with different functions (ie. temperature sensors, relay, ...), to the telegram bot


Part list of the Digital Clock:

Part list of the Central Control Unit

  • Raspberry PI
  • USB charger

Step 1: Build the Clock

To build the clock:

  • insert the 4 8x8 Matrix Led in the breadboard
  • build connection
  • Assemble Wemos D1 mini to the RTC shield and to PIR Sensor
  • Finish connection

Put the 4 Led Modules, side by side and connect the output pins of each module to the input pins of the next.

  • VCC => VCC
  • GND => GND
  • DOUT => DIN
  • CS => CS
  • CLK => CLK

The first module input pins need to be connected to the Wemos D1 mini pins in such a way:

  • VCC => 5V
  • GND => GND
  • DIN => D7
  • CS => D6
  • CLK => D5

COnnect also the PIR senosor to the Wemos D1 mini pins:

  • VCC => 5V
  • Out => D0
  • GND => GND

Connections are ready!

Step 2: Write and Load Program to Wemos D1mini

The Wemos_reogio.ino file is uploaded in this instructable so you can load and modify with your network parametrs in your arduino IDE.

The program switch on the leds when the PIR sensor is excited, for 20 seconds (or more if the sensor continues to be excited) then it turns off the leds.
When the esp8266 detect a message through MQTT in the following format:

["Pir_on":1} the Detection Mode is activated and the following message is published via MQTT anytime the PIR sensor is excited (for the first time):

{"PIR":1} When the following message is dispatched, the messages publishing is suspended:

["Pir_off":1} In such a way this device has two different features:

movemente activated clockanti-intrusion warning And this last feature is "masked" by a "normal" clock

Some issues:

If you never installed the esp8266 in the Arduino IDE, you can view a tutorial here:

You need to install libraries for

  • RTC shield: RTClib.h

ATTENTION: the time in rtc must be set the first time the RTC shield is installed with the battery, then it will maintain the data, until the battery is discharghed

  • 8x8 Led Matrix: LedControl.h

Here an example of manage this leds:

May be that you need to change the order in which leds are written, depending on the wiring. check it and, in case, you can modify the following row:
int revDisp = numDisplay - disp-1; // reverse the order of the panels ATTENTION: IT DEPENDS ON THE WIRING

you need also to install MQTT libraries to manage:

  • MQTT protocol: PubSubClient.h

in this code the MQTT broker is installed in a Raspberry with static IP. Here is an example:

Step 3: Prepare Telegram Bot

Here we don't explain the raspberry set-up, neither the communication between raspberry and a telegram bot, becasue there are a lot of tytorials about this.

An example is:

Step 4: Prepare Raspberry and Load Mosquitto

You have to install mosquitto on Raspberry, you can find a lot of tutorial, here an example about how to manage the MQTT between Raspberry and esp8266:

We have prepared a python program that acts as an interface between telegram and the MQTT broker, converting:

  • commands by the bot in messages published on MQTT, so they can be listened by the esp8266
  • messages published in MQTT by esp8266 in messages to the bot