CNC Machines (GRBL, Marlin) + ASI Biont: How to Control Your Mill and 3D Printer via Chat with AI

Introduction

If you run a CNC router with GRBL or a 3D printer with Marlin, you know the drill: manual G-code uploads, repetitive tasks, and no way to monitor or control the machine remotely. But what if you could just chat with an AI agent and tell it to "home all axes, then start the engraving job" or "check the nozzle temperature and alert me if it drops below 200°C"? That's exactly what ASI Biont does. In this guide, I'll show you how to connect your GRBL or Marlin-powered machine to ASI Biont via a COM port, automate operations, and even get Telegram alerts when something goes wrong. No coding required from your side — the AI writes all the integration code for you.

Why Connect a CNC Machine to an AI Agent?

Modern CNC controllers like GRBL (on Arduino Uno) and Marlin (on RAMPS boards) are essentially serial devices that listen for G-code commands over a COM port. By bridging this COM port to ASI Biont's AI agent, you can:

  • Send G-code directly from a chat interface (Telegram, Web, API).
  • Automate repetitive tasks: run a job every weekday at 9 AM.
  • Monitor machine status: read temperature, position, or error codes.
  • Get alerts: if the spindle current spikes or the bed temperature drifts.

How ASI Biont Connects to Your CNC Machine

ASI Biont supports COM port access through Hardware Bridge – a lightweight Python script (bridge.py) that runs on your PC (Windows/Linux/macOS). The bridge connects to ASI Biont's cloud via WebSocket (the only communication channel). When you tell the AI to send a command, it uses the industrial_command tool with serial_write_and_read(data=hex_string). The bridge writes the bytes to the COM port and immediately reads the response. For example, to home all axes on GRBL, you'd send G28 — the bridge converts it to hex: 4732380a (because G28\n).

Important: The bridge does not expose an HTTP API. All commands go through the WebSocket tunnel. You never write code to access the bridge directly — the AI does it for you.

Real-World Use Case: GRBL + ASI Biont + Telegram Alerts

Let's say you have a CNC engraver running GRBL on an Arduino Nano connected to COM3 at 115200 baud. You want to:
1. Start a job when you send a Telegram message.
2. Monitor the temperature of the spindle (via a virtual sensor).
3. Get an alert if the temperature exceeds 60°C.

Step 1: Set Up Hardware Bridge

Download bridge.py from the ASI Biont dashboard (Devices → Create API Key → Download bridge). Install dependencies:

pip install pyserial requests websockets

Run the bridge:

python bridge.py --token=YOUR_API_KEY --ports=COM3 --baud 115200 --rate=10

Step 2: Tell the AI What to Do

In the ASI Biont chat, you describe the setup:

"Connect to my GRBL CNC on COM3 at 115200 baud. When I say 'start job', send G-code to home axes, then move to X0 Y0 and start spindle. Also read a temperature sensor on analog pin A0 every 30 seconds and alert me on Telegram if it exceeds 60°C."

The AI generates the integration code and runs it. Here's what happens under the hood:

  1. The AI uses serial_write_and_read to send $X (unlock) and G28 (home).
  2. It creates a Telegram bot listener via python-telegram-bot (or uses a webhook).
  3. It polls the temperature by reading M105 (if Marlin) or a custom sensor via serial.
  4. If temperature > 60°C, it sends a Telegram message.

Example G-Code Sequence the AI Might Send

Command Meaning
$X Unlock steppers
G90 Absolute positioning
G28 Home all axes
G0 X10 Y10 Move to safe position
M3 S1000 Start spindle at 1000 RPM
G1 X100 F500 Linear feed

Marlin 3D Printer: Nozzle Temperature Monitoring

If you have a Marlin-based 3D printer (e.g., Ender 3 with SKR Mini E3), the process is identical. Connect via COM port (e.g., COM5 at 250000 baud). The AI can send:

  • M104 S210 — set nozzle temp to 210°C
  • M140 S60 — set bed temp to 60°C
  • M105 — read current temperatures

Example script the AI might write (runs in sandbox):

import pyserial
import time

# This code runs in execute_python, NOT directly on your PC.
# The actual serial communication goes through the bridge.
# Here we just simulate the logic.

def check_temp():
    # AI uses industrial_command to get temp from bridge
    response = industrial_command(
        protocol='serial://',
        command='serial_write_and_read',
        data='4d3130350a'  # M105\n
    )
    # Parse response: "ok T:210.0 /210.0 B:60.0 /60.0"
    temp = float(response.split('T:')[1].split()[0])
    if temp > 250:
        send_telegram_alert("Nozzle overheating!")

Automation Without Coding: AI Integration Builder

You don't need to write a single line of Python. The AI Integration Builder (available in the ASI Biont dashboard) lets you create triggers visually:

  1. Trigger: "Every 5 minutes, read M105 from Marlin"
  2. Condition: "If nozzle temp > 240°C"
  3. Action: "Send Telegram alert + execute M104 S0 (turn off heater)"

All this is configured via chat — you describe the logic in plain English, and the AI builds the integration.

Pitfalls to Avoid

  • Wrong baud rate: GRBL defaults to 115200, Marlin to 250000 (or 115200). Double-check your firmware settings.
  • Hex encoding: The bridge expects hex strings. G28\n becomes 4732380a. The AI handles this, but if you manually send data, use the correct format.
  • Windows overlapped I/O: On Windows, if pyserial fails to write (returns 0 bytes), the bridge automatically falls back to CancelIoEx + PurgeComm + synchronous WriteFile. This is built-in — you don't need to worry.
  • Sandbox timeout: Python scripts in execute_python have a 30-second timeout. Don't write infinite loops — use the bridge's polling mechanism instead.

Why This Beats Traditional Firmware UIs

  • No manual G-code entry: Just tell the AI "start the job" and it sends the sequence.
  • Remote monitoring: Access your CNC from anywhere via Telegram.
  • AI-powered diagnostics: The AI can analyze error codes (e.g., "ALARM:2" in GRBL) and suggest fixes.
  • Zero coding: You describe the task, the AI writes the integration code in seconds.

Conclusion

Connecting your GRBL or Marlin CNC machine to ASI Biont transforms it from a manual tool into a smart, remotely controllable asset. Whether you're running a one-off engraving or a production batch, the AI agent handles the G-code, monitors sensors, and alerts you when something needs attention. No dashboards, no buttons — just chat.

Ready to automate your CNC? Go to asibiont.com, grab your API key, download bridge.py, and start controlling your machine via chat. Your AI agent is waiting.

← All posts

Comments