Build a Live Information Display: Integrating LED Matrices (MAX7219, WS2812B) with ASI Biont AI Agent

Introduction

Imagine walking into your office and seeing a sleek LED matrix silently scrolling the latest Bitcoin price, the weather forecast for the day, and your server’s uptime — all without you writing a single line of integration code. That’s the power of combining LED matrices (MAX7219 or WS2812B) with the ASI Biont AI agent. Instead of spending hours coding an MQTT client or a custom web server, you simply describe what you want in a chat, and the AI handles the connection, data fetching, and control logic. This guide walks you through two real-world setups: a MAX7219 8x8 matrix connected via COM port (Arduino) and a WS2812B panel controlled via MQTT from an ESP32. By the end, you’ll have a fully functional AI-driven information display that responds to Telegram commands.

Why Connect an LED Matrix to an AI Agent?

LED matrices are perfect for showing dynamic data — stock tickers, system alerts, smart home statuses. But manually programming each display to fetch data from different sources (APIs, databases, sensors) is tedious. ASI Biont acts as a brain that:

  • Fetches real-time data from any source (cryptocurrency APIs, weather services, server metrics).
  • Generates and sends display commands to the matrix using the appropriate protocol.
  • Responds to natural language commands like “Show BTC price” or “Display server CPU load”.

You get a flexible, no-code interface that works with any microcontroller or single-board computer.

Connection Methods Supported by ASI Biont

ASI Biont connects to devices through these real mechanisms:

Method Protocol Best For Example Hardware
Hardware Bridge (COM port) Serial (RS-232/RS-485) Arduino, ESP32 (via UART) MAX7219 with Arduino Nano
MQTT paho-mqtt ESP32 (WiFi), Raspberry Pi WS2812B with ESP32
SSH paramiko Raspberry Pi, Orange Pi Direct GPIO control
execute_python Sandbox Python Any device with network access Universal fallback

For LED matrices, the two most practical paths are:

  1. MAX7219 via Arduino + COM port – Use Hardware Bridge (bridge.py) on your PC to send serial commands to an Arduino that drives the matrix.
  2. WS2812B via ESP32 + MQTT – ESP32 subscribes to an MQTT topic; ASI Biont publishes display commands to that topic.

Case Study 1: ESP32 + WS2812B + MQTT – Telegram-Powered Information Board

Problem

You want a WS2812B LED panel (e.g., 16x32) in your living room that shows:
- Current Bitcoin price (USD)
- Outdoor temperature (from OpenWeatherMap)
- Custom scrolling messages (e.g., “Happy Birthday!”)

All controllable via Telegram commands.

Solution

ASI Biont connects to an MQTT broker (e.g., Mosquitto), and the ESP32 subscribes to the topic led/display. When you send a Telegram message like “Show BTC price”, the AI fetches the price from CoinGecko API, formats a display command (e.g., scroll:BTC $42,500), and publishes it via MQTT. The ESP32 receives the command and updates the matrix.

Step-by-Step Implementation

1. Hardware Setup

  • ESP32 (any variant with WiFi).
  • WS2812B LED matrix (e.g., 16x32 or 8x32 panel).
  • 5V power supply (sufficient for the number of LEDs).
  • Connect DIN pin to GPIO13, 5V to 5V, GND to GND.

2. ESP32 Firmware (Arduino IDE)

#include <WiFi.h>
#include <PubSubClient.h>
#include <Adafruit_NeoPixel.h>

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
const char* mqtt_server = "test.mosquitto.org";
const char* topic = "led/display";

WiFiClient espClient;
PubSubClient client(espClient);
Adafruit_NeoPixel strip(512, 13, NEO_GRB + NEO_KHZ800); // 512 LEDs for 16x32

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
  strip.begin();
  strip.show();
}

void callback(char* topic, byte* payload, unsigned int length) {
  String msg = "";
  for (int i = 0; i < length; i++) msg += (char)payload[i];
  if (msg.startsWith("scroll:")) {
    String text = msg.substring(7);
    // call your scrolling function
  } else if (msg.startsWith("color:")) {
    // set all LEDs to a color
  }
}

void loop() {
  if (!client.connected()) reconnect();
  client.loop();
}

3. ASI Biont Integration (via Chat)

You describe to ASI Biont:

“Connect to MQTT broker test.mosquitto.org, subscribe to topic led/display. When I send a Telegram message ‘Show BTC price’, fetch the price from CoinGecko API and publish a command like ‘scroll:BTC $42,500’ to the topic. Also respond to ‘Show weather’ and ‘Scroll [message]’.”

