Connecting 1-Wire Sensors (DS18B20, iButton) to the ASI Biont AI Agent: Full Integration Guide via COM Port

Introduction: Why Connect 1-Wire Sensors to an AI Agent?

The 1-Wire protocol, invented by Dallas Semiconductor (now Maxim Integrated), is one of the simplest and most reliable serial communication standards for low-speed data acquisition. With just a single data line (plus ground), it enables you to connect dozens of sensors — temperature (DS18B20), humidity (DS2438), unique identifiers (DS2401), and even iButton keys — over distances up to 100 meters. Despite its simplicity, 1-Wire is widely used in home automation, industrial monitoring, cold chain logistics, and access control.

However, raw sensor data is just numbers. To make it actionable — trigger alerts, log trends, correlate with other systems, or send notifications — you need a brain. That’s where the ASI Biont AI agent comes in. Instead of writing complex firmware or configuring dashboards, you simply describe what you want in natural language. The AI agent automatically writes the integration code, connects to your 1-Wire bus via a COM port (using a USB-to-1-Wire adapter like the DS9490R), and starts reading sensors, processing data, and executing your logic.

This article is a hands-on guide: we’ll cover the hardware setup, the exact connection method (COM port via Hardware Bridge), a real-world use case with temperature logging and Telegram alerts, step-by-step Python code examples, and wiring diagrams. By the end, you’ll be able to connect any 1-Wire sensor to ASI Biont and automate tasks — all through a chat conversation, no manual coding required.

How ASI Biont Connects to 1-Wire Devices

ASI Biont does not have a pre-built 1-Wire driver. Instead, it uses a universal, flexible approach: the Hardware Bridge and the execute_python sandbox. Here’s how it works:

  1. Hardware Bridge (bridge.py) runs on your local PC (Windows, Linux, or macOS). It connects to ASI Biont’s cloud via a secure WebSocket — the only communication channel. The bridge gives the AI agent access to your computer’s COM ports (RS-232/RS-485, USB-serial adapters).
  2. The user describes the 1-Wire setup in the chat, e.g., "I have a DS9490R USB-to-1-Wire adapter on COM3 at 115200 baud. Read the temperature from a DS18B20 sensor every 5 minutes and send me a Telegram alert if it exceeds 30°C."
  3. The AI agent writes a Python script that uses the industrial_command tool with the serial:// protocol. The command serial_write_and_read(data=hex_string) sends a raw hex command to the COM port and returns the response. The bridge handles the low-level serial I/O (including Windows-specific overlapped I/O fixes like CancelIoEx, PurgeComm, and synchronous WriteFile).
  4. Alternatively, the AI can use the execute_python sandbox to run a script that communicates with the bridge (via WebSocket) or directly with the device if the bridge is not needed (e.g., if the 1-Wire adapter is on a remote Raspberry Pi accessed via SSH).

Why this approach? Because 1-Wire is a byte-level protocol — you send a command (like 0xCC for Skip ROM, 0x44 for Start Conversion) and read the response. The AI agent can be programmed to handle any 1-Wire device without waiting for a built-in driver.

Use Case: Cold Chain Temperature Monitoring with DS18B20

Imagine you run a small food business that stores perishable goods in a refrigerated room. You need to monitor the temperature every 10 minutes and get an instant Telegram notification if it rises above 5°C (spoilage risk). You have a DS18B20 sensor connected to a DS9490R USB adapter plugged into a Windows PC. The sensor’s 64-bit ROM ID is 0x28 0xAA 0xBB 0xCC 0xDD 0xEE 0x11 0x12.

Step 1: Hardware Setup

Component Description
DS18B20 temperature sensor 1-Wire digital thermometer, ±0.5°C accuracy, -55°C to +125°C range. Three pins: GND, DQ (data), VDD (3.0–5.5V).
DS9490R USB-to-1-Wire adapter Converts USB to 1-Wire protocol. No external power needed — it parasitically powers the sensor.
PC (Windows 11) Runs bridge.py. COM port appears as COM3 at 115200 baud (default for DS9490R).
Wiring Connect DS18B20: GND→GND, DQ→data pin (center of DS9490R RJ11), VDD→+5V. Use a 4.7kΩ pull-up resistor between DQ and VDD if not using parasitic mode.

Wiring diagram (text):

