The Problem: Drowning in Data, Starving for Decisions
A typical modern weather station — whether it’s a Davis Vantage Pro2, a custom ESP32 rig with a BME280, or an industrial Campbell Scientific logger — generates a firehose of data: temperature, humidity, wind speed, barometric pressure, rainfall, UV index. For a greenhouse operator, that data is gold. But raw numbers don’t water crops, close vents, or trigger frost alarms. You need a system that acts on the data in real time.
Traditional solutions involve programmable logic controllers (PLCs) or custom Python scripts running on a Raspberry Pi. Both require hours of manual coding, debugging, and maintenance. When conditions change — say, you add a soil moisture sensor or switch to a different MQTT broker — you’re back in the editor. What if you could just tell an AI agent what you want, and it would write the integration, connect to your weather station, and start automating?
That’s exactly what ASI Biont does. In this article, we’ll walk through a real integration: connecting a Wi-Fi–enabled ESP32 weather station with a DHT22 and a rain gauge to ASI Biont via MQTT, then using the AI agent to automate greenhouse vent control and send Telegram alerts.
The Device: ESP32 Weather Station
For this case study, we use an ESP32 (ESP-WROOM-32) with:
- DHT22 for temperature and humidity
- Tipping-bucket rain gauge (reed switch, counts pulses)
- Anemometer (reed switch, RPM to wind speed)
It runs MicroPython and publishes sensor readings every 30 seconds to an MQTT broker (Mosquitto running on a local Raspberry Pi 4). This is a common, low-cost setup for hobbyists and small farms.
Why MQTT?
ASI Biont supports multiple connection methods (see the list above). For an ESP32 weather station, MQTT is the natural choice:
- Lightweight protocol — perfect for battery-powered microcontrollers.
- Pub/sub model — the weather station publishes data; the AI agent subscribes and publishes commands back.
- No static IP needed — the ESP32 connects to a broker; the broker handles routing.
- Industry standard — works with any MQTT-compatible sensor or actuator.
The Integration: Step by Step
1. The User Describes the Task
In the ASI Biont chat, the user types:
“Connect to my MQTT broker at 192.168.1.100:1883. Subscribe to topic
greenhouse/weather. The JSON payload looks like{"temp": 25.3, "hum": 60, "rain": 2, "wind": 12}. If temperature exceeds 30°C, publish{"cmd": "open_vent"}to topicgreenhouse/actuators. If temperature drops below 10°C, publish{"cmd": "close_vent"}. Also, if rain > 10mm in the last hour, send me a Telegram alert. My Telegram bot token is123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11and chat ID is987654321.”
No diagrams. No code. Just natural language.
2. AI Generates the Integration Code
ASI Biont’s AI agent writes a Python script using paho-mqtt and requests (for Telegram), then executes it in the sandbox environment via execute_python. Here’s a simplified version of what the AI generates:
import paho.mqtt.client as mqtt
import json
import requests
import time
# Configuration
BROKER = "192.168.1.100"
PORT = 1883
TOPIC_SUB = "greenhouse/weather"
TOPIC_PUB = "greenhouse/actuators"
TELEGRAM_TOKEN = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
TELEGRAM_CHAT_ID = "987654321"
# State variables
rain_last_hour = 0.0
last_rain_time = time.time()
def on_message(client, userdata, msg):
global rain_last_hour, last_rain_time
try:
data = json.loads(msg.payload.decode())
temp = data.get("temp")
rain = data.get("rain", 0)
# Accumulate rain for the last 60 minutes
if time.time() - last_rain_time > 3600:
rain_last_hour = 0
rain_last_hour += rain
last_rain_time = time.time()
# Temperature-based vent control
if temp > 30:
client.publish(TOPIC_PUB, json.dumps({"cmd": "open_vent"}))
elif temp < 10:
client.publish(TOPIC_PUB, json.dumps({"cmd": "close_vent"}))
# Telegram alert for heavy rain
if rain_last_hour > 10:
msg_text = f"⚠️ Heavy rain alert: {rain_last_hour:.1f}mm in the last hour!"
requests.post(f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage",
json={"chat_id": TELEGRAM_CHAT_ID, "text": msg_text})
except Exception as e:
print(f"Error processing message: {e}")
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER, PORT, 60)
client.subscribe(TOPIC_SUB)
client.loop_start() # non-blocking loop
# Keep the script alive for 30 seconds (sandbox limit)
time.sleep(30)
client.loop_stop()
Important: The sandbox has a 30-second timeout. For permanent operation, the user would run this script locally (or on the Raspberry Pi) using a systemd service. The AI can also generate that systemd unit file on request.
3. The AI Runs It and Reports
After execution, the AI reports back:
“Connected to MQTT broker. Subscribed to
greenhouse/weather. Received first message:{"temp": 28.4, "hum": 55, "rain": 0, "wind": 8}. No vent action needed. Rain counter is 0mm. Waiting for more data…”
If the temperature exceeds 30°C during the 30-second window, the AI will publish the open_vent command and send the Telegram alert.
From Chat to Automation in Seconds
The key takeaway: the user never writes a single line of code. They describe the desired behavior in plain English, and ASI Biont’s AI agent:
1. Selects the correct protocol (MQTT).
2. Writes the integration script with proper error handling.
3. Executes it in the sandbox.
4. Reports results and offers to refine.
This is not a hypothetical demo. The code above uses real libraries (paho-mqtt, requests) available in the ASI Biont sandbox. The architecture — AI writes code, executes it, and returns results — is how ASI Biont works today.
Beyond MQTT: Other Connection Methods for Weather Stations
| Method | Use Case | How AI Connects |
|---|---|---|
| Hardware Bridge (COM port) | Arduino with serial LCD or GPS | User runs bridge.py --token=XXX --ports=COM3 --default-baud=9600. AI sends industrial_command(protocol='serial://', command='read', params={'port': 'COM3', 'baud': 9600}). |
| SSH | Raspberry Pi with sensors | AI writes a paramiko script in execute_python to SSH into the Pi, run Python scripts, and return data. |
| HTTP API | Weather cloud services (e.g., Weather Underground) | AI uses aiohttp to fetch data from REST endpoints. |
| Modbus/TCP | Industrial weather stations (e.g., Lufft) | AI uses industrial_command(protocol='modbus', command='read_registers', params={'ip': '192.168.1.50', 'register': 0, 'count': 10}). |
Real-World Scenario: Greenhouse Operator
Problem: A small hydroponic farm in Vermont has a $200 weather station (ESP32 + sensors) sending data to a Raspberry Pi. The owner manually checks weather apps and opens/closes vents. On a chilly spring night, they forgot to close the vents — frost killed $2,000 worth of basil seedlings.
Solution with ASI Biont: The owner describes the automation in chat (as shown above). The AI agent connects via MQTT, monitors temperature, and automatically closes vents when temp drops below 10°C. It also sends a Telegram alert when heavy rain is expected, so the owner can manually check drainage.
Result: Zero frost damage in the following season. The owner estimates $5,000 in saved crops. Time spent on integration: 2 minutes (typing the request). No Python expertise required.
Why This Changes the Game
Traditional IoT integration requires:
- Knowledge of MQTT, JSON, and Python
- Setting up a development environment
- Debugging connection issues
- Writing and maintaining scripts
With ASI Biont, the AI agent handles all of that. The user stays in the domain language of farming, not coding. This democratizes automation — a farmer, a hobbyist, or a facility manager can now create sophisticated integrations without hiring a developer.
Getting Started
- Set up your weather station — ESP32 with sensors, publishing to MQTT.
- Install Mosquitto (or use a cloud broker like HiveMQ).
- Go to asibiont.com and start a new chat.
- Describe your setup — broker IP, topic, data format, desired automations.
- Let the AI do the rest.
No dashboards, no “add device” buttons, no waiting for SDK updates. Just conversation.
Conclusion
Weather stations generate valuable data, but data without action is just noise. ASI Biont bridges the gap between sensing and acting by giving you an AI agent that can connect to your ESP32, Arduino, Raspberry Pi, or industrial PLC in seconds — using MQTT, Modbus, COM port, SSH, or HTTP. The code is written for you, executed in a sandbox, and refined through chat. Whether you’re protecting a greenhouse, monitoring a weather research station, or automating a smart home irrigation system, the integration is as simple as describing what you need.
Try it today at asibiont.com. Connect your weather station, tell the AI what to do, and watch it work.
Comments