Backstory

I set up the BLTouch module as explained in the guide that came with it - that included unplugging the Z axis switch, and replacing it with a pair of wires from the BLTouch module.

I managed to burn the firmware available from Creality, however this didn't have an offset for the fact the BLTouch module is offset from the hotend, and I couldn't manually edit the .hex file to add in offsets. I tried using the G Code command to update it on the EEPROM, but that didn't work and it always probed off the edge of the bed.

I then decided to flash new firmware based directly off Marlin 1.1.x, as there are some videos on Youtube about how to do this. I used the pink USB ISP supplied with the BLTouch to flash the Arduino bootloader to the motherboard, and now I can use the Arduino IDE to program the board.

I uploaded my configured Marlin firmware (see below), but it isn't working properly.

Problem

When I home the printer, the X and Y stops go to the switches, bump and zero correctly. However, when the Z axis is homing, the BLTouch probe stays retracted, and it starts heading for home - I forcefully shut down my printer when this happens because I know there's nothing to stop it from crashing into the print head and breaking things.

How do I configure my firmware to use the BLTouch module as the Z stop probe?

Although the probe clicks in and out a few times when I power on the printer, I'm not entirely sure that it is even working - going to the BLTouch menu and choosing Cmd: Deploy doesn't have an effect.

On the up side, when it goes to the centre to home (due to Z_SAFE_HOMING), the BLTouch module is over the centre of the build plate instead of the hotend.

Configuration

You can see the Marlin repository I'm trying to use here on Gitlab, or a direct link to the diff between the inital Marlin configuration and my changes.

These are some hopefully relevant configuration changes I've made:

// Configuration.h

//#define USE_XMIN_PLUG
//#define USE_YMIN_PLUG
#define USE_ZMIN_PLUG
#define USE_XMAX_PLUG
#define USE_YMAX_PLUG

#define BLTOUCH

#define X_PROBE_OFFSET_FROM_EXTRUDER -44  // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER -6   // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER 5.7  // Z offset: -below +above  [the nozzle]

#define Z_HOMING_HEIGHT 4

#define Z_SAFE_HOMING

// pins_MELZI_CREALITY.h

#define SERVO0_PIN 20 // Wondering if this is correct?


These settings have been left as default, but they look relevant maybe:

/**
* Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
*
* Enable this option for a probe connected to the Z Min endstop pin.
*/
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

/**
* Z_MIN_PROBE_ENDSTOP
*
* Enable this option for a probe connected to any pin except Z-Min.
* (By default Marlin assumes the Z-Max endstop pin.)
* To use a custom Z Probe pin, set Z_MIN_PROBE_PIN below.
*
*  - The simplest option is to use a free endstop connector.
*  - Use 5V for powered (usually inductive) sensors.
*
*  - RAMPS 1.3/1.4 boards may use the 5V, GND, and Aux4->D32 pin:
*    - For simple switches connect...
*      - normally-closed switches to GND and D32.
*      - normally-open switches to 5V and D32.
*
* WARNING: Setting the wrong pin may have unexpected and potentially
* disastrous consequences. Use with caution and do your homework.
*
*/
//#define Z_MIN_PROBE_ENDSTOP

/**
* Number of servos
*
* For some servo-related options NUM_SERVOS will be set automatically.
* Set this manually if there are extra servos needing manual control.
* Leave undefined or set to 0 to entirely disable the servo subsystem.
*/
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command

• There are 5 wires (of which 2 ground) if you have 2 wires (black/white) on the Z-endstop, where are the orange, red and brown connected. The latter are essential for the servo function, these should be connected correctly and configured correctly in firmware. What controller board do you have (and version) and which pins are you using, adding photos might help.
– 0scar
Sep 10, 2021 at 12:29
• @0scar You were on the right track! I was way out of my depth and ended up setting SERVO0_PIN to the ZMIN pin and not what it should have been according to the breakout board. Sadly there's basically no documentation from Creality, presumably because they want you to use their own pre-compiled hex files. All's well that ends well! Sep 10, 2021 at 13:19
• Glad to help, the servo pin depends on the board, hence not posting an answer, great to see you posting your own answer!
– 0scar
Sep 10, 2021 at 13:54

I've solved this now. Here's the problem:

// pins_MELZI_CREALITY.h
#define SERVO0_PIN 20 // Wondering if this is correct?

Funnily enough, it wasn't correct. Pin 20 is the Z MIN pin, as defined in pins_MELZI_CREALITY.h, and not the servo pin used by the BLTouch module.

At 8:04 of this youtube video, he says that that value should be set to 27, "if we're using a pin 27 board or splicing pin".

I tried it, and the BLTouch module now responds, and homing works!

For anyone else who comes across this problem (it's strangely very hard to find online), add the following code:

#define BLTOUCH
#if ENABLED(BLTOUCH)
#define SERVO0_PIN 27
//#define BLTOUCH_DELAY 375   // (ms) Enable and increase if needed
#endif