The AI writes and executes a Python script using paho-mqtt and aiohttp inside its sandbox. No manual coding needed.

4. Telegram Commands

  • /btc – AI fetches price and publishes scroll command.
  • /weather – AI fetches from OpenWeatherMap and publishes.
  • /scroll Hello World – AI publishes the exact message.

Results

Within 10 minutes, you have a fully functional display that updates in real time. You can change the data source or add new commands just by chatting with the AI.

Case Study 2: Arduino + MAX7219 + COM Port – Server Status Monitor

Problem

You have a MAX7219 8x8 matrix (or a chain of them) that you want to show server CPU load and memory usage, updated every 10 seconds.

Solution

ASI Biont connects to your PC via Hardware Bridge (bridge.py), which communicates with an Arduino over USB serial. The AI periodically queries your server’s metrics via SSH (using paramiko), formats a display pattern, and sends it to the Arduino.

Step-by-Step Implementation

1. Hardware Setup

  • Arduino Nano or Uno.
  • MAX7219 8x8 matrix (common anode, 5V).
  • Connect: VCC→5V, GND→GND, DIN→D11, CS→D10, CLK→D13.

2. Arduino Firmware

#include <LedControl.h>

LedControl lc = LedControl(11, 13, 10, 1); // DIN, CLK, CS, number of matrices

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

void loop() {
  if (Serial.available()) {
    char cmd = Serial.read();
    if (cmd == 'L') {
      // Load percentage (e.g., 'L' followed by 0-100)
      int percent = Serial.parseInt();
      displayBar(percent);
    }
  }
}

void displayBar(int p) {
  // map p to number of lit columns (1-8)
  int cols = map(p, 0, 100, 0, 8);
  for (int col = 0; col < 8; col++) {
    for (int row = 0; row < 8; row++) {
      lc.setLed(0, row, col, col < cols);
    }
  }
}

3. Hardware Bridge Setup

On your PC, run bridge.py with your ASI Biont token:

python bridge.py --token=YOUR_TOKEN --ports=COM3 --default-baud=9600

The bridge connects to ASI Biont via HTTP long polling and opens COM3.

4. ASI Biont Integration (Chat)

You tell the AI:

“Connect to Hardware Bridge with serial port COM3 at 9600 baud. Every 10 seconds, SSH into my server at 192.168.1.100 (user: admin, key: ~/.ssh/id_rsa), get CPU usage using top -bn1 | grep 'Cpu(s)', parse the idle percentage, and send the load value to the Arduino as ‘L’ followed by the percentage.”

The AI writes a Python script that runs in the sandbox (using paramiko for SSH and industrial_command for serial write). It uses the industrial_command(protocol='serial://', command='write', data='L42') pattern.

Results

Your MAX7219 shows a real-time bar graph of CPU load, and you never manually coded the SSH-to-serial pipeline.

Why ASI Biont Makes This So Easy

Traditional integration requires:
- Writing an MQTT or serial client on the microcontroller.
- Writing a backend script to fetch data and send commands.
- Deploying and debugging.

With ASI Biont:

  • You describe the task in natural language. Example: “Connect to my ESP32 via MQTT, listen for Telegram messages, and display Bitcoin price on the LED matrix.”
  • AI writes the Python code using paho-mqtt, aiohttp, paramiko, or pyserial (depending on your chosen method).
  • AI executes the code in its sandbox environment (execute_python) and maintains the connection.
  • You control everything via chat. No dashboards, no buttons.

This means you can connect any device that speaks serial, MQTT, Modbus, HTTP, or SSH. You are not limited to a pre-built list of supported gadgets.

Pitfalls to Avoid

  1. Infinite loops in execute_python – Sandbox timeout is 30 seconds. Use asyncio.sleep() with proper intervals.
  2. Wrong baud rate – Double-check Arduino firmware baud (e.g., 9600) matches bridge.py --default-baud.
  3. MQTT topic mismatch – Ensure ESP32 subscribes to the exact topic AI publishes to.
  4. Power supply for WS2812B – Large matrices draw amps; use a dedicated 5V supply, not USB.

Conclusion

Integrating LED matrices (MAX7219 or WS2812B) with ASI Biont transforms a static display into a dynamic, AI-controlled information hub. Whether you choose MQTT for wireless ESP32 or a wired serial connection via Arduino, the AI handles all the glue code. You just describe your needs, and the AI builds the integration in seconds.

Ready to build your own AI-powered LED display? Head over to asibiont.com and start chatting with the AI agent. No coding skills required — just your hardware and your imagination.

← All posts

Comments