1-Wire Integration with ASI Biont: AI-Powered Temperature Monitoring via COM Port

Introduction

In the world of IoT and industrial automation, the 1-Wire protocol remains a reliable and cost-effective solution for connecting sensors like temperature (DS18B20) and humidity (DHT22 with 1-Wire adapters) over long distances. Developed by Dallas Semiconductor (now Maxim Integrated), 1-Wire uses a single data line plus ground to communicate with multiple devices on a bus—ideal for greenhouses, server rooms, and smart homes. However, turning raw sensor readings into actionable insights often requires custom scripts, dashboards, and manual configuration. This is where ASI Biont, an AI agent for device integration, changes the game.

ASI Biont connects to 1-Wire sensors through the Hardware Bridge mechanism: you run bridge.py on your local PC (Windows, Linux, or macOS), which communicates with the cloud-based AI via HTTP long polling. The AI then sends commands to read or write to the COM port (e.g., COM3) using the industrial_command tool. No dashboard panels, no 'add device' buttons—just a natural chat conversation where you describe your setup, and the AI writes the integration code on the fly.

This article provides a step-by-step guide to connecting 1-Wire sensors (DS18B20 temperature, humidity) to ASI Biont via COM port, with a real use case in greenhouse monitoring, Python code examples, wiring diagram, and automation scenarios.

Why 1-Wire and ASI Biont?

1-Wire sensors are widely used because they:
- Are inexpensive (DS18B20 costs under $2)
- Support daisy-chaining (up to 100+ sensors on one bus)
- Operate over distances up to 100 meters with proper termination
- Offer ±0.5°C accuracy for temperature readings

However, traditional integration requires:
1. A USB-to-1-Wire adapter (e.g., DS9490R) or a microcontroller like Arduino/ESP32
2. Writing Python code with pyserial to parse raw bytes
3. Building a web dashboard or cron jobs for logging and alerts

ASI Biont eliminates steps 2 and 3: the AI agent writes the Python code, executes it in a sandbox environment (via execute_python), and uses the Hardware Bridge to talk to the COM port. You only need to describe your hardware in the chat.

How ASI Biont Connects to 1-Wire Sensors

Connection Architecture

The data flow works as follows:

[DS18B20 Sensors] <--1-Wire bus--> [USB-to-1-Wire Adapter] <--USB--> [Your PC (bridge.py)] <--HTTP long polling--> [ASI Biont Cloud]
  • User's PC: Runs bridge.py with your ASI Biont token and COM port configuration.
  • ASI Biont Cloud: Hosts the AI agent and sandboxed Python execution environment.
  • Communication: The AI issues industrial_command with protocol serial://, command read, and parameters like port=COM3 and baud=9600. The bridge forwards this to the COM port and returns the response.

Step 1: Hardware Setup

  1. Connect DS18B20 sensors to a 1-Wire bus:
  2. Red wire → 3.3V or 5V (VDD)
  3. Black wire → GND
  4. Yellow wire → Data line (DQ) with a 4.7kΩ pull-up resistor to VDD
  5. Connect the bus to a USB-to-1-Wire adapter (e.g., DS9490R) or a USB-to-serial converter (e.g., FTDI) with a 1-Wire driver board.
  6. Plug the adapter into your PC (e.g., COM3 on Windows, /dev/ttyUSB0 on Linux).

Step 2: Install and Run bridge.py

Download bridge.py from the ASI Biont documentation page or your account dashboard. Run it with:

python bridge.py --token=YOUR_ASI_BIONT_TOKEN --ports=COM3 --default-baud=9600
  • --token: Required. Get it from your ASI Biont account settings.
  • --ports: Comma-separated list of COM ports to expose (e.g., COM3,COM5).
  • --default-baud: Baud rate for serial communication (9600 is standard for 1-Wire adapters).

The bridge will connect to ASI Biont via HTTP long polling and wait for commands.

Step 3: Describe Your Setup in the Chat

Open the ASI Biont chat interface and type something like:

"Connect to my 1-Wire temperature sensor on COM3 at 9600 baud. Read the temperature from all connected DS18B20 sensors every 30 seconds. If any sensor reads above 35°C, send me a Telegram alert. Also log all readings to a CSV file."

