Introduction
MQTT (Message Queuing Telemetry Transport) is one of the most in-demand protocols for the Internet of Things. It was developed in 1999 by IBM for telemetry on oil pipelines, and today all major cloud platforms use it: AWS IoT Core, Azure IoT Hub, Google Cloud IoT. Mosquitto and EMQX brokers have become the industry standard, ensuring data transfer from sensors to control systems. But a stream of raw data is useless until there is something to analyze it and turn it into actions. That's where the ASI Biont AI agent comes in.
ASI Biont is an agent that connects to external devices through a natural language dialogue. Instead of complex control panels and manual integration writing, you simply describe the task in a chat, and the agent generates and runs Python code itself. For MQTT, this means connecting a broker takes a minute, not a day. In this article, we'll walk through the connection architecture, compare Mosquitto and EMQX, show a code example, and explain how smart home and industrial automation becomes a matter of a few messages.
Why Connect an AI Agent to an MQTT Broker?
MQTT works on the publish-subscribe model: devices publish messages to topic channels (topics), and subscribers receive these messages in real time. This allows building flexible distributed systems. However, a classic subscriber is either a human or a script with fixed logic. An AI agent adds an intelligence layer:
-
Monitoring and anomalies. The agent analyzes sensor values, detects deviations, and can send a notification via Telegram (for example, using requests.post to api.telegram.org).
-
Automation. By combining data from multiple topics, the agent makes contextual decisions: "if the room temperature is above 25 °C and the window is closed, turn on the air conditioner."
-
Voice and text control. By writing "turn off the kitchen light," you get an action that the agent performs by publishing the value
falseto thelights/kitchen/settopic.
All the logic is written by AI, not a developer. Moreover, ASI Biont does this not through a ready-made plugin, but by generating code for a specific scenario.
How ASI Biont Connects to an MQTT Broker
For MQTT, ASI Biont uses the standard Python library paho-mqtt (documentation: paho-mqtt.readthedocs.io). Connection happens through chat: you describe the broker address, port, topics, and authentication parameters, and the agent writes and executes a script in the sandbox. There are no pre-built connectors — each time a new code is created for your task. This provides flexibility: you can switch between Mosquitto and EMQX, change QoS, add TLS, without changing the overall architecture.
Important: MQTT does not require a Hardware Bridge (bridge.py), as it is an Ethernet protocol. Hardware Bridge is used only for COM ports (RS-232/RS-485) and is downloaded from the ASI Biont dashboard. For MQTT, an IP address and port are sufficient.
Connection Architecture
The system with MQTT and ASI Biont is built according to the following scheme:
+----------------+ publish +------------------+ subscribe +----------------+
| Sensors/ | ----------------> | MQTT Broker | <------------- | ASI Biont |
| Devices | | (Mosquitto/ | | AI Agent |
+----------------+
| /EMQX) | +----------------+
+------------------+
Devices publish data to topics, and ASI Biont subscribes to them. After analysis, the agent can publish commands to control topics. A plus of this scheme is that the device never "knows" about the intelligent agent. This makes it possible to replace equipment, add new sensors, and scale the system without downtime.
For reliable message delivery, three QoS (Quality of Service) levels are used: 0 — at most once, 1 — at least once, 2 — exactly once. In industrial scenarios, QoS 1 is recommended, and QoS 2 for critical commands.
Code Example: Smart Home on Mosquitto
Consider a scenario: a temperature sensor publishes data to the sensors/temperature topic, and ASI Biont must turn on the fan relay in the actuators/relay topic if the temperature is above 25 °C. Below is the Python code that the agent generates for execution in the sandbox. There is no infinite loop here — the script finishes within the set timeout.
import paho.mqtt.client as mqtt
import time
BROKER = "192.168.1.50"
PORT = 1883
TOPIC_TEMP = "sensors/temperature"
TOPIC_RELAY = "actuators/relay"
def on_message(client, userdata, msg):
try:
temp = float(msg.payload.decode())
if temp > 25:
client.publish(TOPIC_RELAY, "ON", qos=1)
else:
client.publish(TOPIC_RELAY, "OFF", qos=1)
except ValueError:
pass
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER, PORT, 60)
client.subscribe(TOPIC_TEMP)
client.loop_start()
time.sleep(10) # wait within the sandbox timeout
client.loop_stop()
client.disconnect()
This is a simplified version. In reality, ASI Biont adds error handling, connection checking, and logging to the chat. But the main thing is you see how little code is needed for a full-fledged integration.
Comparison of Mosquitto and EMQX
The choice of broker depends on your scale. Below is a comparison table based on the official sites mosquitto.org and emqx.io.
| Criterion | Mosquitto | EMQX |
|---|---|---|
| License | EPL-2.0 / BSD | Apache 2.0 (open source) |
| Implementation language | C | Erlang/OTP |
| Maximum number of connections | up to 100,000 per node | millions in a cluster |
| MQTT 5.0 support | Yes | Yes |
| Clustering | Limited, manual | Built-in, automatic |
| Extensibility | C plugins | Rules, Data Integration, Webhooks |
| RAM consumption | from 5–10 MB | from 200 MB and above |
| Deployment complexity | Low | Medium |
| Typical scenarios | Smart home, Edge tests | Industrial IoT, large telemetry |
The conclusion is simple. For a home project or a lab stand, Mosquitto starts with one command and consumes minimal resources. For production level with a stream of millions of messages, EMQX is better suited with its built-in clustering and monitoring. Both brokers work perfectly with ASI Biont because the agent communicates via standard MQTT.
Industrial Automation: Another Scenario
The MQTT + AI agent combination is used not only in residential buildings. In manufacturing, machines publish data about vibration, bearing temperature, and operating time to topics. ASI Biont subscribes to factory/cnc_1/status and works as a predictive analyst. If the vibration level sharply increases, the agent publishes emergency_stop to the factory/cnc_1/control topic and notifies staff in Telegram via the HTTP API. This makes it possible to implement predictive maintenance without an expensive SCADA system.
How to Connect an MQTT Broker to ASI Biont in Five Steps
-
Go to asibiont.com and create a new agent.
-
Write in the chat: "Connect to the MQTT broker at 192.168.0.5:1883, subscribe to the plant/telemetry topic."
-
The agent will clarify the parameters: login, password, data type, TLS requirement.
-
After clarification, ASI Biont will generate a Python script with
paho-mqttand run it in the sandbox. -
You will see a stream of messages in the chat — the agent will start analyzing data and answering questions.
No control panels, configuration files, or "Add device" buttons. Everything is done through the dialogue.
Universal Integration via execute_python
An important feature of ASI Biont is support for the universal execute_python method. This means the agent can connect to any device and protocol if a Python library exists for it. You just need to describe the connection parameters in the chat: IP address, port, baud rate, API key, or device path. The AI agent will choose the appropriate library itself: pyserial, paramiko, paho-mqtt, pymodbus, aiohttp, opcua-asyncio, etc. This approach eliminates the need to wait for developers to add an official integration for your device. Connect anything right now.
Useful Setup Tips
-
For local development, enable anonymous access in Mosquitto:
allow_anonymous true,listener 1883. For production, be sure to use login/password and TLS. -
If the broker works over WebSocket (port 8080/8083), ASI Biont will also be able to connect via the
paho-mqttclient with thetransport="websockets"parameter. -
When using QoS 1, don't forget to handle duplicate messages in the code generated by AI.
-
For long-running tasks, ASI Biont can run scripts periodically on a schedule rather than maintaining a constant connection.
Why This Is the Future of Integrations
Traditional IoT device integration takes days: you need to write code, test, deploy. An AI agent does this in the chat, adapting to a specific broker and device. You can change a topic, switch brokers, add a new rule — just describe it to the agent. It will rewrite the logic in seconds. By combining MQTT with HTTP APIs, databases, and other sources, ASI Biont becomes the "brain" of your IoT infrastructure. All of this already works on the asibiont.com platform.
Conclusion
MQTT is the standard "language" of smart devices. The ASI Biont AI agent turns it into a full-fledged assistant that listens to sensors, analyzes data, and controls actuators. Thanks to direct paho-mqtt support and the universal execute_python, you can connect any MQTT broker to the agent — be it a lightweight Mosquitto for a smart home or a powerful EMQX for industrial IoT. Integration no longer requires a team of developers: just describe the task in the chat at asibiont.com, and in a minute you'll have working automation.
Try it yourself: go to asibiont.com, create an agent, and ask it to connect to your MQTT broker. In a minute, you'll see the AI agent start monitoring data and making decisions. This is no longer the future — it's a tool available today.
Comments