LoRaWAN + ASI Biont: Remote IoT Monitoring and Control via AI Agent (No Backend Coding)

LoRa / LoRaWAN Meets AI: Why Bridge the Two?

LoRa (Long Range) and LoRaWAN are the backbone of low-power, wide-area IoT networks. Sensors in fields, warehouses, or remote assets send small packets over kilometers on a single battery. But turning raw LoRa data into actionable alerts — or sending commands back — usually requires a custom backend: a database, a rule engine, an API. That’s where ASI Biont comes in. Instead of writing a full-stack IoT platform, you describe your device and desired logic in plain English, and the AI agent writes and runs the integration code in seconds.

How ASI Biont Connects to LoRa Devices

ASI Biont supports several connection methods. For LoRa/LoRaWAN, the most practical are:

Method Use Case Key Library
MQTT LoRaWAN gateways that publish sensor data to a broker (e.g., The Things Network → MQTT) paho-mqtt
Hardware Bridge (COM port) Direct LoRa modules (e.g., E32-900T20D) connected to a PC via USB/serial pyserial via bridge.py
HTTP API LoRaWAN cloud platforms (Cumulocity, Actility) that expose REST endpoints aiohttp

In this guide, we focus on the MQTT path — the most common for LoRaWAN gateways. The AI agent subscribes to the broker, parses sensor payloads (usually base64-encoded), and publishes downlink commands. All via chat.

Real Use Case: Temperature/Humidity Monitoring from a Remote Field

Imagine a LoRa-enabled sensor (e.g., Dragino LHT65) deployed in an agricultural field, sending temperature and humidity every 10 minutes via The Things Network (TTN). You want ASI Biont to:
- Read the latest values
- Alert you via Telegram if temperature exceeds 35°C or humidity drops below 30%
- Send a downlink command to change the sensor’s reporting interval

Step 1: Describe the Setup in Chat

You tell ASI Biont:

"Connect to my LoRaWAN sensor via MQTT. The broker is eu1.cloud.thethings.network, port 1883, username your-app@ttn, password your-api-key. Subscribe to the topic v3/your-app@ttn/devices/eui-xxxxxxxx/devices/up. The payload is base64-encoded JSON with fields temperature_c and humidity_pct. Parse it, log it, and if temp > 35°C or humidity < 30%, send me a Telegram alert. Also, if I say 'set interval 30', publish a downlink message on v3/your-app@ttn/devices/eui-xxxxxxxx/down/push with {\"downlinks\":[{\"f_port\":1,\"payload_raw\":\"AB4=\",\"priority\":\"NORMAL\"}]}."

That’s it. No dashboard, no device registration forms.

Step 2: AI Writes and Runs the Integration Code

ASI Biont’s execute_python tool generates a Python script using paho-mqtt. Here’s a simplified version of what it produces (the full script runs in the sandbox environment on Railway):

import paho.mqtt.client as mqtt
import base64
import json
import os

BROKER = "eu1.cloud.thethings.network"
PORT = 1883
USERNAME = "your-app@ttn"
PASSWORD = "your-api-key"
TOPIC_UP = "v3/your-app@ttn/devices/eui-xxxxxxxx/devices/up"
TOPIC_DOWN = "v3/your-app@ttn/devices/eui-xxxxxxxx/down/push"

def on_message(client, userdata, msg):
    payload = json.loads(msg.payload)
    # Decode base64 payload (TTN format)
    raw = payload.get("uplink_message", {}).get("payload_raw", "")
    if raw:
        decoded = base64.b64decode(raw)
        # Assume first 2 bytes: temperature (signed int16), next 2 bytes: humidity (uint16)
        temp = int.from_bytes(decoded[0:2], 'big', signed=True) / 100.0
        hum = int.from_bytes(decoded[2:4], 'big') / 10.0
        print(f"Temperature: {temp}°C, Humidity: {hum}%")
        if temp > 35 or hum < 30:
            print("ALERT: Conditions out of range!")
            # Send Telegram notification (using requests)
            import requests
            requests.post(f"https://api.telegram.org/bot{os.environ['TELEGRAM_TOKEN']}/sendMessage",
                          json={"chat_id": os.environ['TELEGRAM_CHAT_ID'],
                                "text": f"Alert: Temp={temp}°C, Hum={hum}%"})

client = mqtt.Client()
client.username_pw_set(USERNAME, PASSWORD)
client.on_message = on_message
client.connect(BROKER, PORT, 60)
client.subscribe(TOPIC_UP)
client.loop_start()

# Keep connection open (sandbox timeout is 30s, but AI uses asyncio loop with proper timeout)
import time
time.sleep(25)

Note: The actual sandbox script uses asyncio and handles timeouts gracefully. The execute_python sandbox has a 30-second limit, so for persistent subscriptions, ASI Biont uses a long-running background task with periodic reconnection.

Step 3: Control via Chat

You can then chat with ASI Biont:

"What's the latest temperature?"

The AI reads the MQTT message buffer and replies.

"Set interval to 30 minutes."

The AI publishes a downlink payload (e.g., \x01\x1E for 30 min) to the downlink topic.

Why This Matters

  • No backend code: You don’t write Node-RED flows, Node.js servers, or Python Flask apps. The AI does it all.
  • Universal device support: Connect any LoRaWAN sensor — Dragino, Milesight, Seeed, Heltec — as long as it sends data via MQTT or serial.
  • Immediate automation: Combine LoRa data with Telegram alerts, Google Sheets logging, or even voice commands via Telegram bots.
  • Real-time and historical: The AI can store data in a DuckDB database (available in the sandbox) for trend analysis.

Pitfalls to Avoid

  1. Base64 decoding: TTN and ChirpStack encode payloads differently. Always check the uplink message format. Example: TTN uses uplink_message.payload_raw as base64; ChirpStack uses data as hex string.
  2. Downlink port: LoRa sensors have different fPort numbers. The Dragino LHT65 uses fPort 2 for downlink configuration.
  3. Sandbox timeout: Long-running MQTT subscriptions need careful timeout handling. ASI Biont’s execute_python runs for max 30 seconds, so for persistent monitoring, the AI uses a recurring task (e.g., every 30 seconds) that reconnects and processes new messages.
  4. Security: Store API keys and tokens in environment variables (the sandbox supports os.environ). Never hardcode secrets.

Try It Yourself

Go to asibiont.com and start a chat. Describe your LoRaWAN device — the broker, topic, and what you want to monitor. The AI agent will write the integration code and run it in seconds. No setup, no DevOps, just instant IoT intelligence.

Next steps:
- Read the official ASI Biont documentation for detailed protocol support.
- Join the community on GitHub to share your integration recipes.

Last updated: July 2026

← All posts

Comments