The AI agent will:
1. Generate a Python script using pyserial to communicate with the 1-Wire bus via the bridge.
2. Execute the script in the sandbox (via execute_python).
3. Use industrial_command with protocol='serial://' and command='read' to fetch sensor data.
4. Parse the raw 1-Wire protocol bytes to extract temperature values.
5. Set up a loop (with timeouts to respect the 30-second sandbox limit) for periodic reads.
6. Integrate with Telegram API (via aiohttp) for alerts.
7. Write data to a CSV file using csv module.

Concrete Use Case: Greenhouse Monitoring

Scenario

A greenhouse operator wants to monitor temperature and humidity across 10 zones using DS18B20 sensors and a humidity sensor (DHT22 with 1-Wire interface). The goals are:
- Read temperature every 5 minutes
- Alert via Telegram if temperature exceeds 30°C or drops below 10°C
- Log historical data for analysis

Code Example (Generated by ASI Biont)

Below is an example of the Python script the AI might generate and run in the sandbox. Note: this script uses execute_python with aiohttp for HTTP requests to the Telegram API and pyserial via the Hardware Bridge. The actual COM port access is abstracted by the AI using industrial_command.

import asyncio
import csv
from datetime import datetime
import aiohttp

# Configuration (provided by user or AI)
TELEGRAM_BOT_TOKEN = "your_bot_token"
TELEGRAM_CHAT_ID = "your_chat_id"
COM_PORT = "COM3"
BAUD_RATE = 9600

async def read_1wire_temp(port, baud):
    # AI uses industrial_command internally; this is a simplified version
    # The actual call is: industrial_command(protocol='serial://', command='read', port=port, baud=baud)
    # Returns a list of temperatures
    pass  # Real implementation handles 1-Wire ROM and scratchpad reading

async def send_telegram_alert(message):
    async with aiohttp.ClientSession() as session:
        url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
        payload = {"chat_id": TELEGRAM_CHAT_ID, "text": message}
        await session.post(url, json=payload)

async def log_to_csv(temp, humidity):
    with open("greenhouse_log.csv", "a", newline="") as f:
        writer = csv.writer(f)
        writer.writerow([datetime.now().isoformat(), temp, humidity])

async def main():
    # Read all sensors (up to 10 DS18B20 on the bus)
    temps = await read_1wire_temp(COM_PORT, BAUD_RATE)
    for sensor_id, temp in temps:
        print(f"Sensor {sensor_id}: {temp}°C")
        await log_to_csv(temp, None)  # humidity from separate sensor
        if temp > 30 or temp < 10:
            await send_telegram_alert(f"Alert! Sensor {sensor_id}: {temp}°C")

# Run once (loop handled by AI scheduling)
asyncio.run(main())

Note: The AI does not use while True because the sandbox has a 30-second timeout. Instead, it schedules periodic execution via a cron-like mechanism or by calling the script repeatedly.

Automation Scenarios Enabled

Scenario Trigger Action
Greenhouse overheat Temperature > 35°C Send Telegram alert, open vent (via relay on COM port)
Server room cooling failure Temperature > 40°C Alert on-call engineer, log to Google Sheets
Smart home freeze warning Temperature < 5°C Turn on heating via MQTT (ESP32)
Daily report Every 24h Generate summary with max/min/avg, email via SendGrid

Why This Beats Manual Integration

Traditional approach:
- Write Python code with pyserial and 1-Wire protocol parsing
- Set up a database (SQLite, PostgreSQL)
- Build a dashboard (Flask, Grafana)
- Configure alerting (SMS, email)
- Maintain and debug over time

With ASI Biont:
- No coding required: The AI writes and executes the integration from your description
- Zero infrastructure: The sandbox handles execution, logs, and alerts
- Instant deployment: Describe your hardware once, and the AI connects immediately
- Flexible: Change thresholds, add new sensors, or switch to a different alert channel by just chatting

How to Try This Integration

  1. Sign up at asibiont.com (free tier available)
  2. Get your API token from the account settings
  3. Connect your 1-Wire adapter to your PC
  4. Run bridge.py with your token and COM port
  5. In the chat, describe your sensor setup and automation needs

The AI will handle the rest. No need to wait for developer support—connect any device with a serial interface right now.

Conclusion

The combination of 1-Wire sensors and ASI Biont democratizes industrial-grade monitoring. Whether you're managing a greenhouse, a server room, or a smart home, the AI agent eliminates the complexity of writing and maintaining integration code. By simply describing your hardware and desired automation, you get a fully functional system in minutes. Start your journey today and see how AI can transform your device integration workflow.

Try it now: asibiont.com

← All posts

Comments