How to Integrate GPS/GLONASS Trackers with ASI Biont via NMEA and COM Port: A Practical Guide

Introduction

Modern logistics and fleet management rely on real-time location data. GPS/GLONASS trackers output NMEA 0183 sentences — a standard protocol that includes latitude, longitude, speed, heading, and satellite status. Traditionally, integrating such trackers into a monitoring system requires writing custom parsers, setting up data pipelines, and building alert logic. But what if you could skip all that and just describe your requirements in plain English?

ASI Biont is an AI agent that connects to virtually any hardware device — including GPS/GLONASS trackers — through a chat interface. Instead of writing an entire integration from scratch, you tell the AI what you need: “Read NMEA sentences from COM3 at 9600 baud, parse the $GPGGA and $GPRMC strings, and notify me when the vehicle enters a geofence.” The AI writes the Python code, runs it, and handles the communication in seconds.

This article is a step-by-step integration guide for using ASI Biont with a GPS/GLONASS tracker over a COM port via NMEA protocol. We will cover the connection method, wiring (if needed), real code examples, and automation scenarios.

Why Connect a GPS/GLONASS Tracker to an AI Agent?

A standalone GPS tracker broadcasts NMEA sentences, but raw data is useless without a system that can:
- Parse the strings into structured coordinates
- Store location history
- Trigger actions when a vehicle enters or leaves a zone
- Send SMS or Telegram alerts on unauthorized movement

ASI Biont acts as the intelligent middle layer. It reads the serial stream, parses standard NMEA sentences using the pynmea2 library, and can execute business logic — all through a conversational interface. No dashboard configuration, no YAML files, no DevOps.

How ASI Biont Connects to GPS Trackers

ASI Biont supports COM port access via the Hardware Bridge — a lightweight Python application (bridge.py) that runs on your local Windows/Linux/macOS machine. The bridge connects to ASI Biont’s cloud via HTTP long polling and provides a secure tunnel to local serial ports (RS-232, RS-485, USB-to-serial adapters).

Here’s the architecture:
- User PC: runs bridge.py, which opens COM3 (or /dev/ttyUSB0 on Linux) at the tracker’s baud rate.
- ASI Biont Cloud: AI agent receives user instructions, generates Python scripts, and sends commands via the industrial_command tool.
- Hardware Bridge: relays serial read/write requests between the cloud and the physical COM port.

The AI uses the serial:// protocol inside industrial_command() to interact with the bridge. For more complex parsing logic (like NMEA sentence handling), the AI writes a Python script that runs in the sandbox (via execute_python) and uses pynmea2 to decode sentences.

Step-by-Step Integration Example

Scenario: Real-Time Vehicle Tracking with Geofence Alerts

A logistics company wants to monitor a delivery truck. The truck has a GPS/GLONASS tracker (e.g., Teltonika FMB001, Queclink GL300, or any generic NMEA device) connected via a USB-to-serial adapter to a Windows laptop. The tracker outputs NMEA sentences at 9600 baud.

Goal:
- Continuously read $GPGGA and $GPRMC sentences
- Extract latitude, longitude, speed, and UTC time
- If the vehicle enters a predefined geofence (e.g., warehouse zone), send a Telegram notification

Step 1: Set Up Hardware Bridge

Download bridge.py from ASI Biont. Launch it with:

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

Flags:
- --token (required): your ASI Biont API token
- --ports: comma-separated list of COM ports to expose (e.g., COM3,COM4 or /dev/ttyUSB0)
- --default-baud: baud rate for all listed ports (9600, 115200, etc.)

The bridge will connect to ASI Biont and wait for commands. You’ll see a log: Bridge connected. Polling for commands...

Step 2: Connect the Tracker Physically

Most GPS/GLONASS trackers with NMEA output use a 4-pin UART (TX, RX, VCC, GND). For USB connection:
- Connect the tracker’s TX pin to the USB adapter’s RX pin
- Connect the tracker’s RX pin to the adapter’s TX pin (if bidirectional communication is needed)
- Provide 3.3V or 5V power (check tracker datasheet)
- Common GND

If your tracker has an RS-232 interface, use a USB-to-RS-232 converter (e.g., FTDI-based). The bridge will detect the virtual COM port.

Step 3: Describe the Task in ASI Biont Chat

Open the ASI Biont chat and type:

“Connect to GPS tracker on COM3 at 9600 baud. Read NMEA sentences, parse $GPGGA and $GPRMC. Continuously monitor coordinates. If the vehicle enters the geofence zone with center (48.8566, 2.3522) and radius 500 meters, send a Telegram alert to chat ID 123456789 using bot token 123:ABC.”

ASI Biont will:
1. Confirm the connection parameters
2. Write a Python script using pynmea2 for parsing, geopy for distance calculation, and requests for Telegram API
3. Use industrial_command(protocol='serial://', command='read', port='COM3') to fetch raw NMEA lines
4. Execute the script in the sandbox environment

Step 4: Code Example (Generated by AI)

