Asset Tracking Meets AI: How to Connect GPS/BLE Trackers to ASI Biont via MQTT and REST API
Every logistics manager knows the sinking feeling: a high-value pallet left the warehouse, but the tracking platform shows a stale GPS position. Asset tracking is not about the tracker itself — it's about the intelligence that interprets the stream and triggers action. That's where ASI Biont comes in. This is a practical guide to connecting GPS/BLE trackers to ASI Biont's AI agent using MQTT, REST API, and Python — without writing a single line of integration code from scratch. Instead, you describe the task in natural language, and the AI handles the rest.
1. What Is Asset Tracking?
Asset tracking refers to monitoring physical assets — vehicles, containers, medical equipment, or even a fleet of laptops — using GPS trackers, BLE beacons, or RFID tags. Modern trackers publish telemetry to a cloud platform or local broker using lightweight protocols. The two most common approaches are:
- MQTT (Message Queuing Telemetry Transport): a pub/sub protocol designed for low-bandwidth IoT devices. A tracker publishes to a topic like
fleet/truck_42/location, and a subscriber receives the payload. - REST API: many trackers (e.g., Teltonika, Queclink) send data to a vendor cloud, which exposes a REST API for retrieval.
The raw telemetry is just a stream of coordinates and battery percentages. To make it useful, you need to filter, geofence, and forward alerts to a chat or ticketing system. That's exactly what an AI agent can do.
2. Why Connect an AI Agent to Your Tracker?
An AI agent like ASI Biont turns static rules into conversational, adaptive logic. Instead of configuring a dashboard with dozens of alarms, you say: "Notify me when truck #12 leaves the depot between 2 AM and 5 AM." The agent writes the geofencing logic, subscribes to the MQTT topic, and sends a Telegram message via the standard Telegram Bot API. Because the integration is code-first, you can also connect other systems — your ERP, a custom database, or a serverless function.
3. ASI Biont: A Chat-First Integration Platform
ASI Biont is not another IoT dashboard. You interact with it in a chat window — like talking to a senior engineer. It performs integration by generating and executing Python code. This is a powerful concept: any device that can be reached by Python can be integrated. No plugin marketplace, no vendor lock-in. If your tracker speaks MQTT, use paho-mqtt. If it exposes a REST API, use aiohttp. If it's a serial GPS module, use pyserial through the Hardware Bridge.
For example, you might type:
I have an MQTT broker at
192.168.1.50:1883, and my vehicles publish toteltonika/+/location. I need to detect when any vehicle leaves the Riga depot and alert me on Telegram.
The AI will ask clarifying questions — payload format, geofence radius, alert language — then generate a complete Python solution.
4. Supported Connection Protocols
| Protocol | Python Library | Typical Asset Tracking Use Case |
|---|---|---|
| MQTT | paho-mqtt |
GPS trackers, BLE beacons, IoT sensors |
| REST/WebSocket | aiohttp |
Cloud-platform trackers, HTTP webhooks |
| COM port (RS-232/485) | pyserial via bridge.py |
Serial NMEA devices |
| Modbus/TCP | pymodbus |
Industrial PLCs and RTUs |
| SSH | paramiko |
Remote Linux gateways |
| OPC-UA | opcua-asyncio |
Factory equipment |
| CAN bus | python-can |
Vehicles and machinery |
| gRPC | grpcio |
High-performance microservices |
| CoAP | aiocoap |
Constrained IoT nodes |
| Custom | execute_python |
Anything Python can reach |
The beauty: if none of these covers your tracker, ASI Biont's execute_python lets you write a custom handler on the fly.
5. Choosing the Right Connection Method
For asset tracking, the key question is: where does your tracker publish data?
- If it's a cellular GPS tracker (e.g., Teltonika FMB920) that sends data to a local broker or a cloud broker with MQTT support, use MQTT.
- If it sends data to a vendor cloud and you pull via API, use REST.
- If it's a GPS module on a Raspberry Pi over serial, use the Hardware Bridge (download
bridge.pyfrom the ASI Biont dashboard and run it on the Pi).
This article focuses on MQTT and REST, as they cover the majority of commercial trackers.
6. Hardware We'll Use in Examples
We'll use two common setups:
- Teltonika FMB920 — a cellular GPS tracker that can be configured to publish JSON payloads to a local MQTT broker.
- BlueMaestro BLE beacon — broadcasting its MAC address and RSSI for indoor inventory tracking (detected by a Raspberry Pi running a scanner).
These are representative. Any tracker that can output JSON over MQTT or expose a REST API will work the same way.
7. Prerequisites
Before starting, make sure you have:
- An ASI Biont account (from asibiont.com).
- A network-reachable MQTT broker (for example, Mosquitto or EMQX).
- A tracker that publishes to a topic, or a cloud API key.
- Optional: a Raspberry Pi for BLE scanning.
8. Step 1: Describe Your Tracker in Chat
Open ASI Biont's chat and type:
I have a Teltonika FMB920 publishing JSON to MQTT broker at
192.168.1.50:1883with topicteltonika/+/location. The payload looks like{"lat": 56.95, "lon": 24.1, "ignition": true}. Subscribe to all locations, and if a vehicle leaves the Riga depot geofence (radius 500m), send a Telegram notification.
The agent will acknowledge, ask for your Telegram token and chat ID, then generate the integration. You never touch a YAML config or a management panel.
9. Step 2: AI-Generated MQTT Subscriber
Here's an example of the Python code ASI Biont might generate. It uses paho-mqtt, a standard client, and math.radians for haversine distance.
import paho.mqtt.client as mqtt
import json, math, requests
DEPOT = (56.9489, 24.1064) # Riga depot
RADIUS_KM = 0.5
def haversine(lat1, lon1, lat2, lon2):
R = 6371.0
phi1, phi2 = math.radians(lat1), math.radians(lat2)
dphi = math.radians(lat2 - lat1)
dlam = math.radians(lon2 - lon1)
a = math.sin(dphi/2)**2 + math.cos(phi1)*math.cos(phi2)*math.sin(dlam/2)**2
return R * 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
def on_message(client, userdata, msg):
payload = json.loads(msg.payload)
dist = haversine(payload['lat'], payload['lon'], DEPOT[0], DEPOT[1])
if dist > RADIUS_KM:
# Send Telegram alert via Bot API
requests.post(
'https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage',
json={'chat_id': '<CHAT_ID>', 'text': f'Truck {msg.topic} left depot! Dist={dist:.2f}km'}
)
client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.50', 1883)
client.subscribe('teltonika/+/location')
client.loop_forever()
Notice the code sends a Telegram alert using requests.post to the official Bot API — no proprietary messaging SDK. This script can run on a VPS or on the local gateway, depending on your deployment preference.
10. Step 3: Geofencing Logic with Hysteresis
The same script can maintain an in-memory state to avoid alert spam. Instead of alerting on every message, only alert when the vehicle transitions from inside to outside the geofence. ASI Biont understands this and adds a set for tracked vehicles:
vehicle_status = {} # vehicle_id -> is_outside
def on_message(client, userdata, msg):
payload = json.loads(msg.payload)
vehicle = msg.topic.split('/')[1] # e.g., truck_42
dist = haversine(payload['lat'], payload['lon'], DEPOT[0], DEPOT[1])
outside = dist > RADIUS_KM
if outside and not vehicle_status.get(vehicle, False):
# send alert once
requests.post('https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage',
json={'chat_id': '<CHAT_ID>', 'text': f'{vehicle} left depot'})
vehicle_status[vehicle] = outside
This is the kind of domain logic that usually takes hours to write and test. Here it appears in the AI's response in seconds.
11. Step 4: REST API Fallback for Cloud-Based Trackers
Many trackers don't expose MQTT at all. They push data to a vendor cloud, and you retrieve it via REST. For example, a Queclink device might use a proprietary platform. ASI Biont can generate a polling script using aiohttp and run it periodically. Below is a simplified version:
import aiohttp, asyncio
async def fetch_location(session, device_id):
url = f'https://api.trackercloud.example/v2/devices/{device_id}?fields=lat,lon,battery'
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
async with session.get(url, headers=headers) as resp:
return await resp.json()
async def main():
async with aiohttp.ClientSession() as session:
while True:
for dev in ['dev123', 'dev456']:
loc = await fetch_location(session, dev)
print(dev, loc)
# ... process and alert ...
await asyncio.sleep(60) # poll each minute
asyncio.run(main())
Note: while True loops are safe in ASI Biont's sandbox because each execution has a 30-second timeout. For production, the agent will suggest wrapping this in a cron job or a systemd service.
12. Step 5: BLE Beacons for Indoor Inventory
BLE asset tracking is ideal for warehouses where GPS is unavailable. A Raspberry Pi scans for beacons and publishes their MAC addresses to an MQTT topic. ASI Biont can subscribe and perform inventory counts. Here's an example of the subscriber logic:
import paho.mqtt.client as mqtt
import json
inventory = {}
def on_message(client, userdata, msg):
# msg.payload = b'{"mac": "AA:BB:CC:DD:EE:FF", "rssi": -55}'
data = json.loads(msg.payload)
if data['rssi'] > -60: # within ~3 meters
inventory[data['mac']] = True
else:
inventory.pop(data['mac'], None)
print(f'Current assets: {len(inventory)}')
client = mqtt.Client()
client.on_message = on_message
client.connect('localhost', 1883)
client.subscribe('ble/beacons')
client.loop_forever()
This approach turns a noisy RSSI signal into an actionable asset count. The AI can even add a retention timer: if a beacon hasn't been seen for 60 seconds, remove it from inventory.
13. Real-World Impact: What Metrics Improve
Logistics companies that combine asset tracking with AI-driven alerts typically see improvements in several measurable areas:
- Lost asset recovery time: from days to minutes, because the AI instantly notifies the right channel.
- Geofencing false alarms: reduced by implementing hysteresis and state-based transitions like the example above.
- Inventory count accuracy: BLE + AI can provide a near-real-time accurate count, compared to occasional manual sweeps.
While figures vary, studies by the IoT Analytics market research firm consistently rank asset tracking among the top IoT use cases for ROI. For a fleet of 100 vehicles, even a 0.5% reduction in lost assets can justify the integration cost.
14. E-E-A-T: Sources and Technical References
To validate the approaches above, refer to these primary sources:
- MQTT 3.1.1 specification: OASIS
paho-mqttclient documentation: Eclipse PahoaiohttpHTTP client docs: aiohttp.readthedocs.io- Teltonika GPS tracker configuration guides: Teltonika Wiki
- Raspberry Pi BLE scanning examples: bluepy GitHub
These are vendor-neutral, primary sources — the same ones a senior engineer would consult.
15. Why ASI Biont Accelerates Integration
Traditional integration means: read the SDK, authenticate, debug the connection, write business logic, set up alerts. It can take a day. With ASI Biont, you tell the AI what you want, and it writes the code — often in under a minute. Because it supports execute_python, the integration surface is limited only by Python's own ecosystem. paho-mqtt, aiohttp, pymodbus, paramiko — all are available. You can connect a specialized underwater acoustic GPS if you have a Python SDK.
The chat-driven workflow eliminates the learning curve. For example, to connect a serial NMEA GPS receiver, you would:
- Download
bridge.pyfrom your ASI Biont dashboard. - Launch it on the PC/Pi with the serial port:
python bridge.py --token=XXX --ports=COM3 --baud 115200 --rate=10. - Tell ASI Biont: "Read NMEA data from the bridge."
No need to look up an API reference. The agent knows how to parse NMEA sentences like $GPGGA and can extract latitude, longitude, and altitude.
16. Limitations and Best Practices
- Network security: When using MQTT, always use TLS and strong passwords. The AI can generate code with
sslcontext. - Sandbox constraints: Long-running subscribers have a 30-second timeout in
execute_python. For production, ask ASI Biont to export the script and run it on a VPS or a device. - Data validation: The AI's code is based on the payload format you describe. Test with sample payloads to avoid surprises.
- Power management: BLE beacons have limited battery life; your code should handle missed beacons gracefully.
By the way, none of these limitations require custom features — they are standard engineering considerations.
Try It Yourself
The best way to understand the integration is to run it. Open a chat at asibiont.com, give your tracker's MQTT topic or REST API credentials, and ask for a geofence alert. The AI will respond with a working Python script — no dashboard buttons, no plugin store. If it doesn't support your odd tracker out of the box, execute_python will still find a way.
Comments