Andreas Motzek
Published © CC BY

MQTT-Enabled Scrolling Text with ATOM Matrix and MicroPython

Use your ATOM Matrix to receive text via MQTT and scroll it on the RGB LEDs.

IntermediateFull instructions provided1 hour2,083
MQTT-Enabled Scrolling Text with ATOM Matrix and MicroPython

Things used in this project

Hardware components

M5Stack ATOM Matrix ESP32 Development Kit

Software apps and online services

MicroPython Firmware for ESP32 v1.12
Download esp32-idf3-20191220-v1.12.bin from the download page.
MQTT Client
Use the MQTT client to send messages to your device from a web browser.


Read more


Fill in your WLAN credentials in line 21, a user name in line 19 and a MQTT topic name in line 49.
import uos
from cooperative_multitasking import Tasks
from network import WLAN, AP_IF
from mqtt_client import MQTTClient
from machine import Pin
from neopixel import NeoPixel
from font5 import Font5
from neopixel_scroller import NeopixelScroller

tasks = Tasks()

ap = WLAN(AP_IF)
ap = None

client = MQTTClient(tasks,
                    hostname = '',
                    client_id = '',
                    user_name = '...',
                    password = '')
client.activate_wlan([('...', '...')])

gpio27 = Pin(27, Pin.OUT)
neopixels = NeoPixel(gpio27, 25)
font = Font5()
colors = [(20, 0, 0), (20, 20, 0), (0, 20, 0), (0, 0, 20)]
scroller = None

def randint(low, high):
    s = 0
    bs = uos.urandom(4)
    for b in bs:
        s = (s << 8) | b
    return low + (s % (high - low + 1))

def random_color():
    return colors[randint(0, len(colors) - 1)]

def receive_message(topic, payload_object):
    global scroller
        message = payload_object['message']
        color = random_color()
        scroller = NeopixelScroller(neopixels, message, font, foreground_color=color)

client.subscribe('...', receive_message)

def has_message():
    return scroller is not None

def await_message():
    tasks.when_then(has_message, scroll_message)

def is_connected():
    return client.is_connected()

def scroll_message():
    if is_connected():
        tasks.after(300, scroll_message)

def clear_display():
    global scroller
    scroller = None
    for pixel_index in range(25):
        neopixels[pixel_index] = (0, 0, 0)

while tasks.available():


Andreas Motzek

Andreas Motzek

14 projects • 4 followers
I love mathematics and computer science. I work for an international consulting company.