Raspberry Pi - Bluetooth LED Matrix

This tutorial instructs you how to control an LED matrix display with a smartphone through either Bluetooth or BLE. The Raspberry Pi has Bluetooth Low Energy (BLE) capabilities built-in, so we do not need to use an external Bluetooth module.

To send messages from the smartphone to the LED matrix display, we will use the Bluetooth Serial Monitor App. Once the message is received by Raspberry Pi, it will be displayed on the LED matrix display.

Raspberry Pi LED matrix display Bluetooth

Hardware Preparation

1×Raspberry Pi 4 Model B
1×HC-05 Bluetooth Module
1×(Alternative) HM-10 BLE Module
1×LED matrix display
1×Breadboard
1×Jumper Wires
1×(Optional) Screw Terminal Adapter for Raspberry Pi

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you. We appreciate your support.

Overview of LED matrix display and Bluetooth Module

Before beginning this tutorial, it is suggested that you have a fundamental comprehension of LED matrix displays and Bluetooth modules, including their pinouts, how they work, and how to program them. If you are not familiar with these concepts, please look over the following tutorials for additional information:

Wiring Diagram

  • To control the LED matrix display with Classic Bluetooth, We need to use the HC-05 Bluetooth module
The wiring diagram between Raspberry Pi and HC-05 Bluetooth Module LED matrix

This image is created using Fritzing. Click to enlarge image

  • To control the LED matrix display with BLE, We need to use the HM-10 BLE Module
The wiring diagram between Raspberry Pi and HM-10 BLE Module LED matrix

This image is created using Fritzing. Click to enlarge image

Raspberry Pi Code - controls LED matrix display via Bluetooth/BLE

The code can be used for both the HC-10 Bluetooth module and the HM-10 BLE module. It will be effective in both cases.

Detailed Instructions

  • Make sure you have Raspbian or any other Raspberry Pi compatible operating system installed on your Pi.
  • Make sure your Raspberry Pi is connected to the same local network as your PC.
  • Make sure your Raspberry Pi is connected to the internet if you need to install some libraries.
  • If this is the first time you use Raspberry Pi, See how to set up the Raspberry Pi
  • Connect your PC to the Raspberry Pi via SSH using the built-in SSH client on Linux and macOS or PuTTY on Windows. See to how connect your PC to Raspberry Pi via SSH.
  • Make sure you have the RPi.GPIO library installed. If not, install it using the following command:
sudo apt-get update sudo apt-get install python3-rpi.gpio
pip install luma.led_matrix
  • Install the pyserial library for communication with bluetooth module:
pip install pyserial
  • Create a Python script file bluetooth_led_matrix.py and add the following code:
# This Raspberry Pi code was developed by newbiely.com # This Raspberry Pi code is made available for public use without any restriction # For comprehensive instructions and wiring diagrams, please visit: # https://newbiely.com/tutorials/raspberry-pi/raspberry-pi-bluetooth-led-matrix from luma.led_matrix.device import max7219 from luma.core.interface.serial import spi, noop from luma.core.virtual import viewport, sevensegment from luma.core.legacy import show_message import serial from time import sleep CS_PIN = 25 # Replace with your actual CS pin BLOCK_NUM = 4 # Replace with your block number HEIGHT = 8 WIDTH = 8 * BLOCK_NUM # Define SPI interface serial = spi(port=0, device=0, gpio=noop(), cs=CS_PIN) # Define LED matrix device device = max7219(serial, cascaded=BLOCK_NUM, block_orientation=-90) # Define virtual device virtual = viewport(device, width=WIDTH, height=HEIGHT) # Create instance of sevensegment for text display ledMatrix = sevensegment(virtual) # Define serial port for Bluetooth communication bluetooth = serial.Serial('/dev/ttyS0', baudrate=9600, timeout=1) def clear_display(): ledMatrix.text = " " sleep(1) # Main program try: bluetooth.flushInput() # Clear any existing data in the input buffer while True: bluetooth.write(b"Raspberry Pi here, command me!\n") if bluetooth.inWaiting() > 0: text = bluetooth.readline().decode('utf-8').strip() # Read until newline character clear_display() ledMatrix.text = text show_message(device, ledMatrix.text, fill="white", font=None, scroll_delay=0.1) # Send acknowledgment back to the smartphone app bluetooth.write(b"LED Matrix displayed: ") bluetooth.write(text.encode('utf-8')) bluetooth.write(b"\n") except KeyboardInterrupt: pass finally: device.cleanup() bluetooth.close()
  • Save the file and run the Python script by executing the following command in the terminal:
python3 bluetooth_led_matrix.py
  • Download the Bluetooth Serial Monitor App to your smartphone.
  • Launch the Bluetooth Serial Monitor App on your smartphone.
  • Select either Classic Bluetooth or BLE, depending on the module being used.
Bluetooth Serial Monitor App
  • Connect the Bluetooth App to the HC-05 Bluetooth module or the HM-10 BLE module.
Bluetooth Serial Monitor pairing
  • Type a message, for example “HELLO”
  • And then press the Send button
  • To transmit it to the Raspberry Pi.
Bluetooth Serial Monitor App
  • Take a look at the message that is shown on the LED matrix display and the Bluetooth App.
  • Check the output on the Android App.
Bluetooth Serial Monitor App

If you discovered the Bluetooth Serial Monitor app to be useful, please think about giving it a 5-star rating on the Play Store. Your opinion is highly valued! Thank you!

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!