These Marlin commands measure with a probe, align the machine and store the
corrections. Each exists only if the firmware was built with the option named for it.
Bed levelling with G29 has its
own page.
G30: probe one point
Needs a bed probe. Probes the bed once, at the current position unless
X or Y is given. The build option
SERIAL_FLOAT_PRECISION sets the decimal places of the result.
| Parameter | Meaning |
|---|---|
X pos, Y pos | Position to probe |
E 0/1 | Engage the probe for each point; default 0 |
C 0/1 | Apply probe temperature compensation; default 1 (builds with PTC_PROBE, PTC_BED, PTC_HOTEND) |
G31 and G32: probe sled
Need Z_PROBE_SLED. Neither takes a parameter.
| Command | Meaning |
|---|---|
G31 | Dock the sled that carries the Z probe |
G32 | Undock it |
G33: delta auto calibration
Since 1.1.0; needs DELTA_AUTO_CALIBRATION. Probes a circular grid and
calibrates the delta height, end stops, radius and tower angles. Results are kept
with M500.
| Parameter | Meaning |
|---|---|
P points | 0: normalise end stop and tower angle corrections without probing. 1: probe the centre and set the height. 2: probe centre and towers; set height, end stops and radius. 3: probe centre, towers and opposite points; set everything. 4 to 10: the same with intermediate points, averaged. The default is DELTA_CALIBRATION_DEFAULT_POINTS |
C precision | Stop iterating at this precision; otherwise iterate to the best achievable |
F 0–30 | Force this number of iterations and take the best result; default 0 |
L 3, 4, 6 or 7 | Since 2.1.3, with DELTA_CALIBRATION_LEAST_SQUARES: solve by least squares. 3: end stops and height; 4: also the radius; 6: also tower angles; 7: also the diagonal rod. Needs P2 or higher; L6 and L7 need P3 or higher and no T |
T | Do not calibrate tower angles (P3 to P7) |
V 0–3 | 0: dry run, nothing calibrated; 1: report settings (default); 2: also probe results; 3: also calibration results |
E | Engage the probe for each point |
O | Since 2.0.9.2: probe at positions relative to the probe offset instead of the exact kinematic points |
R amount | Since 2.0.9.2: shrink the probed grid by this amount for this run |
S | With sensorless delta probing: save the sensorless offset adjustment |
X, Y, Z | With sensorless delta probing: do not activate stall detection on that tower; G33 P1 Y Z calibrates X alone |
G34: align several Z steppers
G34 means one of two things, chosen at build time. With
Z_STEPPER_AUTO_ALIGN or Z_MULTI_ENDSTOPS it levels the
gantry or bed that several Z motors carry, probing one position per motor. The
positions are set with
M422.
| Parameter | Meaning |
|---|---|
I 1–30 | Number of iterations |
T 0.001–1.0 | Target accuracy |
A 0.5–2.0 | Amplification |
E 0/1 | Stow the probe after each point |
R | Recalculate the points from the current probe offsets |
L | Unlock all Z motors |
Z 1–4 | Motor to lock or unlock |
S 0/1 | Lock state: 1 locked (assumed if omitted), 0 unlocked |
G34 ; align
G34 L Z2 ; unlock all, then lock Z2
G34 Z2 S0 ; unlock Z2
G34: mechanical gantry calibration
Since 2.0.4; needs MECHANICAL_GANTRY_CALIBRATION. Squares the ends of
the X gantry without a probe: the carriage goes to a safe position, motor current is
lowered where possible, Z is driven past its top limit, then brought back, the
current restored and the machine homed again.
| Parameter | Meaning |
|---|---|
S mA | Motor current for the raising move; default GANTRY_CALIBRATION_CURRENT |
Z distance | How far past Z_MAX_POS to move; default GANTRY_CALIBRATION_EXTRA_HEIGHT |
G35: tramming assistant
Needs ASSISTED_TRAMMING. An interactive procedure that measures the
bed corners and says how to turn the adjusting screws.
S value | Screw thread |
|---|---|
S30, S31 | M3, clockwise and counter-clockwise |
S40, S41 | M4, clockwise and counter-clockwise |
S50, S51 | M5, clockwise and counter-clockwise |
G38.2 to G38.5: probe towards a target
Since 1.1.0; need G38_PROBE_TARGET and a probe, and
G38.4 and G38.5 also G38_PROBE_AWAY. They move
towards a target until the probe changes state, to find the position of a
workpiece.
| Command | Stops on | Target reached without it |
|---|---|---|
G38.2 | Contact, moving towards the target | Error |
G38.3 | Contact, moving towards the target | No error |
G38.4 | Loss of contact, moving away | Error |
G38.5 | Loss of contact, moving away | No error |
| Parameter | Meaning |
|---|---|
X, Y, Z pos | Target position |
F rate | Feed rate; by default the homing feed rate |
G42: move to a mesh point
Since 1.1.2; needs a levelling system with a mesh. Moves like G0, with
the destination given as a mesh column and row.
| Parameter | Meaning |
|---|---|
I column | Mesh column |
J row | Mesh row |
F rate | Highest feed rate of the move; also applies to later moves without F |
P | Put the probe, instead of the nozzle, over the point |
G76: probe temperature calibration
Needs PROBE_TEMP_COMPENSATION with PTC_PROBE and
PTC_BED. Measures how probe readings change with temperature; the
offsets are then added during G29 mesh levelling. Only the bed is
heated, not the hot end: the probe is warmed by bringing it near the bed and cooled
by moving it away. The run can be very long (the documentation gives a 15 minute
timeout for heating and cooling). Save with M500.
| Form | Meaning |
|---|---|
G76 | Calibrate for the bed, then the probe |
G76 B | Bed only |
G76 P | Probe only |
M871: temperature compensation values
Needs PROBE_TEMP_COMPENSATION. Alone, prints the tables. Values are
held in micrometres; index 0 is always zero. Save with M500.
| Parameter | Meaning |
|---|---|
B, P, E | Which table to write: bed, probe or extruder |
I index | Entry to write |
V µm | Z adjustment to store there |
R | Reset every value to zero |
M871 B I2 V20 ; bed table, entry 2: 20 µm
M871 P I1 V-5 ; probe table, entry 1: -5 µm
G425: calibration against a conductive object
Needs CALIBRATION_GCODE. The nozzle touches the sides of an
electrically conductive object fixed to the bed (a cube, washer or bolt) wired to
CALIBRATION_PIN, measuring backlash, position errors and nozzle offsets.
It does not switch backlash compensation on; M425 does that.
| Parameter | Meaning |
|---|---|
B | Calibrate backlash only |
T index | Calibrate one tool head only |
V | Probe the object and report position, error, backlash and nozzle offset (needs CALIBRATION_REPORTING) |
U mm | Uncertainty: how far from the object probing starts |
G425 ; full calibration
M425 F1 S0 ; then enable backlash compensation at 100 %
M48: probe repeatability test
Needs Z_MIN_PROBE_REPEATABILITY_TEST. Probes one position repeatedly
and reports the standard deviation.
| Parameter | Meaning |
|---|---|
P count | Number of probings |
X pos, Y pos | Position to test |
V 0–4 | Verbosity; default 1 |
E 0/1 | Engage the probe for each probing |
L count | Number of legs of movement between probings |
S 0/1 | Pattern of those moves: 0 circular, 1 star-like (7 points unless L says otherwise) |
C 0/1 | Apply temperature compensation; default 1 (builds that have it) |
M401 and M402: deploy and stow the probe
Need a bed probe. On a probe that does not move they only activate or deactivate it. Z may be raised to make room.
| Form | Meaning |
|---|---|
M401 | Deploy and activate the probe, taring it if configured |
M401 R1 | Deploy and remain in place |
M401 S0/1 | Since 2.0.9.3, with BLTOUCH_HS_MODE: set BLTouch high speed mode without deploying |
M401 H | Since 2.0.9.4: report that mode without deploying |
M402 | Stow and deactivate the probe |
M402 R1 | Since 2.1.3: stow and remain in place |
M851: probe offset
Needs a bed probe. Sets the distance from the nozzle to the point where the probe
triggers. Positive X is a probe to the right of the nozzle, positive
Y a probe behind it; a probe that triggers below the nozzle, the usual
case, has a negative Z. The factory values come from
NOZZLE_TO_PROBE_OFFSET (in 1.x, three
..._PROBE_OFFSET_FROM_EXTRUDER settings). On a SCARA the offset turns
with the forearm. Changing it does not alter existing levelling data. Save with
M500.
| Parameter | Meaning |
|---|---|
X mm | X offset |
Y mm | Y offset |
Z mm | Z offset |
M852: skew compensation
Needs SKEW_CORRECTION_GCODE. Sets factors, from -1 to 1, that correct
axes which are not square to one another. Stored in EEPROM.
| Parameter | Meaning |
|---|---|
I factor | XY skew |
J factor | XZ skew |
K factor | YZ skew |
S factor | Another name for I when only XY correction is built in |
M860 to M869: I2C position encoders
Since 1.1.4; need I2C_POSITION_ENCODERS. They manage magnetic encoder
modules that report real axis positions.
| Command | Meaning | Own parameters |
|---|---|---|
M860 | Report encoder positions | U: millimetres or raw steps; O: include the homed zero offset |
M861 | Report module status | |
M862 | Test an axis for continuity | |
M863 | Calibrate steps per millimetre | P n: repetitions |
M864 | Change a module’s I2C address | S 30–200: new address |
M865 | Report module firmware version | |
M866 | Report or reset the error count | R: reset |
M867 | Error correction on or off | S 0/1; omitted, toggles |
M868 | Report or set the correction threshold | T value |
M869 | Report the encoder error |
Modules are chosen with I index (from 0), or with
A address (30 to 200; for M864 the current
address, by default the X preset), or by the axis letters X,
Y, Z and E when neither is given.
Sources
- MarlinDocumentation – Marlin’s own documentation source, files G030 to G033, G034-mgc, G034-zsaa, G035, G038, G042, G076, G425, M048, M401, M402, M851, M852, M860-M869 and M871 in
docs/gcode/, as of 3 December 2026