G29 - Unified Bed Leveling

calibration Probe the bed and enable leveling compensation. AUTO_BED_LEVELING_UBL

The Unified Bed Leveling System (UBL) provides a comprehensive set of resources to produce the best bed leveling results possible.

See the full Unified Bed Leveling documentation for more details. (Examples below.)


G29 [A<bool>] [B<bool>] [C<bool/float>] [D<bool>] [E<bool>] [F<linear>] [H<linear>] [I<int>] [J<int>] [K<index>] [L<index>] [P<0|1|2|3|4|5|6>] [Q<index>] [R<int>] [S<slot>] [T<0|1>] [U<bool>] [V<0|1|2|3|4>] [W<bool>] [X<linear>] [Y<linear>]

Argument Description

Activate Unified Bed Leveling (i.e., M420 S1)


Business Card mode (P2 only)


Continue (P1), Current (P2), Constant (P3,Q2)


Disable Unified Bed Leveling (i.e., M420 S0).


Stow probe after probing Each point (P1 only).


Fade height. (UBL only! For others use M420 Z)


Height for Manual Probe raise (P2 only).


Invalidate this number of mesh points. (No value = 1)

  • With a value (v), do Square Grid probing of v x v points.
  • With no value, do Three Point probing - e.g. to adjust a loaded mesh to match slight bed misalignment.

Kompare: Subtract the stored mesh with the given index from the current mesh. This operates on the mesh in-memory, so it will probably invalidate the active mesh for purposes of printing.


Load a mesh. If no index is given, load the previously-activated mesh.



  • P0:

    Zero Mesh Data and turn off the Mesh Compensation System.

  • P1:

    Invalidate Mesh and do Automatic Z Probing.

  • P2:

    Probe Areas of the Mesh that can’t be automatically handled.

  • P3:

    Fill Unpopulated regions of the Mesh with a fixed value (C) or use ‘smart fill’ to extrapolate from already probed points (no argument).

  • P4:

    Fine Tune the Mesh. Generally used in the form G29 P4 Rnn Xxxx Yyyy.

  • P5:

    Find Mean Mesh Height and Standard Deviation.

  • P6:

    Shift Mesh height by the C value.


Test Pattern


Repeat count. (Default GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y)


Store mesh to EEPROM in the given slot. If no slot given, use last-activated. Use S-1 for GCode output.


Topology: Include a Topology Map in the output. Can be used alone or with several other commands. A map type can also be specified:

  • T0:


  • T1:



Unlevel: Probe the outer perimeter to assist physical leveling. (Use with G29 P1 O)


Verbosity Level (0-4)


What?: Displays current Unified Bed Leveling info


X position (otherwise, current X position)


Y position (otherwise, current Y position)




This is a minimal ‘quick-start’ sequence for set-up and initial probing of a UBL mesh on a machine that includes a display and z-probe

M502          ; Reset settings to configuration defaults...
M500          ; ...and Save to EEPROM. Use this on a new install.
M501          ; Read back in the saved EEPROM.
M190 S65      ; Not required, but having the printer at temperature helps accuracy
M104 S210     ; Not required, but having the printer at temperature helps accuracy
G28           ; Home XYZ.
G29 P1        ; Do automated probing of the bed.
G29 P2 B T    ; Manual probing of locations USUALLY NOT NEEDED!!!!
G29 P3 T      ; Repeat until all mesh points are filled in.
G29 T         ; View the Z compensation values.
G29 S1        ; Save UBL mesh points to EEPROM.
G29 F 10.0    ; Set Fade Height for correction at 10.0 mm.
G29 A         ; Activate the UBL System.
M500          ; Save current setup. WARNING - UBL will be active at power up, before any `G28`.

Use G26 and G29 commands to fine-tune a measured mesh

G26 C P T3.0  ; Produce mesh validation pattern with primed nozzle.
; NOTE - PLA temperatures are assumed unless you specify - e.g. - B 105 H 225 for ABS Plastic
G29 P4 T      ; Move nozzle to 'bad' areas and fine tune the values if needed.
; Repeat G26 and G29 P4 T  commands as needed.
G29 S1        ; Save UBL mesh values to EEPROM.
M500          ; Resave UBL's state information.

Use 3-point probe to ‘tilt’ a stored mesh; e.g. in your startup script

G29 L1        ; Load the mesh stored in slot 1 (from G29 S1)
G29 J         ; No size specified on the J option tells G29 to probe the specified 3 points and tilt the mesh according to what it finds.