Installing BDsensor-m-m
Connect the sensor cable to the EXP1 port of the mainboard
- If the sensor cable length is insufficient, you can use the extension cable included in the package.
- The CLK and SDA wires of the BDsensor-m-m can be connected to any GPIO pins on the board. You can also connect the BD sensor cable directly to the BLtouch port, for example:
BLtouch | BDsensor-m
5V --> 5V
GND --> GND
S --> CLK/SCL (Input)
GND --> GND
Zmin --> SDA (Input/Output)
-
Some pins in the mainboard connectors may not be directly connected to the MCU's GPIOs (e.g., they might have filtering capacitors or be isolated via MOSFETs, diodes, or optocouplers, though they can be used if isolated via resistors or pull-up/down resistors). Therefore, they cannot be used with the BDsensor-m, and the firmware will report a connection error. For example:
-
Fan and heater connectors are isolated via MOSFETs.
-
Connectors for temperature thermistors and endstops/probes on some boards are often connected to GND through filtering capacitors.
-
Install the BD sensor near the hotend as shown in the image below. STL of mount, STL_mount_VzBot_Goliath short
Loading...
Apply the patch to the Marlin firmware
The BD sensor is integrated into Marlin 2.1.x (since 2022.8.27).
You can download the release version. However, it is now recommended to download the latest bugfix version: https://github.com/MarlinFirmware/Marlin
You need to modify the configuration files and pin files.
Edit Configuration.h
-
Enable BD_SENSOR
Uncomment:
#define BD_SENSOR
#define Z_SAFE_HOMING
#define BD_SENSOR_PROBE_NO_STOP // Adding this new line for fast bed leveling without nozzle stop.Only
BD_SENSOR_PROBE_NO_STOPis new.Latest Marlin bugfix: https://github.com/MarlinFirmware/Marlin
Description: https://github.com/MarlinFirmware/Marlin/pull/25847
-
Use the probe for homing
Ensure
Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PINis disabled, andUSE_PROBE_FOR_Z_HOMINGshould be enabled as shown below://#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
// Force the use of the probe for Z-axis homing
#define USE_PROBE_FOR_Z_HOMING -
Slow down the second homing Z speed
#define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 16)Here, we must slow down the bump homing speed and Z homing speed because the endstop readings from the BDsensor-m process are not as real-time as a normal endstop.
Edit Configuration_adv.h
Enable #define BABYSTEPPING for real-time leveling functionality.
#define HOMING_BUMP_DIVISOR { 2, 2, 8 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
Edit pins_boardname.h
Configure the pins for the BDsensor-m's SDA and SCL in the pin file pins_boardname.h (e.g., pins_PANDA_PI_V29.h) by adding the following 3 lines:
#define I2C_BD_SDA_PIN PC6 // Please change to the actual pin number to which the SDA wire is connected on your mainboard
#define I2C_BD_SCL_PIN PB2 // Please change to the actual pin number to which the CLK wire is connected on your mainboard
#define I2C_BD_DELAY 20 // Default value is 20, should be in the range [20,50].
If you want to perform automatic bed leveling probing (G29) before printing, like a normal BLtouch, uncomment:
#define AUTO_BED_LEVELING_BILINEAR
And edit the values as shown below:
#define Z_CLEARANCE_DEPLOY_PROBE 0 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 1 // Z Clearance between probe points
#define Z_CLEARANCE_MULTI_PROBE 1 // Z Clearance between multiple probes
Display BD sensor value on the LCD
- For printers with a status display (supporting G-code M117), such as LCD12864 or some UART screens like the Ender-3 V2...
Calibration
-
Clean the nozzle, then move the Z-axis via the console until the nozzle just touches the bed (the BDsensor-m will use this position as the zero point, so no z_offset is needed; we set the value to 0).
-
Send the G-code command
M102 S-6. The printer will slowly move the Z-axis up by 0.1mm each time until it reaches 4mm. Do not run M102 S-6 before installing the sensor, and do not power off the printer during calibration, or the old calibration data will be deleted. If this happens, simply calibrate again. -
You can send
M102 S-5to check if the BD sensor has been successfully calibrated. This will return the raw calibration data stored in the BD sensor.
There is also a calibration tool for this: https://github.com/markniu/Bed_Distance_sensor/raw/new/marlin/BD_Config_Tool_Marlin.zip 
Note: A data value of 1015 or >1010 indicates the sensor is out of range. If the first 5 points (0~0.5mm) or more values are within the range of 0 to 1000, and the increasing value delta is >=10, it indicates successful calibration, as shown in the chart above.
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. Also, ensure the second data value is at least 10 greater than the first.
Testing and Printing
Menu: Bed Level
Auto Bed Leveling
There are two methods for automatic bed leveling:
1. Use M102 for real-time leveling of the first few layers
We can easily enable or disable this auto-leveling by sending G-code commands or adding G-code to the G-code file.
To enable bed leveling in Cura, add the M102 G-code right below the G28 (Home All Axes) G-code in the "Start G-code" section of the printer machine settings. For example, M102 S2 below G28 means it will only perform bed leveling when the Z-axis height is below 0.2mm.
Sending M102 S0 or G28 will disable bed leveling using the BD sensor. By the way, it is disabled by default.
M102 S-1 // Read sensor information, and we can use this for connection checking.
M102 S-2 // Read current distance value
M102 S-5 // Read raw Calibration data
M102 S-6 // Start Calibration. Before that, make sure the nozzle is just touching the bed, and then the printer restarted. Do not home the Z-axis before this.
M102 S4 // Set the adjustable Z height value, e.g., M102 S4 means it will do adjusting while the Z height <=0.4mm. Disable it with M102 S0.
2. G29 automatic bed leveling
Another method for automatic bed leveling is like BLtouch's G29. Simply add a G29 line below G28.
Chris's Basement Installation Video
Check Z endstop with M119
Do not home Z before checking this step, or the nozzle might crash into the print bed.
This is the return message after sending the M119 command (report endstop status).
Send: M119
Recv: x:open y:open z:open
If z min is not open, check your configuration for #define Z_MAX_ENDSTOP_HIT_STATE HIGH.
- Ensure the Z motor is off/unlocked.
- Manually move the Z-axis down until the nozzle touches the bed.
- Send
M102 S-2. The return value should be 0.00mm. Then send M119 again, and you should see the z endstop is now triggered.
Send: M119
Recv: x:open y:open z:TRIGGERED
Check connection
Check the connection via M102 S-1. Here is an example of the return message. Please check if the connection and wire order return a blank or other strings.
Send: M102 S-1
Recv: V1.0 pandapi3d.com