BLTouch Start G-Code for Cura – Explanation & Examples

While a BLTouch can indeed automatically level the bed of your 3D printer, initiating the automatic bed leveling sequence before a print is still a manual task by default, which is not exactly optimal as it can be forgotten or become tedious over time.

In this guide, we will explain how you can write a BLTouch-supported Start G-code block for Cura to remove this manual task from the equation and share ready-to-use Cura Start G-code snippets for some of the popular BLTouch-compatible 3D printers that you can directly use.

How to Write a BLTouch Start G-Code for Cura?

To make your Cura Start G-Code automatically activate the BLTouch probe before every print, you will need to insert the G29 G-Code in there, which is the command responsible for triggering the automatic bed leveling sequence in Marlin Firmware.

When inserting the G29 (G29 P1 for UBL, but we wouldn’t recommend generating the mesh from scratch for each print in the case of UBL) G-Code into the Start G-Code section, you will want to ensure that it comes right after the G28 (Auto Home) G-Code, as a rule of thumb, which is good practice for two reasons.

First, the fact that initiating auto bed leveling requires the printer to be homed first (as the printer needs to know the current positions of the axes to be able to correctly generate the mesh) essentially means that G29 always has to come at a later point than G28.

Additionally, even if the printer was already homed before the Start G-Code block started running, it would still be necessary to place G29 after G28, as running G28 automatically disables automatic bed leveling unless RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28 is explicitly defined in Configuration.h (they’re both inactive by default in most Marlin firmware forks).

Second, placing the G29 command directly after G28 ensures that none of the movement and extrusion commands in the Start G-Code section run before the bed is level, such as the test lines that your 3D printer draws before starting the actual print.

ender 5 default start gcode bltouch example


Once you get your Start G-Code section to look like the example we have shown above (which is the default Cura Start G-Code for Ender 5 with G29 added to it), with the critical part being G29 being added after G28, your work is done!

Alternatively, if you want to go down the route of using a saved mesh that you created with your BLTouch beforehand instead of running the probe before each print, you can replace G29 with M420 S1.

To create a bed leveling mesh and make it possible to utilize M420 S1, you will need to level the bed first with G29, and then save the mesh to the EEPROM with M500. As your printer will automatically load the mesh along with the rest of EEPROM settings whenever it’s powered on, M420 S1 will work without issues from then on.

In the case of UBL, the bed leveling command that generates the mesh will be G29 P1 instead, and saving it will require you to run G29 Sn, where n is the slot number you would like to use, such as G29 S1 to save the mesh in the slot index 1. While your printer should automatically load the mesh on power up in this case as well, you may need to specify the slot number by passing the L parameter to M420 in some cases, such as sending the command M420 S1 L1 to activate bed leveling with the mesh saved in the slot index 1.

In this case, your Start G-Code section will look similar to the example below.

ender 5 default start gcode bltouch saved mesh example


Finally, to verify that the modifications you have made to the Start G-Code are reflected in the G-Code files that Cura produces, you can check the contents of a file (that you have sliced after making the changes) by opening it in a text editor, which should have either the G29 or the M420 S1 command in there.

bltouch start gcode verification from gcode file


With Cura prepending the G-code commands in the Start G-Code section to every G-code file it produces, your 3D printer will end up automatically leveling the bed before each print without any input from you, whether you have chosen the G29 (level from scratch with the probe) or the M420 S1 (level with pre-existing mesh) route.

Example BLTouch Start G-Code Blocks for Cura

In this section, you can find ready-to-use BLTouch Start G-Code blocks that you can utilize for popular BLTouch-supported printers such as Ender 3, Ender 5, and CR-10 by directly copying them into the Start G-Code section in Cura.

G29 (Level from scratch by running the probe)

M104 S180 ; Pre-heat nozzle to a safe temperature (180 degrees in this example)
M190 S{material_bed_temperature_layer_0} ; Heat the bed and wait until target temperature is reached
G92 E0 ; Reset extruder
G28 ; Home all axes
G29 ; Automatic Bed Leveling (BLTouch)
M104 S{material_print_temperature_layer_0} ; Heat the nozzle to the target temperature
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 for nozzle to reach target temperature
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

M420 S1 (Level with pre-existing mesh)

M104 S180 ; Pre-heat nozzle to a safe temperature (180 degrees in this example)
M190 S{material_bed_temperature_layer_0} ; Heat the bed and wait until target temperature is reached
G92 E0 ; Reset extruder
G28 ; Home all axes
M420 S1; Enable Bed Leveling (with saved mesh)
M104 S{material_print_temperature_layer_0} ; Heat the nozzle to the target temperature
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 for nozzle to reach target temperature
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

Where to Find the Start G-Code Section in Cura?

To find the Start G-Code section in Cura, the first step you will need to take is to click Settings (on the menu bar), bring your cursor over Printer, and click the Manage Printers option.

Cura manage printers


With the Manage Printers menu open, select the 3D printer you would like to edit the Start G-Code for from the list on the left and click the Machine Settings button.

Cura machine settings


If the Machine Settings button is not visible, make sure that the 3D printer you’re trying to make the modification for is the currently active printer by clicking the icon on the top right and pressing Activate.

Cura activate printer


Once you have followed all the steps above, you should see the Start G-Code (and End G-Code) input boxes at the bottom of the Machine Settings window.

Conclusion

Now that you know how to get Cura to automatically level the bed before each print using the BLTouch sensor, you won’t have to worry about potentially forgetting to level the bed before a print and enjoy the benefits of automatic bed leveling reliably.

While this is completely optional, getting Cura to handle this process for you is way too convenient to pass up, especially considering that it most likely won’t take more than a minute or two to make the necessary changes.