I2S MEMS Microphone + ASI Biont: Turn ESP32 into an Edge AI Voice Assistant
The I2S MEMS microphone is one of the easiest ways to add sound to your embedded project. Combined with an ESP32, an INMP441 or ICS-43434 gives you a low-cost, high-quality audio input. But raw audio is just bytes — to make decisions, you need an intelligent agent. ASI Biont can process that stream and turn a voice command into an action (e.g., controlling a smart home relay). In this article, we show how to connect an ESP32 with I2S MEMS microphones to ASI Biont for Edge AI voice control and sound analytics.
According to the INMP441 datasheet from TDK InvenSense, the sensor provides a 24-bit I2S output with a 61 dB signal-to-noise ratio and a flat frequency response from 60 Hz to 15 kHz. The ESP32 Technical Reference Manual (Espressif) describes two I2S peripherals that can capture data from such microphones with only three GPIO lines: SCK, WS and SD. This makes a full audio pipeline — from analog sound to digital network packets — possible on a $5 module.
Why Connect Audio to an AI Agent?
A classic problem with voice interfaces is integration: the microphone must be attached to a system that can understand and act. ASI Biont is an AI agent that connects to devices via MQTT, Modbus, HTTP, WebSocket, and many other protocols. Instead of writing firmware for every command, you simply configure the trigger in the AI's chat interface. The agent then executes a Python script to process the audio and control the endpoint (e.g., a Modbus relay or a Telegram alert).
Choosing the Connection: MQTT over Wi-Fi
ESP32 has Wi-Fi, so MQTT is the natural choice. It has low overhead, asynchronous messages, and is supported by ASI Biont's paho-mqtt integration. For continuous audio streaming, MQTT QoS 0 provides minimal latency. The table below summarizes the options:
| Protocol | Interface | Typical Use | Latency |
|---|---|---|---|
| MQTT (paho) | Wi-Fi/Ethernet | Audio chunks, telemetry | Low |
| Modbus/TCP | Ethernet | PLC control, relay commands | Medium |
| COM port (bridge.py) | RS-232/485 | Wired industrial sensors | Medium |
| WebSocket/HTTP | Wi-Fi/IP | One-shot calls, REST APIs | Medium |
For local wake-word recognition, you can also run TensorFlow Lite for Microcontrollers on the ESP32 (see the TensorFlow Micro Speech example). This is purely on-device ML, so the audio stream only leaves the board when a keyword is detected.
Example: Voice-Triggered Smart Home Light
We'll connect an INMP441 to an ESP32, send 16-bit PCM audio at 16 kHz to ASI Biont over MQTT, and let the AI agent control a Modbus relay.
ESP32 side (MicroPython):
from machine import Pin, I2S
import network, time
from umqtt.simple import MQTTClient
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('YOUR_SSID', 'YOUR_PASS')
while not wlan.isconnected():
time.sleep_ms(100)
i2s = I2S(0, sck=Pin(26), ws=Pin(25), sd=Pin(22),
mode=I2S.RX, bits=16, format=I2S.MONO, rate=16000, ibuf=4096)
client = MQTTClient('esp32-audio', '192.168.1.100', 1883)
client.connect()
buf = bytearray(2048)
while True:
i2s.readinto(buf)
client.publish('asibiont/audio/raw', buf)
time.sleep_ms(20)
ASI Biont receives each chunk and runs a sandboxed Python script. The script calculates the root-mean-square (RMS) energy of the audio chunk and, if it exceeds a threshold (like a clap or a voice), triggers a Modbus write coil on a PLC:
import paho.mqtt.client as mqtt
import numpy as np
THRESHOLD = 500 # tunable
def on_audio(client, userdata, msg):
samples = np.frombuffer(msg.payload, dtype=np.int16)
rms = float(np.sqrt(np.mean(samples**2)))
if rms > THRESHOLD:
# Turn on the 1st coil of a Modbus TCP relay
industrial_command(
protocol='modbus/tcp',
command='write_coil',
host='192.168.1.50',
address=0,
value=True
)
mqttc = mqtt.Client()
mqttc.on_message = on_audio
mqttc.connect('localhost', 1883)
mqttc.subscribe('asibiont/audio/raw')
for _ in range(30): # sandbox timeout is 30 seconds
mqttc.loop(timeout=1)
The code above is a simplified illustration — ASI Biont's AI will generate the exact script for your hardware. Notice the loop ends after 30 seconds to comply with the platform's sandbox timeout. For continuous listening, you would run a persistent MQTT bridge or use a chain of periodic invocations.
Real-World Scenarios
- Voice Control of Smart Home: say 'light on' after keyword detection; AI returns a command via MQTT to a Zigbee/Modbus gateway.
- Sound Analytics in a Workshop: listen for glass breaks or abnormal noise; when detected, the AI agent sends a Telegram alert via a simple HTTP POST to api.telegram.org.
- Presence Detection: use background noise patterns (fan noise, voices) to decide if a room is occupied and optimize HVAC.
- Prototype Wake Word: use a small DNN in TensorFlow Lite Micro to detect 'Hey Biont', then offload the follow-up command to the cloud agent.
The AI Agent Writes the Integration for You
The essential advantage of ASI Biont is that you do not have to write the integration code manually. In the chat, you can say: 'My ESP32 is streaming audio to MQTT at 192.168.1.100, topic asibiont/audio/raw. Turn on a Modbus relay at 192.168.1.50 when the sound level jumps above the noise floor.' The AI agent will create the Python script, use paho-mqtt and the built-in industrial_command() method, and run it in a sandbox.
If your device uses RS-232, Modbus, or any other protocol, the same principle applies — ASI Biont connects to any device via execute_python, where the AI writes a custom Python script using pySerial, paramiko, paho-mqtt, pymodbus, aiohttp, opcua-asyncio, or snap7. There are no separate settings panels; everything is done through the chat dialog. For example, for a wired COM port device, you download the Hardware Bridge (bridge.py) from the ASI Biont dashboard (not from GitHub) and launch it with:
python3 bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=115200 --rate=10
The bridge does not expose an HTTP API; the AI agent uses industrial_command() as the single entry point to read and write data through that bridge.
Conclusion
Pairing an I2S MEMS microphone with an ESP32 gives you affordable, high-quality audio capture. Connecting that audio to ASI Biont provides the intelligence layer that turns sound into action. Whether you are automating a smart home, monitoring a factory floor, or building a voice-controlled prototype, the combination of an edge AI microphone and a conversational AI agent removes the hardest part of integration. Try it now — create an account at asibiont.com and describe your device in the chat. In seconds, ASI Biont will generate the code and begin listening.
Comments