Weather Stations + AI Agent: Build a Smart Garden That Waters Itself and Predicts Storms

Stop Wasting Water and Reacting to Weather — Let an AI Agent Do the Thinking

You’ve probably seen those $20 Wi-Fi weather stations on Amazon, or maybe you’ve built one with an ESP32 and a DHT22. They log temperature, humidity, pressure, and rain — and then what? You check a dashboard, maybe get an email, and eventually ignore it. The real power isn’t in collecting data — it’s in acting on it. That’s where ASI Biont comes in.

Instead of fighting with Node-RED flows or writing endless if-else logic, you describe what you want in plain English, and ASI Biont’s AI agent writes the integration code, connects to your weather station, and runs automation. This article shows you exactly how to connect a weather station (ESP32 + DHT22/BME280, or a Raspberry Pi with sensors) to ASI Biont — with real code, real protocols, and real results.

Why Connect a Weather Station to an AI Agent?

Traditional weather controllers (like those from Rain Bird or Hunter) are dumb timers. They water on schedule, regardless of rain. Even “smart” controllers like Rachio or Netamo require cloud accounts, proprietary apps, and limited logic. With an AI agent:

  • Predictive irrigation: AI checks weather forecast, soil moisture, and plant type, then waters only when needed.
  • Storm alerts: AI monitors pressure drops and sends Telegram alerts before a storm hits.
  • Greenhouse automation: AI adjusts vents, fans, and heaters based on real-time sensor data.
  • Energy savings: AI switches off irrigation pumps when rain is forecast, saving electricity and water.

The best part? You don’t code the logic. AI writes it for you.

How ASI Biont Connects to Your Weather Station

ASI Biont supports multiple connection methods, depending on your hardware:

Hardware Protocol How AI Connects
ESP32 (DHT22/BME280) MQTT AI writes a Python script with paho-mqtt that subscribes to sensor topics and publishes commands
Raspberry Pi + sensors SSH AI connects via paramiko, runs Python scripts to read GPIO, and returns data
Arduino + sensors via USB COM port (Hardware Bridge) User runs bridge.py on their PC, AI sends serial_write_and_read commands
Industrial weather station (Modbus) Modbus/TCP AI uses industrial_command with read_registers to poll sensors

The Magic: execute_python

No matter the protocol, the heart of integration is execute_python — ASI Biont’s sandbox environment where AI writes and runs Python code on the server. The sandbox has all major libraries pre-installed: paho-mqtt, paramiko, pymodbus, aiohttp, requests, snap7, bac0, and more. You just describe what you need:

“Connect to my ESP32 weather station via MQTT at broker.hivemq.com, topic sensor/temp, and send a Telegram alert if temperature exceeds 35°C.”

AI generates the code, runs it, and the integration works instantly.

Real-World Example: ESP32 + BME280 + MQTT → ASI Biont → Telegram Alerts

The Problem

You have an ESP32 with a BME280 sensor (temperature, humidity, pressure) sitting in your garden. It publishes data every 10 seconds to an MQTT broker. You want: (1) real-time monitoring in Telegram, (2) an alert if temperature > 35°C or pressure drops rapidly (storm warning), (3) automatic valve control to water plants when soil is dry (requires soil moisture sensor, but we'll keep it simple).

The Solution

Step 1: Set up ESP32 firmware (you do this once)

Use this MicroPython script on your ESP32 to read BME280 and publish to MQTT:

import network
import time
from machine import Pin, I2C
import bme280
from umqtt.simple import MQTTClient

# Wi-Fi credentials
WIFI_SSID = "YourWiFi"
WIFI_PASS = "YourPassword"

# MQTT broker
BROKER = "broker.hivemq.com"
TOPIC_TEMP = "garden/weather/temperature"
TOPIC_HUM = "garden/weather/humidity"
TOPIC_PRESS = "garden/weather/pressure"
TOPIC_CMD = "garden/control/valve"

def connect_wifi():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    wlan.connect(WIFI_SSID, WIFI_PASS)
    while not wlan.isconnected():
        time.sleep(0.5)
    print("Wi-Fi connected")

def read_sensor():
    i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000)
    bme = bme280.BME280(i2c=i2c)
    t, p, h = bme.read_compensated_data()
    temp = t / 100
    press = p / 25600  # hPa
    hum = h / 1024
    return temp, press, hum

connect_wifi()
client = MQTTClient("esp32_garden", BROKER)
client.connect()

while True:
    temp, press, hum = read_sensor()
    client.publish(TOPIC_TEMP, str(temp))
    client.publish(TOPIC_HUM, str(hum))
    client.publish(TOPIC_PRESS, str(press))
    print(f"Temp: {temp}, Press: {press}, Hum: {hum}")
    time.sleep(10)

Step 2: Tell ASI Biont to connect

Open a chat with ASI Biont and type:

“Connect to MQTT broker at broker.hivemq.com. Subscribe to topics garden/weather/#. When temperature > 35°C, send a Telegram alert. Also, if pressure drops more than 2 hPa in 5 minutes, alert ‘Storm warning’. Use my Telegram bot token: 123456:ABC-DEF.”

Step 3: AI generates and runs the integration

ASI Biont writes a Python script using paho-mqtt and requests (for Telegram) and runs it in the sandbox. Here’s what the AI creates (simplified):

import paho.mqtt.client as mqtt
import requests
import json
from collections import deque

TELEGRAM_BOT_TOKEN = "123456:ABC-DEF"
TELEGRAM_CHAT_ID = "your_chat_id"
PRESSURE_HISTORY = deque(maxlen=30)  # 30 readings = 5 minutes at 10s interval

def on_message(client, userdata, msg):
    topic = msg.topic
    value = float(msg.payload.decode())

    if topic == "garden/weather/temperature":
        if value > 35:
            send_telegram(f"🔥 Temperature alert: {value}°C!")
    elif topic == "garden/weather/pressure":
        PRESSURE_HISTORY.append(value)
        if len(PRESSURE_HISTORY) == 30:
            drop = PRESSURE_HISTORY[0] - PRESSURE_HISTORY[-1]
            if drop > 2:
                send_telegram(f"⚡ Storm warning! Pressure dropped {drop:.1f} hPa in 5 min")

def send_telegram(text):
    url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
    data = {"chat_id": TELEGRAM_CHAT_ID, "text": text}
    requests.post(url, json=data)

client = mqtt.Client()
client.on_message = on_message
client.connect("broker.hivemq.com", 1883)
client.subscribe("garden/weather/#")
client.loop_forever()

Step 4: Enjoy

The AI agent runs this script in the sandbox. It stays connected to MQTT, listens to sensor data, and sends you Telegram alerts when thresholds are exceeded. You don’t touch any code.

Advanced Scenario: Raspberry Pi + BME280 + SSH → AI Agent

If you prefer a Raspberry Pi (maybe you have multiple sensors or cameras), ASI Biont connects via SSH. You provide the Pi’s IP, username, and SSH key (or password). Then you say:

“Read temperature from my Pi’s BME280 every 30 seconds. If temperature > 30°C and humidity < 50%, turn on the fan (GPIO 18). Log all data to a CSV file.”

AI generates and runs a script like this:

import paramiko
import time

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.1.100", username="pi", key_filename="/path/to/key")

while True:
    stdin, stdout, stderr = ssh.exec_command("python3 /home/pi/read_bme280.py")
    temp = float(stdout.read().decode().strip())

    if temp > 30:
        ssh.exec_command("echo 1 > /sys/class/gpio/gpio18/value")
        print(f"Fan ON at {temp}°C")
    else:
        ssh.exec_command("echo 0 > /sys/class/gpio/gpio18/value")

    time.sleep(30)

Wait — the script above has a while True loop. But ASI Biont’s sandbox has a 30-second timeout! So AI uses a different approach: it sets up a cron job on the Pi via SSH, or runs a lightweight script that logs data and returns it. The AI is smart enough to adapt.

Comparing ASI Biont with Traditional Controllers

Feature Traditional Smart Controller (Rachio, Netamo) AI Agent (ASI Biont)
Hardware lock-in Works only with their devices Works with any device (ESP32, Arduino, PLC, Pi)
Automation logic Fixed schedules, basic rules AI writes custom logic on the fly
Integration complexity App setup, account creation Describe in chat, AI does the rest
Cost $100–$300 + cloud fees Free tier + your hardware
Custom alerts Limited Any condition, any channel (Telegram, email, SMS)

Pitfalls to Avoid

  1. MQTT broker must be reachable: If your ESP32 is on a local network, your broker needs to be public (like HiveMQ Cloud) or you need a bridge. ASI Biont runs in the cloud, so it can’t talk to a local broker directly. Use a public broker or expose it via a tunnel.

  2. Sandbox timeout: Scripts in execute_python are killed after 30 seconds. For long-running tasks (like MQTT subscribers), AI uses the industrial_command tool with MQTT commands (publish, subscribe) that run on the server side, not in the sandbox. The sandbox is for one-shot scripts.

  3. COM port access: You can’t access COM ports from the cloud. Use Hardware Bridge (bridge.py) — it runs on your PC and connects to ASI Biont via WebSocket. AI sends commands through industrial_command.

The Bottom Line

You don’t need to be a programmer to build a smart weather station. With ASI Biont, you just describe your hardware and what you want, and the AI agent writes the code, connects everything, and runs your automations. No dashboards, no plugins, no waiting for updates.

Try it yourself: Go to asibiont.com, create an account, and tell the AI agent: “Connect to my ESP32 weather station via MQTT and send me alerts on Telegram when temperature exceeds 30°C.” It works in seconds.

← All posts

Comments