<p>I've solved this now.  Here's the problem:</p>
<blockquote><pre>// pins_MELZI_CREALITY.h
<p>#define SERVO0_PIN 20 // Wondering if this is correct?</pre></blockquote></p>
<p>Funnily enough, it wasn't correct.  Pin 20 is the <code>Z MIN</code> pin, as defined in <code>pins_MELZI_CREALITY.h</code>, and <strong>not</strong> the servo pin used by the BLTouch module.</p>
<p>At 8:04 of <a href="https://youtu.be/iAz47riSjLQ?t=484" rel="nofollow noreferrer">this youtube video</a>, he says that that value should be set to 27, &quot;if we're using a pin 27 board or splicing pin&quot;.</p>
<p>I tried it, and the BLTouch module now responds, and homing works!</p>
<p>For anyone else who comes across this problem (it's strangely very hard to find online), add the following code:</p>
<pre><code>#define BLTOUCH
#if ENABLED(BLTOUCH)
  #define SERVO0_PIN 27
  //#define BLTOUCH_DELAY 375   // (ms) Enable and increase if needed
#endif
</code></pre>

CC BY-SA 4.0
2021-09-10T13:51:11.340Z
Many thanks for posting your solution! Pleas accept after 48 hours to minimize the list of unanswered/unaccepted questions. Now work your way through https://3dprinting.stackexchange.com/questions/16604/automatic-bed-leveling-abl-with-a-sensor-bltouch-inductive-capacitive-how and enjoy printing (you still need to provide a bed as level, or trammed, as possible)! :-) Nice video: https://www.youtube.com/watch?v=zSOVAdKw4ss
0scar
CC BY-SA 4.0
2021-09-10T13:18:24.190Z
2021-09-10T13:18:24.190Z
user-596a6526
<h1>Backstory</h1>
<p>I set up the BLTouch module as explained in the guide that came with it - <strong>that included unplugging the Z axis switch, and replacing it with a pair of wires from the BLTouch module</strong>.</p>
<p>I managed to burn the <a href="https://drive.google.com/file/d/1EASLRH4rlZs4AiR2EwQ1NizWgKa2lbBa/view" rel="nofollow noreferrer">firmware available from Creality</a>, 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 <code>.hex</code> 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.</p>
<p>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.</p>
<p>I uploaded my configured Marlin firmware (see below), but it isn't working properly.</p>
<h1>Problem</h1>
<p>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.</p>
<p><strong>How do I configure my firmware to use the BLTouch module as the Z stop probe?</strong></p>
<p>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 <code>Cmd: Deploy</code> doesn't have an effect.</p>
<p>On the up side, when it goes to the centre to home (due to <code>Z_SAFE_HOMING</code>), the BLTouch module is over the centre of the build plate instead of the hotend.</p>
<hr />
<h2>Configuration</h2>
<p>You can see the Marlin repository I'm trying to use <a href="https://gitlab.com/marcellothearcane/ender-5-marlin-1.1.x-firmware" rel="nofollow noreferrer">here on Gitlab</a>, or <a href="https://gitlab.com/marcellothearcane/ender-5-marlin-1.1.x-firmware/-/compare/acfbdfb817605f58c9bd13b24c2b2149ef5d9e8b...master?from_project_id=29512087" rel="nofollow noreferrer">a direct link to the diff</a> between the inital Marlin configuration and my changes.</p>
<p>These are some hopefully relevant configuration changes I've made:</p>
<pre><code>// 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
</code></pre>
<pre><code>// pins_MELZI_CREALITY.h

#define SERVO0_PIN 20 // Wondering if this is correct?
</code></pre>
<p>These settings have been left as default, but they look relevant maybe:</p>
<pre><code>/**
 * 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-&gt;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
</code></pre>

CC BY-SA 4.0
2021-09-10T12:29:40.020Z
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
CC BY-SA 4.0
2021-09-10T13:19:51.553Z
@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!
user-596a6526
CC BY-SA 4.0
2021-09-10T13:54:41.897Z
Glad to help, the servo pin depends on the board, hence not posting an answer, great to see you posting your own answer!
0scar
<marlin><bltouch><creality-ender-5>
How to make Ender 5 use BLTouch probe for Z homing?
user-596a6526
# How to make Ender 5 use BLTouch probe for Z homing?

(Asked by: username_0 on 2021-09-10)

# 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](https://drive.google.com/file/d/1EASLRH4rlZs4AiR2EwQ1NizWgKa2lbBa/view), 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](https://gitlab.com/marcellothearcane/ender-5-marlin-1.1.x-firmware), or [a direct link to the diff](https://gitlab.com/marcellothearcane/ender-5-marlin-1.1.x-firmware/-/compare/acfbdfb817605f58c9bd13b24c2b2149ef5d9e8b...master?from_project_id=29512087) 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

```

**Tags:** marlin, bltouch, creality-ender-5

> **Comments:**
> **username_1**: 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.  
> **username_0**: @username_1 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!  
> **username_1**: Glad to help, the servo pin depends on the board, hence not posting an answer, great to see you posting your own answer!  

---

## 1 answers

### Answer by username_0 on 2021-09-10. Score: 2 | Accepted answer

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](https://youtu.be/iAz47riSjLQ?t=484), 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

```

> **Comments:**
> **username_1**: Many thanks for posting your solution! Pleas accept after 48 hours to minimize the list of unanswered/unaccepted questions. Now work your way through https://3dprinting.stackexchange.com/questions/16604/automatic-bed-leveling-abl-with-a-sensor-bltouch-inductive-capacitive-how and enjoy printing (you still need to provide a bed as level, or trammed, as possible)! :-) Nice video: https://www.youtube.com/watch?v=zSOVAdKw4ss  

---

