Smart LED Matrix Display Controlled by AI: Integrating MAX7219 and WS2812B with ASI Biont

Introduction

LED matrix displays – from the simple 8×8 MAX7219 to the vibrant addressable WS2812B strips – are everywhere: offices, factories, home dashboards. But manually reprogramming them every time you need to show different data is tedious. What if you could just tell an AI agent: “Show the current USD/EUR rate on my WS2812B matrix” and have it happen instantly?

With ASI Biont, you can. The AI agent connects to any LED matrix via MQTT, COM port, or HTTP API – and dynamically changes what’s displayed based on real‑time data, schedules, or events. No dashboard panels, no “add device” buttons – just a chat conversation where you describe your hardware and what you want.

This article shows two concrete integrations:
1. ESP32 + WS2812B (addressable RGB) via MQTT for scrolling text and animations.
2. Arduino + MAX7219 (monochrome 8×8) via the Hardware Bridge (COM port) for numeric indicators.

Both are fully supported by ASI Biont’s existing connection methods.

Why Connect an LED Matrix to an AI Agent?

Capability Without AI With ASI Biont
Change display content Re‑flash firmware / send manual commands Tell the AI in natural language
Data sources Hardcoded in firmware Fetch from any API, database, or sensor
Scheduling Implemented in device code AI sets Cron triggers via execute_python
Alerts & triggers Limited to local events AI monitors external events and updates display

For example, a factory production board can instantly show machine status read from a Modbus PLC; a personal desk display can show weather forecasts from OpenWeatherMap. All without touching a single line of embedded C code – the AI writes the integration for you.

Connection Methods Available

ASI Biont supports multiple protocols. For LED matrices the most relevant are:

Method When to use How the AI interacts
MQTT ESP32, ESP8266, or any board with WiFi AI writes a Python script (execute_python) with paho‑mqtt to publish/subscribe. Device runs MicroPython that listens on the same topic.
Hardware Bridge (COM port) Arduino or any board connected via serial to a PC AI uses the industrial_command tool with serial_write_and_read. The user runs bridge.py on their PC.
SSH Raspberry Pi driving the matrix AI writes a paramiko script to run local Python code on the Pi.

Below we detail the first two, which are the most common for LED matrices.

1. ESP32 + WS2812B (Addressable RGB) via MQTT

How the user describes it in chat

“I have an ESP32 with a WS2812B strip of 64 LEDs. Connect it to ASI Biont via MQTT. I want to display scrolling text – show the current Bitcoin price every 5 minutes.”

The AI agent then:
1. Generates MicroPython firmware code for the ESP32 (WiFi + MQTT + Neopixel).
2. Writes a Python script (execute_python) that fetches BTC price from CoinGecko API and publishes the scrolling text command to the MQTT topic.
3. Optionally sets a schedule to repeat the action.

ESP32 MicroPython code (generated by AI)

import network
import ubinascii
import neopixel
import time
from umqtt.simple import MQTTClient

# Configuration
SSID = "your_wifi"
PASSWORD = "your_pass"
MQTT_BROKER = "test.mosquitto.org"
TOPIC = "led/display"

# WS2812B setup (64 LEDs)
np = neopixel.NeoPixel(machine.Pin(4), 64)

def clear_display():
    for i in range(64):
        np[i] = (0,0,0)
    np.write()

def show_text(text, color=(0,255,0)):
    # Simplified scrolling – normally you'd use a font library
    # Here we just set the first few LEDs to indicate activity
    clear_display()
    for i in range(min(len(text), 64)):
        np[i] = color if i < 10 else (0,0,0)
    np.write()

def mqtt_callback(topic, msg):
    payload = msg.decode()
    # Expected format: "TEXT:Hello" or "CLEAR"
    if payload.startswith("TEXT:"):
        show_text(payload[5:])
    elif payload == "CLEAR":
        clear_display()
    else:
        print("Unknown", payload)

def connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    wlan.connect(SSID, PASSWORD)
    while not wlan.isconnected():
        time.sleep(1)
    print("WiFi connected")
    client = MQTTClient(ubinascii.hexlify(machine.unique_id()), MQTT_BROKER)
    client.set_callback(mqtt_callback)
    client.connect()
    client.subscribe(TOPIC)
    print("MQTT connected")
    return client

client = connect()
while True:
    client.check_msg()
    time.sleep(0.1)

Note: The AI generates this code and provides it as text. The user copies it to their ESP32. The device will wait for messages on topic led/display.

AI side – Python script (execute_python) to send data

