Smart cities rely on a dense web of sensors—temperature, humidity, air quality, motion, noise—to monitor and optimize urban life. But raw sensor data is just noise without intelligent interpretation. That's where AI agents like ASI Biont come in. Instead of writing custom glue code for each sensor type, you simply describe your setup in a chat interface, and the AI agent generates the integration code, connects to your hardware, and starts automating tasks. This guide walks through how to connect Smart City sensors (ESP32, Arduino, Raspberry Pi) to ASI Biont using MQTT, COM port, SSH, and other protocols, with real code examples.
Why Connect Smart City Sensors to an AI Agent?
Urban sensor networks collect massive amounts of data—traffic patterns, pollution levels, energy usage. Manual analysis is impossible at scale. An AI agent can:
- Detect anomalies (sudden temperature spikes, gas leaks)
- Trigger automated responses (open vents, send alerts)
- Predict maintenance needs (e.g., HVAC filter replacement)
- Optimize street lighting based on motion and ambient light
ASI Biont supports over a dozen integration methods, from industrial protocols (Modbus, OPC-UA) to IoT standards (MQTT, CoAP). The key advantage: you don't need to pre-configure dashboards or write boilerplate. Just chat with the AI.
Integration Methods Supported by ASI Biont
| Method | Best For | Example Devices |
|---|---|---|
| MQTT | Wireless IoT sensors (ESP32, RPi) | Temperature, air quality, motion |
| COM port (RS-232/485) | Wired microcontrollers | Arduino, industrial PLCs |
| SSH | Linux-based gateways | Raspberry Pi with camera |
| Modbus/TCP | Industrial controllers | Schneider, Siemens PLC |
| HTTP API | Smart plugs, cameras | REST-enabled thermostats |
| execute_python | Any device via custom script | OPC UA, BACnet, custom protocols |
Real-World Scenario: ESP32 Air Quality Monitor with MQTT
Imagine an urban park equipped with ESP32 boards that measure temperature (DHT22), CO2 (MH-Z19B), and particulate matter (PMS5003). Each ESP32 publishes data to an MQTT broker (e.g., Mosquitto). ASI Biont subscribes to the topics and takes action.
ESP32 side (MicroPython)
import network
import time
from umqtt.simple import MQTTClient
from machine import Pin, I2C
import dht
# Wi-Fi and MQTT config
WIFI_SSID = 'ParkNet'
WIFI_PASS = 'sensor2026'
MQTT_BROKER = '192.168.1.100'
MQTT_TOPIC = b'park/sensors/esp32_01'
# Sensor init
dht_sensor = dht.DHT22(Pin(4))
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(WIFI_SSID, WIFI_PASS)
while not wlan.isconnected():
time.sleep(1)
client = MQTTClient('esp32_01', MQTT_BROKER)
client.connect()
while True:
dht_sensor.measure()
temp = dht_sensor.temperature()
hum = dht_sensor.humidity()
# Also read PMS5003 via UART...
payload = '{{"temp":{},"hum":{}}}'.format(temp, hum)
client.publish(MQTT_TOPIC, payload)
time.sleep(60)
ASI Biont side (execute_python with paho-mqtt)
The user tells the AI: "Subscribe to park/sensors/#, log temperature values, and if temp > 40°C publish an alert to topic alerts/high_temp." The AI writes the following script and runs it in the sandbox (30s timeout – no infinite loop; it runs once and publishes the alert):
import paho.mqtt.client as mqtt
import json
def on_message(client, userdata, msg):
payload = json.loads(msg.payload)
temp = payload.get('temp', 25)
if temp > 40:
alert_msg = json.dumps({'device': msg.topic, 'temp': temp, 'action': 'alert'})
client.publish('alerts/high_temp', alert_msg, qos=1)
print("Alert sent for", msg.topic)
client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.100', 1883, 60)
client.subscribe('park/sensors/#')
client.loop_start()
# Wait briefly to receive one message (timeout fit for sandbox)
import time
time.sleep(5)
client.loop_stop()
Since execute_python has a 30-second limit, the script above runs a single cycle. For persistent monitoring, the AI can instead use the industrial_command tool with the publish command to send alerts when conditions are detected via a scheduled loop (handled outside the sandbox).
How to Set It Up: Just Chat with AI
- Run Hardware Bridge (if using COM port) – download
bridge.pyfrom the ASI Biont dashboard, launch withpython bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200. - For MQTT: Provide the broker IP and topic prefix in the chat.
- For SSH: Supply host, username, and password/key.
- The AI writes the integration code, executes it, and begins interacting.
No dashboards to configure, no complex IDEs. The AI handles protocol negotiation, error handling, and data parsing.
More Smart City Scenarios
- Raspberry Pi + Camera: Connect via SSH. AI runs OpenCV to count pedestrians or detect parked cars, then publishes to a city dashboard.
- CO₂ Sensor via COM port: Arduino reads an MH-Z19B sensor. User connects via Hardware Bridge. AI sends
serial_write_and_readcommands to request data and logs CO₂ levels. - Modbus/TCP Flow Meter: AI reads registers from a Modbus flow meter, calculates cumulative flow, and triggers a valve if flow exceeds threshold.
- OPC UA Weather Station: AI reads variables (wind speed, UV index) from an OPC UA server, correlates with historical data, and predicts high-risk fire weather conditions.
Conclusion
Smart city sensor integration with ASI Biont eliminates the months of custom development typically required to connect diverse IoT hardware. Whether you're using MQTT, Modbus, COM port, or SSH, the AI agent writes the glue code on the fly, adapts to your specific hardware, and starts automating immediately. No waiting for vendor updates, no learning 15 different protocols. Just describe what you need in natural language.
Ready to connect your city's sensors? Try ASI Biont for free and watch the AI transform raw data into intelligent urban management.
Comments