3D printer G-code · Marlin

M420: Bed levelling state (Marlin)

Bed levelling state — Turns mesh compensation on or off, sets the fade height and prints the stored mesh. Because G28 turns levelling off in many builds, start codes use G28 followed by M420…

By cnccode · Updated
On this page
  1. What does M420 do?
  2. Parameters
  3. Example
  4. Tips from practice
  5. Related commands
  6. More bed levelling commands
  7. Frequently asked questions
PropertyValue
CommandM420
FunctionBed levelling state
FirmwareMarlin
GroupBed levelling
SyntaxM420 [S<0|1>] [Z<fade>] [V]

What does M420 do?

Turns mesh compensation on or off, sets the fade height and prints the stored mesh. Because G28 turns levelling off in many builds, start codes use G28 followed by M420 S1.

Parameters

ParameterMeaning
S1 on, 0 off
ZFade height: compensation fades out up to this height
VPrint the mesh

Example

G-code
G28
M420 S1 Z10

Tips from practice

  • Fade height 5–10 mm stops a warped bed from showing in the top of the part.

Marlin. Many Marlin commands only exist when the feature is enabled in the firmware build. If the printer answers "Unknown command", the feature is missing. Klipper does not understand most of these settings codes; it uses printer.cfg instead.

More bed levelling commands

CommandFunctionFirmware
G29Bed levelling (probe the mesh)Marlin
M851Probe offset (Z offset)Marlin
M48Probe repeatability testMarlin
G34Z stepper auto-alignMarlin
G26Mesh validation patternMarlin
BED_MESH_CALIBRATEProbe the bed mesh (Klipper)Klipper
BED_MESH_PROFILESave and load mesh profilesKlipper
Z_TILT_ADJUSTLevel the gantry (two or three Z motors)Klipper
QUAD_GANTRY_LEVELQuad gantry levelKlipper
PROBE_CALIBRATEFind the probe Z offsetKlipper
SET_GCODE_OFFSETLive Z (babystep)Klipper
SCREWS_TILT_CALCULATEBed screw turnsKlipper

Test it before you print

Paste your start code or a whole file into the 3D printer simulator. It plans every move, shows the time and finds missing waits, cold extrusion and moves outside the bed.

Open the simulator

Frequently asked questions

What does M420 do on a 3D printer?
M420 is bed levelling state. Turns mesh compensation on or off, sets the fade height and prints the stored mesh. Because G28 turns levelling off in many builds, start codes use G28 followed by M420 S1.
Does M420 work in Klipper and Marlin?
M420 is a Marlin command. Klipper uses its own commands and printer.cfg settings for this task.
Was this page helpful?