import paho.mqtt.client as mqtt
import requests
import time

# Fetch BTC price
resp = requests.get("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd")
price = resp.json()["bitcoin"]["usd"]
message = f"BTC: ${price}"

# Publish to MQTT
client = mqtt.Client()
client.connect("test.mosquitto.org", 1883, 60)
client.publish("led/display", f"TEXT:{message}")
client.disconnect()

This script runs on ASI Biont’s server (sandbox, 30‑second timeout). The AI can schedule it every 5 minutes using Cron triggers (described in chat).

How the user triggers this

Simply type:

“Run the BTC price script now”
The AI executes the Python script in its sandbox. No manual MQTT publishing needed.

2. Arduino + MAX7219 8×8 via Hardware Bridge

Scenario

An Arduino Uno with a MAX7219‑driven 8×8 matrix shows a simple numeric counter. The user wants to update it from ASI Biont: e.g., display the current number of open support tickets.

Setup

  • Arduino code listens on the serial port for commands like SHOW 42\n. The device echoes the number.
  • The user runs bridge.py on their PC with --ports=COM3 --baud=9600 --token=YOUR_TOKEN.
  • In chat, user says: “Connect to COM3 at 9600 baud, send HELP to verify.” The AI uses industrial_command:
industrial_command(
  protocol='serial://',
  command='serial_write_and_read',
  parameters={'data': '48454c500a'}  # "HELP\n" in hex
)

If the device responds with “OK”, integration is confirmed.

Arduino code (user must upload once)

#include <LedControl.h>

LedControl lc = LedControl(12,11,10,1); // DIN,CLK,CS, devices

void setup() {
  Serial.begin(9600);
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void loop() {
  if (Serial.available()) {
    String cmd = Serial.readStringUntil('\n');
    cmd.trim();
    if (cmd.startsWith("SHOW ")) {
      int num = cmd.substring(5).toInt();
      displayNumber(num);
      Serial.print("OK: ");
      Serial.println(num);
    } else if (cmd == "HELP") {
      Serial.println("COMMANDS: SHOW <num>, HELP");
    }
  }
}

void displayNumber(int n) {
  lc.clearDisplay(0);
  // Simple 2‑digit on 8×8
  int tens = n / 10;
  int ones = n % 10;
  // Draw tens on left 4 columns, ones on right
  for (int col=0; col<4; col++) {
    lc.setColumn(0, col, digits[tens][col]);
    lc.setColumn(0, col+4, digits[ones][col]);
  }
}

Sending display updates from AI

After verifying the connection, the user says: “Show number 42 on the MAX7219.”
The AI sends:

industrial_command(
  protocol='serial://',
  command='serial_write_and_read',
  parameters={'data': '53484f572034320a'}  # "SHOW 42\n"
)

To automate: the AI can run a Python script (execute_python) that fetches ticket count from a help desk API and sends the SHOW command via MQTT or directly via the bridge? Actually the bridge is for serial only. For automation without manual chat, the user could set up a schedule where the AI runs a script that uses industrial_command – but industrial_command is only available inside the chat session, not in executed scripts. So the correct approach is: the AI writes a Python script that publishes to an MQTT topic, and the Arduino listens to MQTT (or uses a second serial bridge). For simplicity, a common pattern is to keep the serial bridge always connected and use the industrial_command tool each time the user triggers an update, or the AI can schedule a chat message that contains the command. For fully autonomous updates, wire the Arduino to a Wi‑Fi module (ESP8266) and use MQTT – that brings us back to the first method.

Thus the MAX7219 + COM port is ideal for one‑off commands or when the user is present.

Why This Approach Beats Traditional Programming

Aspect Traditional With ASI Biont
Time to first display update Hours (code, compile, upload, test) Seconds (describe in chat)
Changing data source Edit firmware, re‑upload Ask AI to change the Python script
Adding new triggers Requires re‑coding AI adds condition in chat
Skill level Embedded programming Natural language

Conclusion

LED matrix displays become truly smart when an AI agent controls them. ASI Biont connects to MAX7219 via COM port with a Hardware Bridge and to WS2812B via MQTT – and to any other device through execute_python. You don’t need to learn MQTT, TCP, or serial protocols; just describe your hardware and your goal. The AI writes the integration code on the fly, executes it, and updates your display in real time.

Try it yourself: go to asibiont.com, create an API key, download bridge.py, and tell the AI to connect your LED matrix. Whether it’s a stock ticker, a server monitor, or a countdown timer – set it up in one conversation.

← All posts

Comments