3D printer G-code · Marlin and Klipper

G28: Home axes (Marlin & Klipper)

Home axes — Moves the axes to their endstops (or the probe for Z) and sets the machine position. Without letters all axes are homed. Every print must start with G28, because the…

By cnccode · Updated
On this page
  1. What does G28 do?
  2. Parameters
  3. Example
  4. Tips from practice
  5. Related commands
  6. More motion commands
  7. Frequently asked questions
PropertyValue
CommandG28
FunctionHome axes
FirmwareMarlin and Klipper
GroupMotion
SyntaxG28 [X] [Y] [Z]

What does G28 do?

Moves the axes to their endstops (or the probe for Z) and sets the machine position. Without letters all axes are homed. Every print must start with G28, because the printer does not know its position after power on.

Parameters

ParameterMeaning
X Y ZHome only these axes

Example

G-code
G28        ; home all
G28 X Y    ; home only X and Y (park the head)

Tips from practice

  • In Marlin G28 turns bed levelling off; turn it back on with M420 S1 or run G29 afterwards.
  • With a probe as Z endstop the nozzle must be clean: a blob under the nozzle changes the first layer.
  • Klipper refuses moves before homing with "Must home axis first".

The command works in Marlin and Klipper. Options can differ: Klipper accepts fewer parameters for some M-codes and ignores codes it does not know with an "Unknown command" error.

More motion commands

CommandFunctionFirmware
G1Linear move (G0 / G1)Marlin and Klipper
G2Arc move clockwise (G2 / G3)Marlin and Klipper
G4Dwell (pause)Marlin and Klipper
G90Absolute positioning (G90 / G91)Marlin and Klipper

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 G28 do on a 3D printer?
G28 is home axes. Moves the axes to their endstops (or the probe for Z) and sets the machine position. Without letters all axes are homed. Every print must start with G28, because the printer does not know its position after power on.
Does G28 work in Klipper and Marlin?
Yes, both firmwares understand G28.
Was this page helpful?