Bed leveling sensors are much more common now than they were even a couple years ago. Some firmwares are loaded with features that use these sensors to their fullest potential, while others are a bit more hands-on to get usable results. Let’s take a look at what you need to know to set the Z-Offset for your 3D printer using Smoothieware.


Relatively recently, Smoothieware added babystepping to the firmware. Babystepping allows you to adjust the first layer’s Z-offset in the middle of printing, instead of requiring you to restart the print with a new Z-offset. Alternatively, even without any sort of bed sensor you can use babysteps to back off your first layer if you find that you’ve leveled the bed a bit too close or too far from the nozzle and need to make adjustments.

Basic Setup of a Bed Leveling Probe with Smoothieware

Depending on the hardware that you have installed, the hardware setup will be slightly different for every combination. In the case of my printer, I used an Azteeg X5 mini WiFi and a BLTouch, so some information may pertain only to this setup. When setting up the BLTouch on my printer, I plugged the white wire to the (left/middle/right) pin of the “Probe,” the black wire to the (left/middle/right) pin of the “Probe,” the brown wire to pin X, the red wire to pin x, and the orange wire to pin X. With the probe properly installed, I then needed to change the “config” file used in Smoothieware to enable the BLTouch. Smoothieware works a bit differently than other firmware languages and features a plain text file that is used to configure the firmware, rather than needing to reflash the firmware every time you need to make a change.

Changing the Config

To make the BLTouch properly run, I needed to change three things in the config: that there is now a Z probe, how the Z probe works, and which bed leveling algorithm I want to be used.

Enabling the Zprobe

The following needs to be in the “config” file to enable the use of a bed leveling probe (in this case the BLTouch):

probe endstop
probe_pin 1.29 # optional pin for probe

# optional Z probe

zprobe.enable                                true           # set to true to enable a zprobe

zprobe.probe_pin                             1.29          # pin probe is attached to if NC remove the !

zprobe.slow_feedrate                         5             # mm/sec probe feed rate

zprobe.debounce_ms                           2            # set if noisy

zprobe.fast_feedrate                         50            # move feedrate mm/sec

zprobe.probe_height                          10             # how much above bed to start probe

zprobe.dwell_before_probing 0.2 #Dwell time in seconds before probing

How the Zprobe Works

The following needs to be in the “config” file to have the BLTouch working properly:

# Switch module for servo control

switch.servo.enable                            true           # Enable this module

switch.servo.input_on_command    M280 S3   #           M280 S3.0      # M280 S7.5 would be midway

switch.servo.input_off_command    M280 S7   #          M280 S7.0      # Same as M280 S0 0% duty cycle, effectively off

switch.servo.output_pin    2.4   # Must be a PWM capable pin

switch.servo.output_type                       hwpwm          # H/W pwm output settable with S parameter in the input_on_command

switch.servo.pwm_period_ms                     20             # set period to 20ms (50Hz) default is 50Hz

Leveling Strategy

There are multiple options when it comes to leveling strategy: you can have round grids (used for Delta 3D printers), you can have rectangular grids (for most 3D printers), or three-point leveling for 3D printers with extremely flat beds. You can read more about them here, but I use a 5x5 grid for my printer here:

Now, this is all great but still doesn’t enable you to babystep for easier bed leveling. To do that, a newer feature was added to the firmware that, rather than being a workaround to get something like babystepping, is actually true babystepping. If you have an LCD, you can add the following code to give you the ability to babystep, but without one you can instead call out this same code in the terminal of your connected slicer.

leveling-strategy.rectangular-grid.enable true # The strategy must be enabled in the config, as well as the zprobe module.

leveling-strategy.rectangular-grid.x_size 150 # size of bed in the X axis

leveling-strategy.rectangular-grid.y_size 160 # size of bed in the Y axis

leveling-strategy.rectangular-grid.size 5# The size of the grid, for example, 7 causes a 7x7 grid with 49 points.
# Must be an odd number.

leveling-strategy.rectangular-grid.do_home true

leveling-strategy.rectangular-grid.probe_offsets -30,-55,0 # Optional probe offsets from the nozzle or tool head false # If the saved grid is to be loaded on boot then this must be set to true

leveling-strategy.rectangular-grid.initial_height 10 # will move to Z10 before the first probe

mm_per_line_segment 1 # necessary for cartesians using rectangular-grid

Calibration of the New Sensor

Now that you have the foundation laid out, you will need to calibrate this sensor so you don’t ram the nozzle into the bed or start the first layer in mid-air. 

  1. You’ll start by moving your print head over the bed and, in the case of a BL-Touch, deploying the probe. 
  2. Then move the Z-axis so the probe gets closer and closer to the bed until it’s about to trigger. Slide a piece of paper between the bed and the nozzle. Every probe is different, so some will have an LED light up when it’s triggered, others will click or retract a pin.
  3. Through the LCD, manually jog Z-axis by 0.01mm increments until the probe is triggered. The BLTouch will flash at you that it wasn’t able to fully deploy, but don’t worry about it. Write down the Z height at this point.
  4. Once it’s triggered, take the piece of paper that’s between the nozzle and the bed and repeat the process of slowly moving the Z-Axis until you feel some resistance from the nozzle on the paper. You don’t want so much resistance that you have to pull hard, but enough that the paper is pinched between the bed and nozzle and it’s difficult to slide the paper toward the back but still easy to pull it toward you.
  5. Take note of the Z height and subtract it from the previous Z height. This is the rough nozzle offset; the distance between where your probe hits the bed and the nozzle hits the bed.
  6. Record this in the Z-offset of the printer’s settings in the slicer, use a Gcode setting to save it to your printer’s EEPROM, or you can include the Gcode in the Start Gcode of the printer’s slicing profile.
    1. In my case, I include the following as my start Gcode to have it be easily modifiable
    2. M280S10.6 ; Clear Alarm
    3. Z10 ; Z up
    4. M280S3 ; Probe down
    5. G32 ; Bed Calibration
    6. G1 X100 Y90 ; Nozzle Offset Location
    7. G30 Z3.10 ;Set Nozzle Offset
    8. M280S7 ; Retract Probe
    9. G1 Z15 F1500 ; Lift Nozzle

To hone in on the Z-offset that would work best for an optimal first layer, a test print will need to be run.

  1. Start a print of a large cube. We just need to see a large first layer, we aren’t going to let it finish.
  2. Let the bed leveling strategy run to completion and start printing.
  3. Once the skirt is being laid down, pay attention to how squished the first layer is. If it’s too far, scroll through the “Custom” sub menu and click “Babystep Closer” to bring the nozzle closer by however much you specified in the config earlier. If it’s too close select “Babystep Further.”
  4. Be aware of how many times you select either “Further” or “Closer” as there won’t be a display of how far you have moved.
    1. I use increments of 0.02mm with my babystepping, so if I click “Further” 4 times, “Closer” twice, and “Further” once more, then I know I need to subtract 0.6mm to my Z Offset so I don’t have to babystep next time.
      1. (4-2+1)*0.02mm = 0.06mm
  5. Change your Z Offset in your start Gcode so you don’t have to babystep every time you start a print.

The introduction of babystepping into Smoothieware is something that has been desired for a long time now, and with its inclusion using Smoothieware is much more reliable and easier to use. For an in depth look at what steps you might want to take to achieve a perfect first layer for other bed leveling methods, you can check it out here.