How to Connect a Microphone (MAX9814, INMP441) to the ASI Biont AI Agent
Microphones are no longer just for phone calls and podcasts. When you connect a MAX9814 or INMP441 microphone to an AI agent like ASI Biont, you unlock voice-controlled automation, sound-level-triggered actions, and acoustic anomaly detection for workshops, smart homes, or industrial environments. This guide walks you through the wiring, the code, and the AI integration steps — all through natural language chat, no management panels required.
Why Pair a Microphone with an AI Agent?
ASI Biont is an AI agent that typically talks to PLCs, CNCs, and industrial controllers via protocols like Modbus, OPC-UA, or MQTT. Adding a microphone gives the AI a new sense: hearing. You can command a machine by voice, detect a broken bearing from its sound signature, or start a ventilation fan when noise exceeds a threshold. The integration is surprisingly easy because ASI Biont generates the glue code itself — you just describe the setup in chat.
Choosing the Connection Method
Two popular microphone modules work well with this approach:
- MAX9814 — analog output, built-in AGC, requires an ADC (ESP32 has one).
- INMP441 — digital I2S output, wide dynamic range, direct ESP32 connection.
In both cases, an ESP32 acts as a bridge between the microphone and the network. For ASI Biont, the two primary interfaces are:
- MQTT — ESP32 publishes sound levels to a broker (e.g., Mosquitto); ASI Biont subscribes via
paho-mqtt. - COM port — ESP32 connected over USB/serial to the machine running ASI Biont's Hardware Bridge (
bridge.py), which you download from the dashboard.
This article focuses on MQTT, but we'll cover both.
Wiring Diagram
| Microphone | ESP32 Pin | Notes |
|---|---|---|
| MAX9814 VDD | 3.3V | 2.7–5.5V range, use 3.3V |
| MAX9814 GND | GND | Common ground |
| MAX9814 OUT | GPIO34 (ADC1_CH6) | Analog signal |
| INMP441 VDD | 3.3V | Digital supply |
| INMP441 GND | GND | Common ground |
| INMP441 SCK | GPIO16 | I2S bit clock (BCK) |
| INMP441 WS | GPIO15 | Word select (LRCK) |
| INMP441 SD | GPIO14 | Serial data (DOUT) |
| INMP441 L/R | GND | Left channel (0) |
For the MAX9814, you may also connect the AR (auto gain) pin to VDD for a fixed gain. These wiring conventions are standard for ESP32 dev boards — always double-check your specific board's pinout.
MicroPython Code for ESP32
The following MicroPython example reads the MAX9814 analog output, computes an RMS sound level, and publishes it to an MQTT topic every second. This is the kind of code you'd flash onto an ESP32 once; AI-side logic is handled by ASI Biont.
from machine import Pin, ADC
import time, ujson
from umqtt.simple import MQTTClient
BROKER = "192.168.1.100" # MQTT broker IP
CLIENT_ID = "mic_esp32"
TOPIC = "sensors/mic/level"
adc = ADC(Pin(34))
adc.atten(ADC.ATTN_11DB) # 0–3.6V range
def connect_mqtt():
client = MQTTClient(CLIENT_ID, BROKER)
client.connect()
return client
try:
client = connect_mqtt()
except Exception as e:
print("MQTT connect failed:", e)
while True:
time.sleep(1)
while True:
samples = [adc.read() for _ in range(50)]
avg = sum(samples) / len(samples)
rms = max(1, int((sum((s - avg)**2 for s in samples) / len(samples))**0.5))
payload = ujson.dumps({"rms": rms, "ts": time.time()})
try:
client.publish(TOPIC, payload)
except:
client = connect_mqtt()
time.sleep(1)
For the INMP441, use MicroPython's built-in I2S class to read samples and calculate a similar metric. The protocol remains unchanged — you're still publishing a numeric level to the broker.
Connecting ASI Biont via MQTT
Now comes the fascinating part. In the ASI Biont chat, you simply write:
Connect to MQTT broker at 192.168.1.100, topic sensors/mic/level. Subscribe and alert me when RMS exceeds 500.
ASI Biont then generates a Python script using paho-mqtt. Here's the kind of code it produces:
import paho.mqtt.client as mqtt
import json, requests
THRESHOLD = 500
BROKER = "192.168.1.100"
TOPIC = "sensors/mic/level"
def on_message(client, userdata, msg):
data = json.loads(msg.payload)
if data["rms"] > THRESHOLD:
print("High sound level:", data["rms"])
# Send a Telegram notification via Bot API
requests.post(
"https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage",
params={"chat_id": "<CHAT_ID>", "text": f"Alert: RMS {data['rms']}"}
)
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER)
client.subscribe(TOPIC)
client.loop_forever()
No pre-configured connectors, no drag-and-drop flow editors — just a natural-language description that turns into a working subscription.
Real-World Scenario: Voice-Activated Machine Start
Let's make it tangible. You have a lathe in a workshop. You want to start it by clapping twice (or speaking a keyword). The ESP32 microphone continuously publishes RMS values. ASI Biont receives them and, when the level crosses a threshold (say, RMS > 600), it sends a Modbus write to a PLC that switches the lathe's contactor.
In the chat, you type:
When microphone RMS > 600, write 1 to register 100 on PLC 192.168.1.50 using Modbus/TCP.
ASI Biont then generates the trigger logic. For Modbus, it uses pymodbus; the resulting code might look like:
from pymodbus.client import ModbusTcpClient
import paho.mqtt.client as mqtt
modbus_ip = "192.168.1.50"
client = mqtt.Client()
def on_message(client, userdata, msg):
import json
data = json.loads(msg.payload)
if data["rms"] > 600:
mc = ModbusTcpClient(modbus_ip)
mc.connect()
mc.write_register(100, 1)
mc.close()
client.on_message = on_message
client.connect("192.168.1.100")
client.subscribe("sensors/mic/level")
client.loop_forever()
The AI wrote the entire integration, including the connection handling, from your words.
The Power of execute_python
What if your microphone is connected not via MQTT but directly to a COM port? ASI Biont handles that too. You download bridge.py from the dashboard, run it with the token and port parameters:
python bridge.py --token=XXX --ports=COM3 --baud 115200 --rate=10
Then in chat you say:
Read analogue values from COM3 and log them.
ASI Biont will use industrial_command(protocol='serial', command='...') to talk to the bridge, or — even more flexibly — it can write a custom Python script using pyserial and run it via execute_python. The latter is the universal fallback: ASI Biont connects to ANY device through execute_python. The AI writes the integration code on the spot, using pyserial, paramiko, paho-mqtt, pymodbus, aiohttp, or opcua-asyncio as needed. There is no waiting for official device drivers. You describe the parameters (port, IP, baud rate, API key) and the AI does the rest.
This makes the microphone integration a perfect example of the platform's philosophy: the user stays in a chat interface, the AI handles the technical plumbing.
Conclusion
Integrating a MAX9814 or INMP441 microphone with ASI Biont is straightforward, whether you choose MQTT for wireless flexibility or a COM port for direct serial access. The AI agent turns your sound data into actionable automation — from voice commands to acoustic alerts — in a matter of seconds. Because of execute_python, the possibilities extend far beyond these two microphones; any sensor or actuator can be connected just by describing it in chat.
Ready to give your sound sensor an AI brain? Head over to asibiont.com and try the integration yourself. In one chat session, you'll have a voice-controlled, AI-powered system running.
Comments