GRBL ASI Biont Integration: How to Connect a CNC Machine to an AI Agent and Automate G-Code Production

The CNC router on your desk is a precision instrument, but it is also blind, deaf, and mute. It waits obediently for a G-code file, executes it, and stops. In 2026, this is no longer enough. With ASI Biont, a CNC machine becomes a full participant in the production workflow: it receives commands from the chat, generates G-code by itself, reports errors, and asks for confirmation when something goes wrong.

This guide is a practical blueprint for integrating GRBL- and Marlin-based machines with ASI Biont. You will learn how to connect the machine via COM port, MQTT or HTTP API, how to generate G-code from a simple text command, how to catch alarms and send notifications to Telegram and Slack, and which automation scenarios make sense for small production and freelancers.

Why Connect a CNC Machine to an AI Agent

A typical small workshop workflow looks like this: the client sends a drawing and a DXF file, the operator opens CAM software, manually selects contour, depth and strategy, generates G-code, transfers it via SD card or USB, runs the machine, and manually watches for errors. Every step is routine, error-prone, and tied to the operator's presence.

After integration with ASI Biont, the same process collapses into one dialogue:

User: "Make a 50x50 mm square pocket, 2 mm deep, from the top-left corner of the plate."
ASI Biont: "G-code is generated, the program fits into the working area, send to the machine?"

The operator approves once, and the machine works further according to the scenario — with notifications to a smartphone instead of constant observation.

System Architecture: How It Works

The integration is based on a simple principle: ASI Biont acts as the brain, turning the user's intent into machine commands. The technical chain looks like this:

[User: Telegram / Slack / Web interface]
                 ↓
          [ASI Biont AI Agent]
          (intent parsing, G-code
           generation, validation)
                 ↓
        [CNC Bridge / Gateway]
        (Python, Node-RED or ESP32)
                 ↓  serial: 115200 8N1
        [GRBL / Marlin controller]
                 ↓  step/dir
        [Stepper drivers, spindle, limit switches]

The bridge is the key component. It translates commands from ASI Biont into the serial protocol and returns machine status to the agent. It can run on a Raspberry Pi, a PC next to the machine, or a microcontroller.

GRBL vs Marlin: Choosing the Firmware

Almost all hobby and semi-professional machines run on one of these two firmware families. They both speak G-code but differ in details relevant to AI integration:

Criterion GRBL (1.1 / 2.0) Marlin (RAMPS, SKR)
Hardware Arduino Uno/Nano, 32-bit boards 8/32-bit boards, RAMPS, SKR
Typical machines CNC-3018, laser engravers, small mills 3D printers with CNC mode, custom machines
Serial protocol Line-by-line, "ok" / "error" response Longer polling, M114/M119 queries
Status reporting ? — real-time position and state M114 position, M119 endstops
G-code dialect Tight, fast, blocks up to 132 chars Extended, many M-codes, autoleveling
Best for AI integration Recommended: predictable protocol If the machine already runs Marlin

For the first integration, GRBL is the best choice: its serial protocol is extremely simple and every command receives an explicit "ok" or "error" response. This makes the connection to an AI agent almost trivial.

Connection Methods: Serial, MQTT, HTTP

Choose the physical channel according to what is already installed near the machine:

Method When to use Pros Cons
Serial (USB COM) Machine next to PC / Raspberry Pi Minimal latency, no network Usually one client at a time
MQTT (Wi-Fi / Ethernet) Remote launch, fleet of machines Async, multiple subscribers, queues Need an MQTT broker
HTTP API (OctoPrint / FluidNC) Marlin machines with OctoPrint Ready web interface, filesystem Heavy, more dependencies
WebSocket bridge Interactive ASI Biont dashboard Real-time status push Need to implement the bridge

In practice, the combination "serial + MQTT" covers 90% of cases: the CNC connects to a local gateway via USB, and the gateway exchanges structured messages with ASI Biont via MQTT or WebSocket.

Step-by-Step: GRBL Serial Connection

  1. Connect the CNC controller to the computer via USB and install the drivers (CH340 or CP2102).
  2. Determine the port name: on Linux it is /dev/ttyUSB0, on Windows COM3.
  3. Open a serial terminal (Candle or PuTTY), set 115200 8N1, send $$ — you must see a list of GRBL settings.
  4. Save the settings: $10=1 for expanded status reports, $5=1 to enable limit switches if they are installed.
  5. If the machine is in ALARM state, send $X to unlock it before starting.

A minimal Python test of the connection:

import serial
ser = serial.Serial("/dev/ttyUSB0", 115200, timeout=2)
ser.write(b"\r\n\r\n")  # wake up GRBL
while True:
    line = ser.readline().decode().strip()
    if line in ("ok", "error"):
        break
print("GRBL is ready!")

Now replace the terminal with ASI Biont: the agent only needs the ability to write to this port and read the responses.

G-Code Generation via Chat: A Practical Example

Create a project in ASI Biont named "cnc-workshop" and connect it to the serial gateway. Then send a text command in Telegram:

User: "Engrave the text 'ASIB' on a 100x80 mm acrylic plate, depth 1 mm, origin in the center, V-bit 0.5 mm."

ASI Biont processes the request:

  1. Extracts the parameters: material, depth, size, cutter, origin.
  2. Checks the contour and machine boundaries via the digital twin of the machine.
  3. Generates G-code using a CAM-capable model — this is the key difference from a regular chatbot: ASI Biont has templates, constraints and validation rules for CNC tasks.
  4. Shows the preview and asks for confirmation.

The resulting G-code may look like this:

; ASIB engraving
G21 G90 G94
G17
M03 S12000
G00 X0 Y0 Z5
G00 X-42 Y0
G01 Z-1.0 F200
G01 X42 Y0 F400
G00 Z5
M05
M30

The user approves, and the agent sends the program line by line to GRBL, reading "ok" after each block. An important detail: ASI Biont sends G-code through a validator plugin — if the coordinates exceed the machine working area, the agent pauses and asks for clarification instead of launching a dangerous program.

Code Example: A Command Sender Bridge

The bridge between ASI Biont and GRBL is a small Python script. It subscribes to an MQTT topic, receives G-code blocks, and writes them to the serial port:

import serial, time

def send_block(ser, block):
    ser.write((block + "\n").encode())
    while True:
        resp = ser.readline().decode().strip()
        if resp == "ok":
            return True
        if resp.startswith("error"):
            raise RuntimeError(resp)

ser = serial.Serial("/dev/ttyUSB0", 115200, timeout=2)
time.sleep(2)
for block in gcode_lines:  # from ASI Biont
    send_block(ser, block)
print("Job finished")

This layer gives full control: you can pause (!), resume (~), perform a soft reset (0x18), keep a job history, and send status to Telegram if the machine stops unexpectedly.

Where Does the AI Run: Edge or Cloud

The AI inside ASI Biont is cloud-based, so it can leverage large language models for complex dialogue, drawing interpretation and toolpath logic. Part of the computation can be shifted to the edge — to the gateway:

Task Cloud (ASI Biont) Edge (Raspberry Pi / ESP32)
Intent parsing from natural language Yes Small distilled SLM possible
G-code generation Yes, large context Not practical on ESP32
G-code validation Geometry checks by plugin Coordinate and feed checks
Status monitoring and alarms Receives ? responses Local watchdog

On an ESP32-class device the edge handles purely hardware functions; on a Raspberry Pi you can already run small models like TinyLlama or Qwen2-0.5B for basic parameter extraction. The recommended scheme is hybrid: the cloud makes decisions, the edge guarantees safety and continuity.

Automation Scenarios for Small Production

With ASI Biont, one freelancer or a small workshop can handle routine that would previously require several full-time operators.

Scenario Without AI With ASI Biont
Engraving orders from Etsy/Instagram Manual conversion of each text into G-code Client message → automatic "plate 100x80, text…" → G-code → run
Batch cutting of parts Operator stands next to the machine all day Agent starts the next file automatically, notifies when the batch is done
Night operation Inconvenient and unsafe Alarms, limits, spindle stop → Telegram/Slack + machine halt
Multi-machine workshop Operator switches between machines One agent manages a fleet via MQTT topics
Regular clients with complex orders Email, files, endless clarification Chat history stored in the project with a digital twin

An example of an automated batch: the agent receives a CSV file with client order parameters, generates ten G-code programs, puts them into a queue, and after each job checks the ? response to verify that the machine returned to zero.

Error Monitoring and Notifications

The serial protocol gives you real-time error visibility:

  • GRBL sends ALARM:1..9 — hard limits triggered, or a soft limit error.
  • error:22 or error:8 in response to a block — G-code syntax error.
  • Silence without "ok" — controller freeze or disconnected USB.

The bridge listens for these events and sends a structured message to ASI Biont, which then delivers a notification to Telegram/Slack:

{"machine": "cnc-3018", "event": "ALARM",
 "code": 1, "msg": "Hard limit hit",
 "pos": [12.5, 0, -1.0],
 "suggested_action": "unlock with $X"}

ASI Biont can also act proactively: for example, if the spindle speed drops below the threshold after an M3 command, the agent stops the job and asks for permission to restart with a different feed rate.

Safety and Security Rules

Automation is convenient, but a machine without an operator is still a machine. Before production use:

  1. Add a validator to the agent: working area bounds, maximum feed rate, allowed tool numbers.
  2. Use human-in-the-loop for the first run: the agent always requests confirmation before starting a new program.
  3. Emergency stop must be implemented in hardware, not only in the agent — a physical E-STOP in the power circuit.
  4. Limit the agent's rights: it may pause the machine but must not disable limit switches.
  5. Keep a journal: every generated G-code block is logged in the project with a timestamp.

A dangerous program generated by an LLM is no worse than a typo in a hand-written one — but automatic checks reduce the risk of a ruined workpiece by an order of magnitude.

Limitations of AI Control

Honesty forces us to list the constraints. ASI Biont will not replace CAM for complex 5-axis machining, trochoidal milling, or high-speed strategies with special kinematics. The G-code generator is strong at flat 2.5D tasks: engraving, contouring, drilling, simple pockets, and label cutting. For fully free-form 3D toolpaths use Fusion 360 or similar, and let the agent manage the files and the machine itself.

Another limitation is latency for very long programs: streaming ten thousand lines of G-code over the network requires a stable connection. If the network is unreliable, place the G-code file on the gateway and let ASI Biont execute a "start file" command instead of transferring the entire text.

Conclusion

Integrating a CNC machine with ASI Biont is not about a "chatbot that prints G-code" — it is a full automation layer for production: parsing orders from chat, generating and validating programs, batch execution, and alarm handling via Telegram/Slack. It takes one evening to connect a GRBL machine, and the benefit multiplies with every subsequent order.

Start small: take your CNC-3018, connect it via USB, run the serial test from this article, create a project in ASI Biont, and ask the agent to engrave something simple — a test marker or a plate for a customer. Once the first program executes, add notifications and batch scenarios.

If you have a Marlin machine, the path is similar: set the baud rate correctly, use M114/M119 status commands, and connect the gateway through OctoPrint. And when you are ready, combine several machines into one pool with MQTT and let the AI agent run your workshop around the clock.

← All posts

Comments