MQTT-Enabled Scrolling Text with ATOM Matrix and MicroPython
2023-09-20 | By M5Stack
License: General Public License Bluetooth / BLE Wifi Arduino
* Thanks for the source code and project information provided by @Andreas Motzek
Things used in this project
Hardware components
M5Stack ATOM Matrix ESP32 Development Kit×1
Software apps and online services
MicroPython Firmware for ESP32 v1.19.1
Download esp32-20220618-v1.19.1.bin from the download page.
MQTT Client
Use the MQTT client to send messages to your device from a web browser.
For Windows:
1. Install Python, Esptool, and Ampy
If you have no Python 3 installation on your computer, please download the installer from https://www.python.org/downloads/ and execute it. Then install Esptool and Ampy with
> pip3 install esptool
> pip3 install adafruit-ampy
on the command line.
2. Download and Install Firmware
Download https://micropython.org/resources/firmware/esp32-20220618-v1.19.1.bin. Connect your ATOM Matrix to your computer via USB. If you are connecting it the first time wait a little until Windows installs the driver. Open the Windows Device Manager and look into "COM & LPT" to find the correct COM port, e.g., COM6. Then install the firmware with
> esptool.py --chip esp32 --port COM6 erase_flash
> esptool.py --chip esp32 --port COM6 write_flash -z 0x1000 esp32-20220618-v1.19.1.bin
Reset your device after the installation is finished.
3. Download and Install Libraries
Create a folder named lib on your computer. Download the files cooperative_multitasking.mpy, font5.mpy, mqtt.mpy, mqtt_client.mpy and neopixel_scroller.mpy from https://bitbucket.org/amotzek/micro-python/downloads/ into that lib folder. In the command line navigate to the folder above lib and then execute
> ampy.exe --port COM6 --delay 3 put lib
to upload the folder to your ATOM Matrix.
4. Edit and Upload main.py
From the Code section of this project copy the file main.py to your computer and fill in your WLAN credentials in line 21, a username in line 19, and a MQTT topic name in line 49. Execute
> ampy.exe --port COM6 --delay 3 put main.py
to upload the file to your ATOM Matrix.
5. Test
In your browser go to http://www.hivemq.com/demos/websocket-client/. Click the Connect button. Enter the topic name from line 49 into the Topic field. Enter
{ "message": "HELLO!" }
into the Message field. Click the Publish button. Your ATOM Matrix should display HELLO! now.
Only capital letters A to Z, digits and some other characters can be displayed. For a complete list see the source code of Font5 at https://bitbucket.org/amotzek/micro-python/src/master/src/main/modules/font5.py.
Code