Raspberry Pi + TensorFlow Lite / ONNX Runtime: Edge AI Integration with ASI Biont Agent

Raspberry Pi + TensorFlow Lite / ONNX Runtime: Edge AI Integration with ASI Biont Agent

Introduction

Edge AI is transforming how we process data — moving inference from the cloud to local devices like Raspberry Pi. When you pair a Raspberry Pi running TensorFlow Lite or ONNX Runtime with an intelligent AI agent like ASI Biont, you unlock real-time, privacy-preserving automation without relying on constant cloud connectivity. Imagine a camera on your Raspberry Pi detecting anomalies on a production line, and the AI agent instantly triggering a Telegram alert or adjusting a PLC — all without human intervention.

According to Gartner's 2025 report on edge computing, over 65% of enterprises will deploy edge AI solutions by 2027, with single-board computers like Raspberry Pi being a primary platform due to their low cost and flexibility. This article provides a step-by-step guide to connecting your Raspberry Pi with TensorFlow Lite / ONNX Runtime to the ASI Biont AI agent, covering architecture, real code examples, and automation scenarios.

Why Connect Raspberry Pi + TensorFlow Lite / ONNX Runtime to an AI Agent?

A Raspberry Pi alone can run lightweight ML models — object detection (MobileNet, YOLO-Nano), audio classification, or anomaly detection — but it lacks a central brain to orchestrate actions across multiple devices, make high-level decisions, or integrate with external services (email, Slack, databases). ASI Biont fills this gap:

  • Centralized orchestration: One AI agent manages multiple Raspberry Pis, PLCs, sensors, and cloud APIs.
  • Context-aware decisions: The agent combines on-device inference results with historical data, weather APIs, or business rules.
  • Zero manual coding: You describe your integration in natural language, and ASI Biont writes the Python code using paramiko (SSH), paho-mqtt, or pymodbus.
  • No dashboard required: Everything happens through chat — no need to configure panels or add devices manually.

Connection Methods: How ASI Biont Talks to Your Raspberry Pi

ASI Biont supports multiple connection methods. For a Raspberry Pi, the most practical options are:

Method Protocol Use Case Raspberry Pi Requirement
SSH paramiko Run Python scripts, control GPIO, execute inference SSH enabled (default on Raspberry Pi OS)
MQTT paho-mqtt Lightweight messaging for sensor data or inference results Mosquitto broker or cloud broker
HTTP API aiohttp Read/write REST endpoints on the Pi Flask/FastAPI server on Pi
Modbus/TCP pymodbus Control industrial PLCs via Pi as gateway Modbus TCP server on network
Hardware Bridge bridge.py Direct COM port access for Arduino/UART devices USB-to-serial adapter on Pi

Recommended for most scenarios: SSH. It gives the AI agent full access to the Pi's filesystem, GPIO, and ability to run any Python script with TensorFlow Lite or ONNX Runtime.

Concrete Use Case: Computer Vision on Raspberry Pi with AI Analysis

Let's build a practical example: a Raspberry Pi 4 with a camera module running TensorFlow Lite for object detection. The ASI Biont agent connects via SSH, runs the inference script, receives detection results, and triggers actions.

Step 1: User Describes the Task in Chat

User writes:

"Connect to my Raspberry Pi at 192.168.1.100 via SSH (user: pi, password: raspberry). Run a TensorFlow Lite object detection script from /home/pi/tflite/detect.py on the camera feed. If a person is detected with confidence > 0.7, take a photo and save it to /home/pi/detections/. Then send me a Telegram message with the photo."

Step 2: AI Writes the Integration Code

ASI Biont's execute_python sandbox generates and executes the following script:

import paramiko
import json
import base64
from datetime import datetime

# SSH connection parameters
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect('192.168.1.100', username='pi', password='raspberry')

# Run the detection script on the Pi
stdin, stdout, stderr = ssh_client.exec_command('python3 /home/pi/tflite/detect.py --confidence 0.7')
output = stdout.read().decode()
error = stderr.read().decode()

if error:
    print(f"SSH Error: {error}")
