-
Notifications
You must be signed in to change notification settings - Fork 0
M Code Reference
This reference covers standard RepRap M-codes and proprietary FlashForge extensions supported via TCP port 8899.
| Code | Function | Parameters | Description |
|---|---|---|---|
| M17 | Enable Steppers | None | Enable all stepper motors |
| M18 | Disable Steppers | None | Disable all stepper motors |
Warning (M18): Disabling steppers may cause the Z-axis to drop due to gravity.
| Code | Function | Parameters | Description |
|---|---|---|---|
| M23 | Select File | path | Select file for printing |
| M24 | Start/Resume | None | Start selected file or resume paused job |
| M25 | Pause Print | None | Pause current print job |
| M26 | Stop Print | None | Cancel current print job immediately |
Selects a file from printer storage for printing.
Command Format:
~M23 0:<file_path>
Path Formats:
-
0:/user/<filename>- User storage path -
/data/<filename>- Data storage path
Examples:
~M23 0:/user/Benchy.gcode
~M23 /data/Model.3mf
Response:
CMD M23 Received.
ok
Important: After stopping via TCP, the printer will not be controllable until the cancelled job dialog is manually cleared from the printer's screen.
Modern Printers (5M/AD5X): The HTTP API provides a way to programmatically clear the stopped state using stateCtrl_cmd:
POST http://10.0.0.42:8898/control
Content-Type: application/json
{
"serialNumber": "SNADVA5MXXXXX",
"checkCode": "12345",
"payload": {
"cmd": "stateCtrl_cmd",
"args": {
"action": "setClearPlatform"
}
}
}This dismisses the on-screen dialog and returns the printer to a controllable state.
| Code | Function | Parameters | Description |
|---|---|---|---|
| M27 | Report Status | None | Get print job progress |
| M105 | Get Temperatures | None | Get current/target temps |
| M114 | Get Position | None | Get current XYZE position |
| M115 | Get Firmware Info | None | Get printer details |
| M119 | Endstop Status | None | Get endstops and status |
Response:
CMD M115 Received.
Machine Type: Flashforge Adventurer 5M Pro
Machine Name: Adventurer 5M Pro
Firmware: v3.1.5
SN: SNXXXXXXX1234
X: 220 Y: 220 Z: 220
Tool Count: 1
Mac Address:XX:XX:XX:XX:XX:XX
ok
Response (Modern Format):
CMD M105 Received.
T0:17.9/0.0 T1:0.0/0.0 B:18.5/0.0
ok
Response (Legacy Format):
CMD M105 Received.
T0:22 /0 B:11/0
ok
| Field | Description |
|---|---|
| T0 | Primary extruder (current/target) |
| T1 | Secondary extruder (current/target) |
| B | Heated bed (current/target) |
Response:
CMD M119 Received.
Endstop: X-max: 110 Y-max: 110 Z-min: 0
MachineStatus: READY
MoveMode: READY
Status: S:1 L:0 J:0 F:0
LED: 1
CurrentFile:
ok
| Field | Description |
|---|---|
| Endstop | X, Y, Z endstop states |
| MachineStatus | READY, BUILDING_FROM_SD, PAUSED, BUSY, BUILDING_COMPLETED |
| MoveMode | MOVING, PAUSED, READY, WAIT_ON_TOOL, HOMING |
| LED | 1 = ON, 0 = OFF |
| CurrentFile | Active print filename |
| Code | Function | Parameters | Description |
|---|---|---|---|
| M104 | Set Nozzle Temp | S | Set extruder temp (async) |
| M140 | Set Bed Temp | S | Set bed temp (async) |
Command: ~M104 S<temperature>
| Value | Description |
|---|---|
| S0 | Turn off extruder heating |
| S210 | Set to 210C |
Examples:
~M104 S210 (Heat to 210C)
~M104 S0 (Turn off)
Command: ~M140 S<temperature>
| Value | Description |
|---|---|
| S0 | Turn off bed heating |
| S60 | Set to 60C |
| Code | Function | Parameters | Description |
|---|---|---|---|
| M106 | Fan On | [S] | Turn fan on (optional speed) |
| M107 | Fan Off | None | Turn fan off |
Command: ~M106 [S<speed>]
| Model | Speed Support |
|---|---|
| Adventurer 3 | On/Off only (no speed control) |
| 5M Series | Variable speed S0-255 |
Examples:
~M106 (Full speed)
~M106 S128 (50% speed - 5M only)
~M106 S255 (Full speed - 5M only)
| Code | Function | Parameters | Description |
|---|---|---|---|
| M112 | Emergency Stop | None | Immediate halt |
Warning: M112 causes an immediate halt of all operations. On some printers, axes are homed and heaters are turned off. The print job cannot be recovered after triggering M112.
| Code | Function | Description |
|---|---|---|
| M601 | Connect WiFi | Legacy session initialization |
| M602 | Disconnect WiFi | Legacy session termination |
Required before sending most commands.
Command: ~M601
Success Response:
CMD M601 Received.
Control Success V2.1.
ok
Failure Response:
CMD M601 Received.
Control Failed.
Failure indicates another client is connected or previous session was not properly closed.
Required before disconnecting.
Command: ~M602
Response:
CMD M602 Received.
Control Release.
ok
| Code | Function | Parameters | Description |
|---|---|---|---|
| M610 | Rename Printer | Set printer display name |
Warning: Triggers network service restart, briefly dropping the connection.
| Code | Function | Description |
|---|---|---|
| M650 | Get Calibration | Returns internal calibration values |
Note: Returns calibration values, NOT model identification.
| Code | Function | Description |
|---|---|---|
| M661 | List Files | Returns file list with special parsing |
| M662 | Get Thumbnail | Returns PNG binary with custom header |
Command: ~M661
Important: Data is sent AFTER the ok response.
Response:
CMD M661 Received.
ok
D::/data/File1.3mf::/data/File2.gcode...
The file list uses special delimiters and requires custom parsing.
Command: ~M662 <file_path>
Example: ~M662 /data/Model.gcode
Important: Binary PNG data is sent AFTER the ok response. The PNG has a custom header (0xa2a22a2a).
| Code | Function | Parameters | Description |
|---|---|---|---|
| M144 | LED On | None | Turn LED on (EEPROM write) |
| M145 | LED Off | None | Turn LED off (EEPROM write) |
| M146 | LED RGB | r g b F | Set LED color (preferred) |
Command: ~M146 r<red> g<green> b<blue> F0
| Parameter | Range | Description |
|---|---|---|
| r | 0-255 | Red intensity |
| g | 0-255 | Green intensity |
| b | 0-255 | Blue intensity |
| F | 0 | Control flag |
Examples:
~M146 r255 g255 b255 F0 (White, ON)
~M146 r255 g0 b0 F0 (Red)
~M146 r0 g0 b0 F0 (OFF)
Warning (M144/M145): These commands write to EEPROM. Avoid frequent use to prevent EEPROM wear. Use M146 instead.
| Code | Function | Description |
|---|---|---|
| M663 | Get XYZEF | Enhanced position query (serial passthrough) |
| Code | Function | Description |
|---|---|---|
| M28 | Start Upload | Begin binary file transfer |
| M29 | End Upload | Complete binary file transfer |
Note: For legacy printers (A3/A4) only. Modern printers should use HTTP /uploadGcode.
See TCP Protocol for complete M28/M29 documentation.
Some commands are present in firmware but non-functional:
| Code | Status | Notes |
|---|---|---|
| M108 | Stubbed | Cancel Heat Wait - non-functional on A3 |
| Code | Category | A3 | A4 | 5M | AD5X |
|---|---|---|---|---|---|
| M17 | Stepper | Yes | Yes | Yes | Yes |
| M18 | Stepper | Yes | Yes | Yes | Yes |
| M23 | Job | Yes | Yes | Yes | Yes |
| M24 | Job | Yes | Yes | Yes | Yes |
| M25 | Job | Yes | Yes | Yes | Yes |
| M26 | Job | Yes | Yes | Yes | Yes |
| M27 | Status | Yes | Yes | Yes | Yes |
| M104 | Temp | Yes | Yes | Yes | Yes |
| M105 | Temp | Yes | Yes | Yes | Yes |
| M106 | Fan | Yes* | Yes* | Yes | Yes |
| M107 | Fan | Yes | Yes | Yes | Yes |
| M112 | Safety | Yes | Yes | Yes | Yes |
| M114 | Status | Yes | Yes | Yes | Yes |
| M115 | Status | Yes | Yes | Yes | Yes |
| M119 | Status | Yes | Yes | Yes | Yes |
| M140 | Temp | Yes | Yes | Yes | Yes |
| M601 | Session | Yes | Yes | Yes | Yes |
| M602 | Session | Yes | Yes | Yes | Yes |
| M610 | Config | Yes | Yes | Yes | Yes |
| M650 | Calib | Yes | Yes | Yes | Yes |
| M661 | File | Yes | Yes | Yes | Yes |
| M662 | File | Yes | Yes | Yes | Yes |
| M663 | Status | Yes | Yes | Yes | Yes |
| M146 | LED | Yes | Yes | Yes | Yes |
*A3/A4: On/Off only (no variable speed)