Install BDsensor
Connect the sensor cable to the motherboard or CAN bus toolhead board.
- Please note that SB2040 cannot use BDsensor
- Please note that SHT36 requires connecting BDsensor's CLK/SCL (Input) to a high-voltage input port and the jumper should be connected.
- BDsensor's CLK and SDA lines can be connected to any GPIO pin on the board. You can also directly connect the BD sensor cable to the BLtouch port, for example:
BLtouch | BDsensor
5V --> 5V
GND --> GND
S --> CLK/SCL (Input)
GND --> GND
Zmin --> SDA (Input/Output)
-
Some pins on the motherboard connector may not be directly connected to the MCU's gpios (e.g., they may have filter capacitors or be isolated via MOSFETs, diodes, or optocouplers, but if they are isolated via resistors or resistor pull-up/down, they also may not work), thus they cannot be used with BDsensor. The firmware will report a connection error. For example:
-
Fan and heater connectors are isolated through MOSFETs,
-
In some boards, connectors used for temperature thermistors and endstops/probes are typically connected to GND through filter capacitors,
-
Install the BD sensor near the hotend as shown in the image below. STL of mount, STL_mount_VzBot_Goliath short

Install the patch into the klipper firmware
-
Discard any previous modifications to klipper files and update klipper
cd
cd ~/klipper
git checkout .
git pull -
Clone the latest BD sensor code
cd && git clone https://github.com/markniu/Bed_Distance_sensor.git -
Install
cd ~/Bed_Distance_sensor/klipper/
./install_BDsensor.sh -
Compile the firmware
cd ~/klipper/
make menuconfig
make clean
make -
Flash the firmware to the MCU or CANbus toolhead board connected to the BD sensor
If your printer runs Moonraker, add the following section to moonraker.conf, then you can update BDsensor with one click via the web interface or KlipperScreen.
[update_manager BDsensor]
type: git_repo
primary_branch: new
channel: dev
path: ~/Bed_Distance_sensor
origin: https://github.com/markniu/Bed_Distance_sensor.git
install_script: ./klipper/install_BDsensor.sh
is_system_service: False
managed_services: klipper
info_tags:
desc=Bed Distance Sensor
Edit printer.cfg
-
Copy this section into your printer.cfg and edit the
sda_pinandscl_pinin[BDsensor]. Also, don't forget to disable other probe sections, such as BLtouch. You can connect the BD sensor to either the motherboard or the toolhead CAN module. -
Change
speedin[BDsensor]to 0.8. This is only applicable for z tilt and PROBE_ACCURACY commands. The smaller the value, the higher the accuracy during probing because the MCU reads the BD sensor in the main loop during homing not as real-time as a normal endstop.[BDsensor] -
To use the BD sensor as an endstop during Z-axis homing, change the
endstop_pinin[stepper_z]toendstop_pin: probe:z_virtual_endstop -
Make sure there is
[safe_z_home]in your printer.cfg -
Change the value in
[bed_mesh]and[z_tilt]or[quad_gantry_level]to 1 (recommended 0.7-1.0mm). The default value in klipper is 5mm, otherwise it can easily exceed the sensor range. -
The nozzle height is only suitable to be set in
z_adjust:. Positive values bring the nozzle closer to the bed, negative values move it away. Other settings to adjust nozzle height may have bugs -
Remove the # before
no_stop_probe:trueto enable fast bed scanning -
Below is a configuration example.
[BDsensor]
scl_pin:PC6 # Servo signal pin
sda_pin:PC3 # Endstop signal pin
delay: 20 # 20us per pulse, this value should be >=20 but must be below 50
z_offset:0 # this `z_offset` must be set to 0.
z_adjust:0.0 # z axis adjustment, replace the z_offset function. within -0.3 to 0.3mm
x_offset: -34
y_offset: 0
#no_stop_probe:true # enable this for fast probe, the toolhead will not stop at the probe point.
position_endstop: 0.8 # the Z axis will stop at this position (mm) while homing z, recommend value is 0.4~1.0
#speed:0.8 # this speed only works for the z tilt and PROBE_ACCURACY command.
[stepper_z]
endstop_pin: probe:z_virtual_endstop
#position_endstop: 0.5
homing_speed: 5
second_homing_speed: 0.8
[bed_mesh]
speed: 200
horizontal_move_z:1
algorithm: bicubic
[quad_gantry_level]
horizontal_move_z:1
After installation, please check it by sending the following gcode commands
M102 S-1 # Read sensor information
M102 S-2 # Read one distance value
Check connections
-
Send
M102 S-1via console, this is an example of the returned message. If it returns blank or other strings, please check the connections and wire order.Send: M102 S-1
Recv: V1.0 pandapi3d.com
Calibration
- Clean the nozzle, then manually move the Z-axis via the console until the nozzle just touches the bed (the BDsensor will use this position as the zero position, so no
z_offsetis needed, which is why the value is 0 in the [BDsensor] section). - Send the gcode command
M102 S-6via the console, the printer will slowly move the Z-axis upward by 0.1mm each time until it reaches 4mm. Do not run M102 S-6 before installing the sensor, nor power off the printer during calibration, otherwise the old calibration data will be deleted. If this happens, simply recalibrate. - Afterwards, you can check if the BD sensor has been successfully calibrated via
M102 S-5, which will return the stored raw calibration data from the BD sensor.
Notes:
-
The Z-axis homing speed is best set to 5
-
If the first raw calibration data returned by M102 S-5 is greater than 400, it means the sensor is installed too high and needs to be reinstalled closer to the bed. The recommended value for the first data is 100. Also ensure the second data value is at least 10 more than the first.
-
FAQ: If the calibration data starts with 1, the second value is 9, and the third is 24, what does this mean?
-
This means the resolution between 0-0.1mm is only 9, and between 0.1-0.2mm the resolution is 15. Therefore, it is recommended to recalibrate and ensure the first resolution (0-0.1mm) is greater than 10.
-
-
Don't forget to adjust the Z-axis height after running G28 or for these commands
Z_tiltandquad_gantry_level -
The section names must be correctly capitalized or klipper will report
Unknown pin chip name 'probe'