else:
    # Parse JSON output from the script (assumes detect.py outputs JSON)
    result = json.loads(output)
    if result['detections']:
        photo_path = f"/home/pi/detections/person_{datetime.now().strftime('%Y%m%d_%H%M%S')}.jpg"
        # Script should have saved the photo; we just read it
        sftp = ssh_client.open_sftp()
        with sftp.open(photo_path, 'rb') as f:
            photo_bytes = f.read()
        sftp.close()

        # Send via Telegram (using requests library available in sandbox)
        import requests
        TELEGRAM_TOKEN = 'YOUR_BOT_TOKEN'
        CHAT_ID = 'YOUR_CHAT_ID'
        url = f'https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendPhoto'
        files = {'photo': ('detection.jpg', photo_bytes, 'image/jpeg')}
        data = {'chat_id': CHAT_ID, 'caption': f'Person detected at {datetime.now()}'}
        response = requests.post(url, files=files, data=data)
        print(f"Telegram alert sent: {response.status_code}")
    else:
        print("No detections above threshold.")

ssh_client.close()

Step 3: AI Executes and Returns Results

The AI runs this in the sandbox, connects to the Pi, triggers detection, and sends you the Telegram message — all in under 30 seconds (sandbox timeout).

Alternative: MQTT-Based Integration for Continuous Monitoring

If you prefer a persistent, event-driven architecture, use MQTT. The Raspberry Pi publishes detection results to a topic, and ASI Biont subscribes via industrial_command:

# On the Raspberry Pi (MicroPython or Python script)
import paho.mqtt.client as mqtt
import json

client = mqtt.Client()
client.connect('broker.hivemq.com', 1883, 60)

# After running inference:
payload = {
    'device': 'raspberry-cam-1',
    'detections': [{'label': 'person', 'confidence': 0.85}],
    'timestamp': '2026-07-08T10:30:00Z'
}
client.publish('factory/camera/detections', json.dumps(payload))

In ASI Biont chat, the user says:

"Subscribe to MQTT topic 'factory/camera/detections' on broker.hivemq.com. When a detection with label 'person' and confidence > 0.7 arrives, log it to a PostgreSQL database and send a Slack notification."

The AI then uses industrial_command(protocol='mqtt', command='subscribe', topic='factory/camera/detections', broker='broker.hivemq.com') and writes a handler script.

Automation Scenarios Possible with This Integration

Scenario Raspberry Pi Role AI Agent Action
Security patrol Camera detects intruders via TensorFlow Lite Save video clip, send alert to Telegram, lock doors via Modbus PLC
Predictive maintenance Microphone + ONNX Runtime detects abnormal motor sounds Log anomaly to InfluxDB, create ticket in Jira, schedule inspection
Smart agriculture Camera counts fruit ripeness Update greenhouse climate (HVAC via Modbus), send harvest report to email
Retail analytics Camera counts foot traffic Update dashboard (Grafana API), adjust staffing schedule

Why This Integration Is Revolutionary

Traditional IoT integrations require manual coding of each bridge, authentication, and error handling. With ASI Biont:

  • No SDK installation: The AI generates ready-to-run Python code using standard libraries (paramiko, paho-mqtt, pymodbus).
  • No waiting for feature updates: Support any device — just describe it in chat.
  • Natural language interface: "Turn on the red LED on GPIO 17 when temperature exceeds 30°C" becomes a working script in seconds.
  • Sandbox safety: All AI-generated code runs in a restricted environment with pre-approved libraries (requests, numpy, onnxruntime, etc.).

How to Get Started

  1. Go to asibiont.com and start a chat.
  2. Describe your Raspberry Pi setup: IP address, SSH credentials, and what you want to achieve.
  3. The AI will ask clarifying questions (e.g., path to your TensorFlow Lite model, detection threshold).
  4. Review and confirm the generated code — the AI executes it in the sandbox.
  5. See results in real-time: detections, logs, or actions.

Conclusion

Integrating Raspberry Pi with TensorFlow Lite / ONNX Runtime into ASI Biont transforms a single-board computer into a powerful edge AI node with a central intelligent orchestrator. Whether you're building a security system, predictive maintenance solution, or smart agriculture platform, the combination of on-device ML and AI-driven automation eliminates months of custom development.

Try it now: Describe your Raspberry Pi project in the chat at asibiont.com and let the AI agent connect, code, and control your devices in minutes.

← All posts

Comments