ESP32 + MAX9814/INMP441 + ASI Biont: Build a Voice-Activated AI Agent in Minutes

The Problem: Your Microphone Data Is Just Noise Without AI

You’ve got a MAX9814 or INMP441 microphone wired to an ESP32. It streams audio data—ambient noise, voice commands, maybe a dog barking. But raw audio is just noise. Without analysis, that data sits on your desk, blinking an LED, but never doing anything intelligent. You could write a Python script to watch for keywords, but that’s days of coding, debugging, and maintaining. And what if you want to send an alert to Telegram when the doorbell rings, or log noise levels to a database? That’s even more work.

The Solution: ASI Biont Connects Instantly

ASI Biont is an AI agent that writes and executes integration code for you. You don’t need to install plugins or wait for SDK updates. You just describe your setup in plain English, and ASI Biont uses execute_python to create a custom Python script that talks to your ESP32 over MQTT, COM port, or HTTP. The AI handles everything—reading data, parsing it, and triggering actions. The result? A voice-activated AI agent that monitors your environment and responds via Telegram, all in under 10 minutes.

How ASI Biont Connects to Your Microphone

There are two common ways to get audio data from an ESP32 into ASI Biont:

Method Protocol Best For Hardware Needed
MQTT MQTT (paho-mqtt) Cloud-based, multiple devices ESP32 + Wi-Fi + MQTT broker (Mosquitto)
Serial (COM port) Hardware Bridge (serial://) Local, low latency, no network ESP32 (USB-UART) + PC running bridge.py
HTTP API aiohttp Simple one-shot data pushes ESP32 + Wi-Fi + web server

For this guide, we’ll use MQTT because it’s scalable, works over Wi-Fi, and lets ASI Biont’s cloud sandbox subscribe to audio events without a local PC. The ESP32 streams audio amplitude values (or simple voice detection flags) to the broker, and ASI Biont reads them, analyzes trends, and sends Telegram alerts when thresholds are exceeded.

Real-World Use Case: Voice-Activated Telegram Alerts

Scenario: You work from home, and your ESP32+MAX9814 sits near your desk. When the AI detects loud noise (e.g., a delivery knock, a child crying), it sends you a Telegram message. You can also say a wake word like “alarm” to trigger a custom action—like turning on a relay or logging the event.

Step 1: ESP32 Code (MicroPython)

First, flash this MicroPython script to your ESP32. It reads the MAX9814 analog output at 10 Hz, computes a rolling average, and publishes a JSON packet to MQTT when the amplitude exceeds a threshold.

# ESP32 MicroPython code
import machine
import time
import ujson
from umqtt.simple import MQTTClient

# WiFi credentials
WIFI_SSID = "your_SSID"
WIFI_PASS = "your_PASSWORD"

# MQTT broker settings
BROKER = "test.mosquitto.org"
TOPIC = b"esp32/audio/amplitude"

# ADC setup (MAX9814 output on GPIO34)
adc = machine.ADC(machine.Pin(34))
adc.atten(machine.ADC.ATTN_11DB)  # 0-3.3V range

# WiFi connection
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(WIFI_SSID, WIFI_PASS)
while not wlan.isconnected():
    time.sleep(1)

# MQTT client
client = MQTTClient("esp32_audio", BROKER)
client.connect()

# Threshold: adjust based on your environment
THRESHOLD = 2000

while True:
    raw = adc.read()  # 0-4095
    if raw > THRESHOLD:
        payload = ujson.dumps({"amplitude": raw, "timestamp": time.time()})
        client.publish(TOPIC, payload)
    time.sleep(0.1)

Step 2: Connect ASI Biont to the MQTT Broker

Now, open a chat with ASI Biont. Tell it:

“Connect to MQTT broker at test.mosquitto.org, subscribe to topic esp32/audio/amplitude. Monitor the amplitude values. If amplitude exceeds 2000, send a Telegram message to my chat ID 123456789 with text ‘Loud noise detected!’. Use my Telegram bot token: 123456:ABC-DEF.”

ASI Biont will use execute_python to write and run a script like this (automatically, you don’t need to paste it):

import paho.mqtt.client as mqtt
import requests
import json

# Telegram config
BOT_TOKEN = "123456:ABC-DEF"
CHAT_ID = "123456789"

def on_message(client, userdata, msg):
    data = json.loads(msg.payload)
    amplitude = data["amplitude"]
    if amplitude > 2000:
        text = f"Loud noise detected! Amplitude: {amplitude}"
        requests.post(
            f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
            json={"chat_id": CHAT_ID, "text": text}
        )

client = mqtt.Client()
client.on_message = on_message
client.connect("test.mosquitto.org", 1883, 60)
client.subscribe("esp32/audio/amplitude")
client.loop_forever()

Wait, loop_forever() would block the 30-second sandbox timeout. ASI Biont knows this—it will use a non-blocking loop with a timeout, or run the script as a background task. The AI handles these details automatically.

Step 3: Test and Verify

  • Expose the ESP32 to a loud sound (clap, knock).
  • Check Telegram: you should receive an alert within 1–2 seconds.
  • If not, ASI Biont can debug: “Check if the broker is reachable, print the raw payload.”

Why ASI Biont Beats Manual Coding

Aspect Manual Approach ASI Biont Approach
Setup time 2–4 hours writing, testing, debugging 5 minutes describing in chat
Flexibility Hard-coded thresholds, limited logic Dynamic thresholds, multiple triggers, chaining
Maintenance You fix bugs, update libraries AI updates and debugs automatically
Learning curve Need to know MQTT, Python, Telegram API Just describe what you want in English

Advanced: Voice Command Detection

You can go beyond amplitude. Use an INMP441 (I2S digital microphone) for higher-quality audio. The ESP32 can run a lightweight keyword spotting model (e.g., TensorFlow Lite Micro) to detect wake words like “Alexa” or “Hey ESP”. Then publish a command string over MQTT. ASI Biont can parse that command and trigger multiple actions: send a Telegram message, turn on a relay via MQTT, or log to a Google Sheet.

Example: If the ESP32 sends {"command": "turn_on_light"}, ASI Biont can execute:

if command == "turn_on_light":
    # Publish to ESP32 relay topic
    mqtt_client.publish("esp32/relay/1", "ON")
    # Log to database (e.g., PostgreSQL)
    db.execute("INSERT INTO logs (event, time) VALUES (%s, NOW())", ("light_on",))

Pitfalls to Avoid

  1. Wi-Fi disconnects: ESP32 MQTT clients may drop. Add auto-reconnect logic in MicroPython (client.connect() in a try-except).
  2. Broker availability: Public brokers like test.mosquitto.org are unreliable for production. Run Mosquitto on a Raspberry Pi or use a cloud broker (HiveMQ, AWS IoT).
  3. Audio aliasing: MAX9814 is analog; you’ll get noise from power supply ripple. Add a 100nF capacitor between VCC and GND near the module.
  4. Sandbox timeout: execute_python scripts are limited to 30 seconds. For long-running MQTT subscriptions, ASI Biont uses a non-blocking approach—the AI handles this automatically.
  5. Threshold tuning: Start with a high threshold, then lower it gradually. Use the print() function in the ESP32 code to see raw ADC values in the serial monitor.

What to Do Next

  1. Flash your ESP32 with the MicroPython code above (change Wi-Fi/ broker settings).
  2. Open ASI Biont chat at asibiont.com.
  3. Describe your integration: “Connect to MQTT broker, subscribe to topic esp32/audio/amplitude, send Telegram alert when amplitude > 2000.”
  4. Test with a clap or knock.

No coding. No waiting. Your microphone just became an intelligent voice sensor.

Why This Matters

Voice is the most natural interface. But integrating microphones with AI has been complex—until now. ASI Biont removes the barrier by letting you describe your setup and the AI does the heavy lifting. Whether you’re monitoring a baby’s room, detecting break-ins, or building a voice-controlled smart home, ASI Biont + ESP32 + MAX9814/INMP441 gives you a production-ready voice pipeline in minutes.

Start your integration today at asibiont.com.

← All posts

Comments