How to Activate Auto Bed Leveling in Cura? (Marlin Firmware)

While automatic bed leveling is a considerable upgrade to manual leveling in many ways, having to manually initiate the auto bed leveling process before each print is not exactly a great experience, both in terms of reliability and convenience.

In this guide, we will explain how you can activate automatic bed leveling in Cura for Marlin firmware, which will instruct Cura to tell your 3D printer to automatically level the bed before every print without needing any manual action on your side, making the bed leveling process truly automatic as the name suggests.

How to Activate (or Deactivate) Auto Bed Leveling in Cura for Every Print?

In a nutshell, activating auto bed leveling in Cura involves inserting the G-code command responsible for either leveling the bed with a probe or activating bed leveling by using a saved mesh into the Start G-Code section of Cura.

As the G-code commands in the Start G-code section are automatically added to every .gcode file that Cura produces, the 3D printer ends up automatically leveling the bed at the start of each print.

Start G-code example in gcode file


Without further ado, let’s get into it!

To start, click the Settings option on the menu bar, hover over the Printer option, and click the Manage Printers option from the dropdown menu.

Cura manage printers


Next up, choose the printer you would like to make the modification for from the left pane, and press the Machine Settings button.

Cura machine settings


If the Machine Settings button isn’t visible to you, click the “three lines” icon on the top-right, and click the Activate option from the dropdown menu to make the button visible.

Cura activate printer


At this point, you can take two different paths: inserting either the G29 (Auto Home) or the M420 (Bed Leveling State) G-code command, where the prior is for automatically leveling your printer’s bed without a saved mesh, and the latter is for using a saved mesh that was generated by the probe beforehand.

Auto Bed Leveling in Cura with G29

First, let’s go through the scenario where you don’t use a saved mesh for the bed leveling process and prefer the probe to level the bed from scratch before each print, which comes with the advantage of increased reliability due to the mesh data always being freshly generated, but at the expense of higher machine wear & tear and increased print times.

In this case, add the G29 (G29 P1 for UBL, but it wouldn’t make a whole lot of sense to probe the bed before each print if you’re using UBL, as UBL is primarily designed for the usage of a saved mesh) command right below G28 in the Start G-code input area, which will cause your 3D printer to start probing the bed as soon as auto-homing is done.

Please ensure that G29 always comes after G28, as G29 requires the printer to be homed with G28 first, and the G28 command disables bed leveling by default.

While having RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28 explicitly defined in Configuration.h will prevent G28 from disabling bed leveling, these parameters are inactive by default in most Marlin forks, making it a good idea to always place G29 after G28 as a rule of thumb.

automatic bed leveling without saved mesh start g-code


With that, you have successfully enabled auto bed leveling in Cura!

As a bonus, if you want to verify that everything is working as intended before moving forward with a print, you can open up the following .gcode file that you have sliced with Cura in a text editor and locate the G29 G-code command in there.

Finally, if you want to deactivate auto bed leveling in Cura, you can retrace your steps and remove the G29 G-code command you have added, bringing things back to normal.

Auto Bed Leveling in Cura with M420

Now, let’s look at how we can get Cura to use our saved mesh instead to level the bed automatically before each print.

In this case, saved mesh refers to a mesh that has been previously generated with the G29 (G29 P1 for UBL) command, and saved to the EEPROM with the M500 command (G29 Sn for UBL, where n is the slot index, such as G29 S1 to save the mesh to slot index 1).

While this method is considered to be the more optimal out of the two, as it saves both time and machine wear & tear, renewing the mesh every few prints is still necessary to ensure that the data stays up-to-date with the bed’s current positioning, and failing to do so will gradually reduce the reliability of auto bed leveling.

For this process, add the M420 S1 (it can be necessary to add the L parameter to M420 in some cases of using UBL, such as sending the command M420 S1 L1 to activate bed leveling specifically with the saved mesh in slot index 1) command right below G28 in the Start G-code input area instead, which will instruct your 3D printer to load the saved mesh as soon as auto-homing is done.

Please ensure that M420 S1 always comes after G28, as the G28 command also disables bed leveling in the case of using a saved mesh (unless RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28 is defined in Configuration.h).

automatic bed leveling with saved mesh start g-code


Once that’s done, you can go ahead and close the windows you have opened, slice the next model you would like to print, and enjoy Cura handling the automatic bed leveling process by using your saved mesh!

Additionally, if you would like to verify that the change you have made is reflected in the .gcode files that Cura produces, you can open a file in your favorite text editor and search for M420 S1, which should be there in the Start G-code block.

Finally, if you want to deactivate saved mesh auto bed leveling in Cura, you can retrace your steps and remove the M420 S1 G-code command you have added to bring things back to their default state.

Example Cura Auto Bed Leveling Start G-Code Blocks for Ender 3 (Pro & V2 & S1 & Neo)

Since we have been using an Ender 3 V2 Neo to demonstrate the process of activating auto bed leveling in Cura for this guide, we would like to share with you the Start G-Code blocks we have prepared, both for leveling with and without a saved mesh, for any Ender 3 users who can benefit from them.

As a bonus, these code blocks contain some extra optimizations that shorten the required time for the pre-print stage, which can save a decent amount of time over many prints.

Start G-Code Block for Leveling without Saved Mesh

M104 S180 ; Start pre-heating the nozzle to a safe temperature where the filament won't ooze to save time
M190 S{material_bed_temperature_layer_0} ; Start heating the bed to the target temperature specified in Print Settings and wait until the temperature is reached
G92 E0 ; Reset extruder
G28 ; Auto Home all axes
G29 ; Automatic bed leveling
M104 S{material_print_temperature_layer_0} ; Start heating the nozzle to the target temperature specified in Print Settings
G1 Z2.0 F3000 ; Move Z Axis up
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
M109 S{material_print_temperature_layer_0} ; Wait until the nozzle is heated to the target temperature specified in Print Settings
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to the side
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset extruder
G1 Z2.0 F3000 ; Move Z Axis up
G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish

Start G-Code Block for Leveling with Saved Mesh

M104 S180 ; Start pre-heating the nozzle to a safe temperature where the filament won't ooze to save time
M190 S{material_bed_temperature_layer_0} ; Start heating the bed to the target temperature specified in Print Settings and wait until the temperature is reached
G92 E0 ; Reset extruder
G28 ; Auto Home all axes
M420 S1 ; Automatic bed leveling with saved mesh
M104 S{material_print_temperature_layer_0} ; Start heating the nozzle to the target temperature specified in Print Settings
G1 Z2.0 F3000 ; Move Z Axis up
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
M109 S{material_print_temperature_layer_0} ; Wait until the nozzle is heated to the target temperature specified in Print Settings
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to the side
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset extruder
G1 Z2.0 F3000 ; Move Z Axis up
G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish

Conclusion

Now that you have set automatic bed leveling up in Cura, you will never have to worry about manually initiating the auto bed leveling process before each print, which will significantly improve both convenience and consistency.

Considering how easy it is to set up, on top of the benefits it brings to the 3D printing experience, there really isn’t much of a reason not to have Cura handle the automatic bed leveling process while you focus on parts of the print that require your attention.