Below is an example of the Python script that ASI Biont would generate and run. This script runs in the sandbox and communicates with the bridge via the serial:// protocol.

import asyncio
import pynmea2
from geopy.distance import geodesic
import requests

# Geofence center (Paris, France)
CENTER_LAT = 48.8566
CENTER_LON = 2.3522
RADIUS_METERS = 500

# Telegram config
TELEGRAM_BOT_TOKEN = "123:ABC"
TELEGRAM_CHAT_ID = "123456789"

# We will use industrial_command to read from COM port
# (In real execution, ASI Biont injects the command)

def parse_nmea(sentence):
    """Parse a single NMEA sentence using pynmea2."""
    try:
        msg = pynmea2.parse(sentence)
        if isinstance(msg, pynmea2.types.GGA):
            return {
                'type': 'GGA',
                'lat': msg.latitude,
                'lon': msg.longitude,
                'altitude': msg.altitude,
                'satellites': msg.num_sats
            }
        elif isinstance(msg, pynmea2.types.RMC):
            return {
                'type': 'RMC',
                'lat': msg.latitude,
                'lon': msg.longitude,
                'speed': msg.spd_over_grnd,
                'utc': msg.timestamp
            }
    except pynmea2.ParseError:
        return None
    return None

def check_geofence(lat, lon):
    """Return True if point is within radius from center."""
    point = (lat, lon)
    distance = geodesic(point, (CENTER_LAT, CENTER_LON)).meters
    return distance <= RADIUS_METERS

def send_telegram_alert(message):
    url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
    payload = {
        'chat_id': TELEGRAM_CHAT_ID,
        'text': message
    }
    requests.post(url, json=payload, timeout=5)

async def main():
    # In real execution, ASI Biont provides the raw line from the bridge
    # For demonstration, we simulate a few NMEA sentences
    test_sentences = [
        "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
        "$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A",
        "$GPGGA,123520,4851.396,N,00221.173,E,1,06,1.2,42.0,M,,*7F"  # near Paris
    ]

    for sentence in test_sentences:
        data = parse_nmea(sentence)
        if data and 'lat' in data:
            lat = data['lat']
            lon = data['lon']
            print(f"Parsed: {data['type']} - Lat: {lat}, Lon: {lon}")
            if check_geofence(lat, lon):
                send_telegram_alert(f"🚛 Vehicle entered geofence! Location: {lat}, {lon}")
                print("Alert sent.")
            else:
                print("Outside geofence.")
        await asyncio.sleep(1)

if __name__ == "__main__":
    asyncio.run(main())

Note: In a real integration, the AI would not use hardcoded test sentences. Instead, it would call industrial_command(protocol='serial://', command='read', port='COM3') repeatedly to fetch live NMEA lines from the bridge. The sandbox script would process each line as it arrives.

Step 5: Automation Scenarios

Once the GPS data is flowing, you can expand the automation:

Scenario AI Prompt Action
Speed alert “Notify me if speed exceeds 90 km/h” AI adds a speed check to the parsing script, sends Telegram
Fuel consumption monitoring “Combine GPS data with fuel sensor via Modbus” AI connects to a Modbus fuel level sensor, correlates location with fuel drops
Route optimization “Plot the last 100 coordinates on a map and suggest a faster route” AI uses matplotlib to plot points and networkx for shortest path
Driver behavior “Detect harsh braking from speed changes” AI analyzes consecutive speed readings, flags events

Why This Approach Beats Traditional Integration

  • No coding required from you: You describe the task in natural language. The AI generates, debugs, and runs the code.
  • Supports any NMEA device: Whether it’s a $20 generic tracker or a $500 Teltonika, as long as it outputs NMEA over serial, it works.
  • Instant geofencing: Add geofences by simply describing them in chat — no GIS software needed.
  • Extensible: Combine GPS data with other devices (temperature sensors, fuel sensors, cameras) in the same conversation.

Real-World Use Case: Last-Mile Delivery Monitoring

A small delivery company in Berlin used ASI Biont to monitor 5 vans. Each van had a USB GPS dongle plugged into a Raspberry Pi. The Pi ran bridge.py and exposed the GPS COM port. The company manager told ASI Biont:

“Watch all 5 GPS feeds. If any van stays within 100 meters of the depot after 10 AM, send me a Slack message.”

The AI agent connected to each Pi via SSH (using paramiko), read the NMEA streams, implemented the logic, and integrated Slack. The entire setup took 15 minutes — compared to days of custom scripting.

Conclusion

Integrating GPS/GLONASS trackers with an AI agent like ASI Biont transforms raw NMEA data into actionable intelligence — without writing a single line of traditional code. The Hardware Bridge provides secure COM port access, while the AI handles parsing, logic, and alerts.

Whether you manage a fleet of trucks, monitor agricultural vehicles, or track personal assets, ASI Biont lets you focus on the “what” (business logic) instead of the “how” (serial programming).

Ready to integrate your GPS tracker? Go to asibiont.com, describe your tracker and requirements in the chat, and let the AI do the integration in seconds.

← All posts

Comments