DS9490R RJ11 pinout (looking at plug):
Pin 1: GND
Pin 2: +5V
Pin 3: Data (1-Wire)
Pin 4: NC

DS18B20 (TO-92 package, flat side facing you):
Left: GND
Center: Data (DQ)
Right: VDD (+3 to +5.5V)

Connect:
DS9490R Pin 1  DS18B20 GND (left)
DS9490R Pin 3  DS18B20 DQ (center)
DS9490R Pin 2  DS18B20 VDD (right)
Add a 4.7 resistor between Pin 3 and Pin 2 (data to VDD).

Step 2: Configure the Hardware Bridge

  1. Go to the ASI Biont dashboard (https://asibiont.com/dashboard).
  2. Navigate to DevicesCreate API Key. Copy the generated token.
  3. Download bridge.py via the Download bridge button (not from GitHub).
  4. On your PC, install dependencies:
    bash pip install pyserial requests websockets
  5. Run the bridge with your token and specify the COM port:
    bash python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud=115200 --rate=10
    The bridge connects to ASI Biont’s cloud via WebSocket and starts listening for commands on COM3 at 115200 baud. The --rate=10 limits command execution to 10 per second.

Step 3: Describe the Task in Chat

Open the ASI Biont chat (web or Telegram) and type:

"I have a DS9490R adapter on COM3 at 115200 baud. The DS18B20 sensor has ROM ID 28AABBCCDDEE1112. Write a script that: reads the temperature every 10 minutes, logs it to a local CSV file, and sends a Telegram alert if it exceeds 5°C. Use my Telegram bot token 123456:ABC-DEF and chat ID 987654."

The AI agent will:
- Understand the 1-Wire protocol (it knows the ROM commands: 0xCC for Skip ROM, 0x44 for Convert T, 0xBE for Read Scratchpad).
- Use the industrial_command tool with protocol='serial' to send hex commands to the bridge.
- Generate a Python script that runs in the execute_python sandbox (or as a scheduled task).

Step 4: AI-Generated Code Example

Here’s what the AI agent actually writes inside the sandbox (simplified):

import serial
import time
import csv
import asyncio
from datetime import datetime
import requests

# Configuration
PORT = 'COM3'
BAUD = 115200
SENSOR_ROM = '28AABBCCDDEE1112'  # 64-bit ROM ID as hex
TELEGRAM_TOKEN = '123456:ABC-DEF'
CHAT_ID = '987654'
CSV_FILE = 'temperature_log.csv'
THRESHOLD = 5.0  # Celsius

# Initialize serial connection
ser = serial.Serial(PORT, BAUD, timeout=2)

def read_temperature():
    """Read temperature from DS18B20 using 1-Wire protocol."""
    # 1. Send reset pulse (0xF0) - actually we use 0xCC for Skip ROM for simplicity
    ser.write(b'\xCC')  # Skip ROM (since only one sensor)
    ser.write(b'\x44')  # Convert T command
    time.sleep(0.75)  # Wait for conversion (750ms max)

    # 2. Read scratchpad
    ser.write(b'\xCC')  # Skip ROM
    ser.write(b'\xBE')  # Read Scratchpad
    data = ser.read(9)  # Read 9 bytes (scratchpad + CRC)

    # 3. Parse temperature (bytes 0 and 1: LSB, MSB)
    if len(data) >= 2:
        temp_raw = data[0] | (data[1] << 8)
        if temp_raw & 0x8000:  # Negative temperature
            temp_raw = -((temp_raw ^ 0xFFFF) + 1)
        temperature = temp_raw / 16.0
        return temperature
    return None

async def send_telegram(message):
    url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
    payload = {'chat_id': CHAT_ID, 'text': message}
    try:
        requests.post(url, json=payload, timeout=5)
    except Exception as e:
        print(f"Telegram error: {e}")

def log_to_csv(temp):
    with open(CSV_FILE, 'a', newline='') as f:
        writer = csv.writer(f)
        writer.writerow([datetime.now().isoformat(), temp])

def main():
    try:
        while True:
            temp = read_temperature()
            if temp is not None:
                print(f"Temperature: {temp:.2f}°C")
                log_to_csv(temp)
                if temp > THRESHOLD:
                    asyncio.run(send_telegram(f"⚠️ Temperature exceeded {THRESHOLD}°C: {temp:.2f}°C!"))
            else:
                print("Failed to read sensor")
            time.sleep(600)  # Wait 10 minutes
    except KeyboardInterrupt:
        print("Stopped")
    finally:
        ser.close()

if __name__ == '__main__':
    main()

Important: This script runs inside the execute_python sandbox on the ASI Biont server. However, because the sandbox cannot directly access your local COM port, the AI agent actually uses a different approach: it schedules a task that runs the industrial_command tool via the bridge. The bridge sends the hex commands to COM3 and returns the readings. The above code is for illustration — the real implementation uses the bridge as a proxy.

Step 5: Real Execution

In practice, the AI agent does this:

  1. Checks connectivity by sending a HELP command via serial_write_and_read(data="48454c500a" ). The bridge sends HELP\n to COM3 and returns the device response (e.g., a list of supported commands).
  2. Configures a periodic task using the bridge’s rate limiter. It sends the conversion command 0xCC, 0x44, waits 750ms, then reads scratchpad 0xCC, 0xBE and parses the response.
  3. Logs and alerts using Telegram API (via requests inside the sandbox) and appends to a CSV file stored on the local PC (the sandbox can write to a mounted volume, or the bridge can write locally).

All you see in the chat is:

AI: ✅ Connection established with DS9490R on COM3. Starting temperature monitoring every 10 minutes...
AI: Temperature: 4.2°C (2026-07-16 14:30:00) - Normal.
AI: Temperature: 5.3°C (2026-07-16 14:40:00) ⚠️ Alert sent to Telegram!

Advanced Scenarios: iButton Access Control and Multiple Sensors

iButton Authentication (DS2401 / DS1990A)

iButton (a stainless steel key) contains a unique 64-bit ROM ID. You can use it for access control: when someone touches an iButton to a reader (e.g., DS9097U), the AI agent reads the ID and checks against an allowlist.

Chat prompt:

"I have a DS9097U iButton reader on COM4 at 9600 baud. When an iButton is touched, read its 64-bit ROM ID and compare with my list: 01XXXXXXXXXXXXXX (admin), 02XXXXXXXXXXXXXX (staff). If unknown, send a Telegram alert with the ID."

The AI agent sends the 0x33 (Read ROM) command and parses the 8-byte response:

ser.write(b'\x33')  # Read ROM
data = ser.read(8)  # Family code (1 byte) + serial (6 bytes) + CRC (1 byte)
if len(data) == 8:
    rom_id = data.hex().upper()
    print(f"iButton ID: {rom_id}")

Multiple DS18B20 Sensors on One Bus

1-Wire allows multiple sensors on a single data line. Each has a unique ROM ID. The AI agent can scan the bus using the 0xF0 (Search ROM) command, then address each sensor individually with 0x55 (Match ROM) followed by the 8-byte ROM ID.

Chat prompt:

"Scan all DS18B20 sensors on COM3, read their ROM IDs, then read temperature from each every 5 minutes. Log to separate CSV columns."

The AI implements the 1-Wire search algorithm (which is non-trivial) — but since the AI agent has been trained on the Maxim application note AN937, it can generate the correct code automatically.

Why This Is Revolutionary: No-Code, No-Wait Integration

Traditional IoT platforms require you to:
- Write custom firmware for each sensor
- Set up MQTT brokers or HTTP servers
- Build dashboards with drag-and-drop widgets
- Wait for official driver support

With ASI Biont, you just describe what you need. The AI agent:
- Understands the protocol (1-Wire, Modbus, MQTT, etc.)
- Writes the integration code in seconds
- Handles edge cases (CRC checks, timing, bus contention)
- Runs on your existing hardware (bridge.py is <500 lines)
- Integrates with any external service (Telegram, email, Slack, database)

No coding required from you. The AI does all the heavy lifting.

Conclusion

The combination of 1-Wire sensors and the ASI Biont AI agent is a powerful, low-cost solution for real-world monitoring and automation. Whether you’re tracking refrigerator temperatures, authenticating iButton keys, or building a multi-sensor environmental monitor, you can set it up in minutes — just plug in the adapter, run the bridge, and tell the AI what to do.

Ready to try it yourself? Go to asibiont.com, create an API key, download the bridge, and connect your 1-Wire sensors. Describe your use case in the chat — the AI agent will handle the rest. No dashboards, no coding, no waiting. Just results.

← All posts

Comments