This page gives RepRapFirmware’s codes for setting up Z probes, probing, mesh bed
compensation and levelling, from the Duet3D G-code dictionary as read on 3 December
2026. Homing is on
RepRapFirmware motion. RRF
means RepRapFirmware, and version numbers are its versions. Probing moves need homed
axes, and probes that must be deployed use the macros of M401 and
M402.
M558: create or change a probe
M558 P deletes any probe with that number and creates a new one,
resetting its G31 values. M558 comes before
G31.
| Parameter (RRF 3) | Meaning |
|---|---|
K | Probe number, default 0 |
P | Probe type, below |
C"pin" | Input pin and optional modulation pin; required except for types 0 and 10. ! inverts the input, ^ turns on its pullup (needed on the Duet 2 probe input in RRF 3 for switches and BLTouch) |
H or Ha:b | Dive height in mm above the trigger height, default 3 or 5 by version; the second value (3.5.1 and later) serves repeat probes and is measured from the last trigger. With Z homed a probing move ends at (M208 Z minimum − first dive height + trigger height) |
F | Probing speed in mm/min. A second, lower value (3.3 and later) adds repeat probes at that speed after a fast one in a plain G30; a third (3.5.0 and later) is the scanning speed |
T | Travel speed between points, also the Z lift speed, mm/min; M203 limits apply if lower |
R | Settling time before probing, seconds, default 0 |
A | Most probes per point, default 1, up to 31 |
S | Tolerance, default 0.03 mm: probing repeats until two results in a row agree within it and averages them, else averages all A results. S-1 forces averaging |
B1 | Heaters off while probing (default B0) |
V | Load cell scale in grams per count, negative if readings fall under force; required for, and only for, type 12; use its sign and not ! (3.7 and later) |
Ulow:high | Type 12: allowed preload window in grams, checked after the tare before each probe; two equal values disable the check |
P | Probe type |
|---|---|
| 0 | None: you are asked to jog Z until the nozzle touches |
| 1 | Unmodulated or smart IR, or anything emulating one: analogue, rising as the nozzle nears the bed; control signal high |
| 2 | Simple modulated IR; only one, on the main board with Duet 3 (deprecated from 3.7.0) |
| 3 | As 1 with the control signal low (not from 3.7.0) |
| 4, 6, 7 | RRF 2 only: switch on the E0 endstop input (4, input chosen by C, default 3), on E1 (6, deprecated) or on Z (7, deprecated) |
| 5 | Switch, normally closed by default (deprecated from 3.7.0 for 8) |
| 8 | As 5, unfiltered and faster |
| 9 | As 5, for a BLTouch retracted and redeployed between points |
| 10 | Z motor stall detection |
| 11 | Scanning probe with analogue output (3.5.0 and later); calibrate with M558.1 |
| 12 | Load cell (3.7 and later), only on expansion and tool boards; tared at creation and before each probe, drift tracked between probes, a reading of exactly zero refused |
On Duet 3 expansion and tool boards the types are 8 and 9, plus 11 from 3.5 and 1 and 12 from 3.7. On the main board types 1, 2 and 5 can only be probe 0. In 3.7, trigger delay over CAN is compensated, which may call for a slightly larger trigger height.
RRF 2 and earlier take P, F, H (default 5),
R (1.17 on), T, A, S,
B (1.21 on), I1 to invert the reading (1.16 to 2.x) and
C for the endstop input of type 4; in 1.19 and earlier non-zero
X, Y, Z made the probe home that axis (later
M574).
M558 P8 C"io2.in" H5 F120 T3000
M950 S0 C"io3.out"
M558 P9 C"io3.in" H5 F500:120 T3000 ; BLTouch, driven with M280 P0
M558.1 to M558.4: scanning and load cell probes
| Form | Effect |
|---|---|
M558.1 Kn Smm | (3.5.0) Calibrate: scan from trigger height + mm down to trigger height − mm (at least 0.1, at most the trigger height) and compute the coefficients and threshold |
M558.1 Kn A B C | Set linear, quadratic and cubic coefficients (B, C default 0, used only with A): height = trigger height + A·d + B·d² + C·d³, d = reading − G31 P |
M558.1 Kn | Report offset and coefficients |
M558.2 Kn S-1 | (3.5.0, LDC1612 probes) Find drive current and reading offset, with the sensor at the closest working distance |
M558.2 Kn Sc Ro | Set drive current (0 to 31) and the offset subtracted from raw readings (default 0); then repeat M558.1 |
M558.3 K S F H V | (3.6.0, parameters provisional) S0 threshold mode, S1 touch mode, where contact is found from a sharp change in the rate of the reading; F touch feed rate (default 200), H nozzle height assumed at touch (default −0.1), V sensitivity 0.0 (very) to 10.0 (hardly), default 0.5. Omitted values stay; none reports |
M558.4 Kn | (3.7.0) Tare a load cell probe now, for example after a tool change; it also happens automatically |
Before M558.1: probe defined as scanning, trigger height set, axes
homed, sensor over the bed away from its edges, drive current set.
G31 and M851: probe values
Alone, G31 reports whether the probe is triggered, or its
reading.
| Parameter | Meaning |
|---|---|
K | Probe, default 0 (RRF 3) |
P | Trigger value. Type 12: force in grams after the tare, negative to trigger on falling force (3.7 and later) |
Z | Height at which it triggers, default 0.7 (3.3 documentation) |
X, Y (3.3 and later any axis but Z) | Probe offset from the print head reference point |
S | Temperature at which Z is correct, default the current one |
Ta or Ta:b | 3.3 and later: trigger height changes by a·Δ + b·Δ², Δ = temperature − S |
H | RRF 3: M308 sensor for that compensation |
C | The coefficient before 3.3: two values in 3.2, one in 3.0, 3.1 and RRF 2, which uses the bed temperature |
T (RRF 2, 1.17 on) | Probe type the S and C values belong to; separate sets exist for types 0 and 4, 1 and 2, and 3 |
G31 follows M558, and M584 if it names
axes beyond X and Y. The nozzle used as probe may need a negative Z.
M500 P31 saves the values.
G31 P500 X23 Y5 Z1.1 S21 H2 T0.02
M851 Z-2.3 (2.02 and later) is Marlin compatibility: it sets the
trigger height with the sign reversed against G31 Z and marks the
values for M500. G31 is preferred.
G30: probe one point
| Parameter | Meaning |
|---|---|
P | Point number in a calibration sequence, from 0 upwards |
X, Y | Where to probe; may lie outside the printable area on purpose |
Z | −9999 or lower: probe from the dive height. A normal value is taken as the trigger height found, without probing |
H | Height correction at this point, for a trigger height that varies over the bed |
S | What to do, below |
K | Probe number, default 0 every time (3.01 and later) |
Without P | Effect at the current XY |
|---|---|
G30, S0, S-4 or lower | Probe and set Z to the trigger height |
S-1 | Only report the machine height at trigger |
S-2 | Adjust the selected tool’s Z offset |
S-3 | Set the probe’s trigger height (2.03 and later) |
With P points, the S on the last one ends the set:
S-1 reports errors only. On Cartesian and CoreXY, S0
calibrates as many factors as points, another value that many factors (not more
than the points). Linear delta auto calibration takes 3, 4, 6, 7, 8 or 9; rotary
delta (experimental) 3, 4, 5 or 7. A scanning probe works as an ordinary one from
3.5.0.
G30 P0 X20 Y190 Z-99999
G30 P1 X180 Y190 Z-99999
G30 P2 X100 Y10 Z-99999 S3
G32 and M557: levelling macro and probe points
G32 runs bed.g (passing its parameters from 3.3), which
normally probes with G30 for delta calibration, independent Z motor
levelling or screw adjustment advice.
M557 parameter | Mesh grid for G29 |
|---|---|
Xa:b, Ya:b | Range in mm; from 3.3 any axis pair other than Z |
R | Probing radius (X and Y); with a range as well, their intersection |
S or Sx:y | Point spacing (two values from 1.19) |
P or Px:y | Number of points instead (2.02 and later) |
The number of points is limited by board and version (961 or 441; 121 in RRF 1 on
the Duet 0.6 and 0.8.5). Before 1.18, M557 Pn
X Y instead stored a G32 probe point; use
bed.g.
M557 X0:200 Y0:220 S20
M557 R150 S15
G29 and M374 to M376, M561: mesh compensation
| Command | Effect |
|---|---|
G29 | From 3.2 runs sys/mesh.g if present (with any parameters from 3.3), else as S0 |
G29 S0 | Probe the grid, save /sys/heightmap.csv and turn compensation on |
G29 S1 P"file" | Load a map and turn it on |
G29 S2 | Turn compensation off and clear the map (and the invalid point map where supported) |
G29 S3 P"file" | Save the map (2.04 and later) |
G29 S4 P"file" | Duet 3, 3.5 and later: load grid and point map, default /sys/probePoints.csv |
K with G29 | Probe number, default 0 (3.01 and later) |
M374 P"file" | Save grid and map, default heightmap.csv (G29 S0 already saves) |
M375 P"file" | Same as G29 S1; a missing file reports an error and leaves compensation off |
M376 Hmm | Taper compensation linearly from full at Z=0 to none at this height; 1.0 or less disables. Extrusion is not adjusted, so use at least 20 times the largest map error |
M561 | Cancel bed plane fitting and move in user coordinates again |
A probe points file looks like a height map but starts with
RepRapFirmware probe points file v2, and from its fourth line holds 1
for points to probe and 0 for points to skip. After G29 S4,
G29 S0 uses it in place of M557.
M401 and M402: deploy and retract
M401 runs sys/deployproben.g if
present, else sys/deployprobe.g; M402 likewise
retractprobe. P gives the probe number (3.01 and later),
and from 3.5 the general macro receives it as K. After
M401, probing does not run the macros for that probe until
M402.
G38.2 to G38.5: straight probing
| Command | Direction | Failure |
|---|---|---|
G38.2 | Towards the workpiece until contact | is an error |
G38.3 | Towards, until contact | is not |
G38.4 | Away until contact is lost | is an error |
G38.5 | Away until contact is lost | is not |
RRF 3 and later. Axis words give the target (user coordinates after 3.1.1),
K the probe (3.3; P before, now deprecated),
F the speed (3.6.0; otherwise the probe’s M558 F). For
the two error forms, a probe already in the target state, no target, or a target
equal to the position are errors. A probe need not be inverted to probe away.
M671: pivot points and levelling screws
| Parameter | Meaning |
|---|---|
X, Y | 2 to 4 coordinates each, colon separated, measured from the M208 origin |
S | Largest correction per point in mm, default 1.0 |
P | Screw pitch in mm for manual levelling advice, default 0.5 (M3) |
F | Factor on the computed corrections, default 1.0, to converge faster on real joints |
With independent Z motors there is one pair per M584 Z driver, in the
same order, and G32 levels with them. Otherwise the points may be bed
screws, or the feet of a printer standing on the print surface (then read the
advice reversed). It follows kinematics commands such as M667 and
M669.
M671 X-15.0:100.0:215.0 Y220.0:-20.0:220.0
M672, M673, M674 and M675
| Command | Parameters and effect |
|---|---|
M672 Sb:b… K | Send configuration bytes to a programmable probe (K 3.01 and later). Duet3D Smart Effector (programming pin set in M558): S105:t:255−t sets the threshold (default 50, higher is less sensitive); S131:131 restores factory settings |
M673 axis S F | (2.02) Align a plane on rotary axis U V W A B C after two G30 P points, all axes homed; S factor (default 1), F feed rate. Without an axis and with four or more points, find the rotary centre offset in X or Y and Z, report it and move by it |
M674 | Set Z to a workpiece’s centre on a rotary axis: listed as not yet implemented |
M675 axis F R P | Find the centre of a cavity: probe to the low side, back off R (default 5), probe the high side, move to the middle. F and P (or K) are required; the axis homed and a tool selected |
Sources
- G-code dictionary – Duet3D’s documentation of RepRapFirmware’s commands, published under a Creative Commons attribution share-alike licence; this page is written in our own words