Integrating 1-Wire Sensors with AI Agent ASI Biont: A Step-by-Step Guide

Introduction

The 1-Wire protocol, developed by Dallas Semiconductor (now Maxim Integrated), is a low-speed serial communication standard that uses a single data line (plus ground) to connect multiple sensors and devices. Its simplicity and long cable runs (up to 100 meters) make it a favorite for temperature monitoring in smart homes, greenhouses, server rooms, and industrial environments. The most popular 1-Wire device is the DS18B20 digital temperature sensor, which provides ±0.5°C accuracy and a unique 64-bit serial number for each sensor on the bus.

Connecting a 1-Wire network to an AI agent like ASI Biont unlocks real-time data analysis, anomaly detection, and automated control — without writing a single line of integration code manually. Instead of building a custom dashboard or polling script, you simply describe your setup in a chat with the AI, and it generates the entire Python code using the appropriate protocol. This article shows you exactly how to integrate 1-Wire sensors (DS18B20, DS2413, or any 1-Wire device) with ASI Biont via a Hardware Bridge over a COM port.

Why Integrate 1-Wire with an AI Agent?

  • Real-time monitoring: AI can read temperature every 10 seconds, detect trends, and alert you via Telegram or email if a freezer fails or a greenhouse gets too hot.
  • Predictive maintenance: Analyze historical data to predict when a cooling system might fail.
  • Automated actions: Send commands to relays or actuators based on sensor readings.

Connection Method: Hardware Bridge (COM port)

ASI Biont connects to 1-Wire devices through a Hardware Bridge — a small Python application (bridge.py) that you run on your local PC (Windows, Linux, macOS). The bridge communicates with ASI Biont's cloud via HTTP long polling, and the AI sends commands through the industrial_command tool. The bridge then translates those commands into serial communication on your chosen COM port.

Why this method?
- 1-Wire adapters (e.g., DS9490R USB adapter, or a DIY adapter using a MAX31850) appear as a virtual COM port on your computer.
- The bridge gives the AI direct access to read and write to that COM port.
- No need for a Raspberry Pi or cloud server — just a PC with the adapter plugged in.

Hardware needed:
- 1-Wire to USB adapter (e.g., DS9490R, or a DIY FTDI-based adapter with a DS2480B).
- One or more DS18B20 sensors (or other 1-Wire devices).
- 4.7 kΩ pull-up resistor (required for the 1-Wire bus).
- Jumper wires and a breadboard.

Wiring Diagram

[1-Wire USB Adapter]  →  Data pin (yellow)  →  DS18B20 Data (middle pin)
                      →  VCC (red)           →  DS18B20 VDD (left pin)
                      →  GND (black)         →  DS18B20 GND (right pin)
                      →  4.7kΩ resistor between Data and VCC

For multiple sensors, connect all Data pins together, all VCC together, all GND together. Each sensor has a unique ID, so the bus distinguishes them.

Step-by-Step Integration with ASI Biont

1. Set up the Hardware Bridge

Download bridge.py from ASI Biont's documentation page. Run it with your token and specify the COM port:

python bridge.py --token=YOUR_API_TOKEN --ports=COM3 --default-baud=9600

Note: The bridge does NOT run an HTTP server locally — it connects to the cloud via long polling. All commands are sent through the AI chat.

2. Talk to the AI Agent

In the ASI Biont chat, describe your setup:

"Connect to 1-Wire adapter on COM3 at 9600 baud. I have three DS18B20 sensors. Read temperature from all sensors every 10 seconds, log them to a CSV file, and send me an alert if any sensor exceeds 30°C."

3. AI Generates the Code

The AI will write a Python script using pyserial (available in the sandbox) and execute it via execute_python. Here is an example of what the AI might generate:

import serial
import csv
import time
from datetime import datetime

# 1-Wire ROM commands
SKIP_ROM = b'\xCC'
CONVERT_T = b'\x44'
READ_SCRATCHPAD = b'\xBE'
SEND_COMMAND = b'\x55'  # Match ROM (not used here)

# Initialize serial
ser = serial.Serial('COM3', 9600, timeout=1)
time.sleep(2)  # let adapter initialize

def reset_bus():
    ser.write(b'\x01')  # 1-Wire reset command (depends on adapter)
    time.sleep(0.01)

def read_temp(rom_id_hex):
    # Convert hex string to bytes
    rom_id = bytes.fromhex(rom_id_hex)
    reset_bus()
    ser.write(SKIP_ROM)
    ser.write(CONVERT_T)
    time.sleep(0.75)  # wait for conversion
    reset_bus()
    ser.write(SKIP_ROM)
    ser.write(READ_SCRATCHPAD)
    data = ser.read(9)
    if len(data) < 9:
        return None
    temp_raw = data[0] | (data[1] << 8)
    return temp_raw / 16.0

# Known sensor ROMs (replace with yours)
sensors = ['28FF6A5B161603', '28FF1234567890', '28FFAABBCCDDEE']

while True:
    timestamp = datetime.now().isoformat()
    row = [timestamp]
    for rom in sensors:
        temp = read_temp(rom)
        row.append(temp)
        print(f"Sensor {rom}: {temp}°C")
        if temp and temp > 30:
            print(f"ALERT: Sensor {rom} exceeded 30°C!")
            # AI can send alert via Telegram (another script)
    # Append to CSV
    with open('temps.csv', 'a', newline='') as f:
        writer = csv.writer(f)
        writer.writerow(row)
    time.sleep(10)

Important: The sandbox has a 30-second timeout, so the AI will rewrite the loop using asynchronous scheduling or generate a script that runs on your local machine via the bridge. For continuous monitoring, the AI can generate a script that runs on your PC (not in the sandbox) and sends data to ASI Biont via MQTT.

4. AI Executes and Connects

The AI runs the script in the sandbox (if it's a one-shot read) or sends instructions to run the script locally. Once connected, you can ask questions like:

  • "What is the average temperature over the last hour?"
  • "Plot a temperature graph for sensor 28FF6A5B161603."
  • "If temperature drops below 5°C, turn on the heater (via another COM port relay)."

Real-World Scenario: Smart Greenhouse

A hobbyist has a greenhouse with 6 DS18B20 sensors placed at different heights and a 1-Wire relay board (DS2413) to control fans and heaters. They connect the 1-Wire USB adapter to a Windows laptop running the bridge.

In the chat, they say:

"Monitor all 6 sensors. If the average temperature is above 28°C, turn on fan relay (relay 1). If below 10°C, turn on heater (relay 2). Log all data to Google Sheets."

The AI generates:
- A script to read sensors and control relays via 1-Wire commands.
- A script to send data to Google Sheets via HTTP API.
- A script to send alerts via Telegram.

All without manual coding — the user just describes the logic.

Why This Matters

Traditionally, integrating 1-Wire sensors required:
1. Installing a library (e.g., owfs, DigiTemp, or w1-therm).
2. Writing polling scripts in Python or C.
3. Building a dashboard (Grafana, Node-RED).

With ASI Biont, you skip steps 2 and 3. The AI agent writes the integration code in seconds, handles error checking, and adapts to your specific hardware. You can change the logic by simply updating the chat description.

Conclusion

The combination of 1-Wire sensors and an AI agent like ASI Biont eliminates the programming barrier. Whether you're monitoring a server room, automating a greenhouse, or logging temperatures in a chemical lab, you can set up a complete monitoring and control system in minutes — just by describing your hardware and requirements in plain English.

Ready to try it? Go to asibiont.com, start a chat, and tell the AI: "Connect to my 1-Wire adapter on COM3 with three DS18B20 sensors." See how fast you get a working integration.

← All posts

Comments