Posted on

BLTouch on Duet Wifi & RepRapFirmware

The time has come to setup BLTouch on my system.

I’m going to use Duet WiFi + Duex5, but I’ll post details about using it without the Duex as well.

Since I do use Duex5 and because of other considerations explained in this blog-post, I’ve decided upon not following the pin selection most often mentioend other places. I do however try to explain my reasoning and how you can use it to customize your own setup.

Please let me know if you have comments or inputs. I do take all comments as a positve thing, also potential corrections to my writings 🙂

When I feel I have everything I need, I’ll boil down on this post and use it as a “how-to” for both duet3d wiki and


Physical overview

First a short explanation on how a BLTouch sensor works and what it is: The BLTouch sensor is in the category of Servo sensors, meaning it’s using a mechanical servo mechanism to raise and lower the metal pin to do the testing.

Quote from the maker: ANTCLABS(A&T)

  • BLTouch is an auto leveling sensor for 3D Printers based on open-source.
  • Simple, Smart, High-precision
  • It could work with any kinds of bed materials, such as glasses, woods, metals, and so on.

Probe Connector role

At first the Duet Wifi and RepRapFirmware didn’t support servos, but focused on other sensor types like their own IR-sensor.

It means the description on the WiKi can be a bit confusing for us non-electronical centric people as they talk a lot about using the Probe Sensor, which just doesn’t apply fully to the BLTouch Sensor. (To be honest I get more confused by reading this page, so don’t feel bad if you are like me!)

They have added a BLTouch section now though, which helps a lot. Thumbs up! 🙂

It means we can’t just use all the pins from the Probe connector as the sole connection on the Duet WiFi, but only use 2 of these pins in the Probe Connector, GND and IN, to register the actual signal from the BLTouch. We need to use PWM connector for the other 3 pins from the BLTouch.

The Probe Connector is the one to the right in the photo. Placed next to the LCD connector to the left of it.

The red wire is IN and black wire is GND

Note: You might notice the small 480Ω resistor crimped into the connector here. More on this later.

Using expansion PWM port for Servo

The 3 remaining wires from the BLTouch are there to control the Servo Pin inside the BLTouch.

Since we have a Duex board we are going to use 1 of the 5 ports labeled as “PWM” ports on the board itself, but listed as “Shared with servos” on Duex2/5 main features page.

When looking at the Wiring Diagram, the connectors are labeled as “PWM / Servos“.

Physical Connections

Lets start by looking at the 2 wires for the Probe Connector on the Duet Wifi/Ethernet.

2-Pins for Z signal

We are going to connect the 2 wires labeled Z (white) and GND (black) on the BLTouch and connect to the matching pin on Duet WiFi Probe Connector, as shown in the diagram.

Note: Your wires might be colored differently. Especially if you use a counterfit version like 3DTouch.
My version of the BLTouch is an old Classic version.

5v to 3.3v logic level conversion

The BLTouch is as default configuring using 5v logic. It means we have to make sure we set it up to run as 3.3v logic instead. Don’t worry about not grasping what 3.3v logic means, as it’s really not important to know what it is, only how we hook up our sensor.

If you have an old Classic BLTouch (as I do), you need to either solder or crimp in the included 480Ω (ohm) resistor between the 2 wires for the Probe Connector.

I crimped them into my connector. Mine came with a 480Ω and 10kΩ resistor.

I do not know why the 10kΩ was included.. anyone know?

If you have a new version of BLTouch with serial number, you just need to cut the solder away between 2 solder pads, as shown here:

3-Pins for Servo

The 3 left over wires on the BLTouch are GND (brown), Red (5v) and Orange (control signal)

If you do not own a Duex expansions port and instead use the pins on the Duet Wifi, you connect as shown on this diagram:

You can use a different Heater-pin, just make the necessary adjustment in your configurations.

  • GND ( G, Brown) to pin 2 on Duet WiFi
  • 5v (5v, Red) to pin 1 on Duet WiFi
  • Orange (S, Control signal) to pin 31

Some info on the Duet Wiki where they use pin 8 instead of my 31. They are also using different colors than my BLTouch, so be sure to check on your own model!

Note on below wire colors: I did not have any brown (used black) or orange (used white) cables, so go by the labels near the connectors, or remember my choices.

The difference between Pin 8 and Pin 31, is how Pin8 is assigned Heater 3 and Pin31 is assigned Heater 7. I picked the last available, in case I later wanted to actually use Heater 3 as a heater. I’m never going to use 7 heaters, and Heater 7 connector also made for nicer wiring in my case 🙂

Note: It can be confusing how the numbering on PWM# and E# doesn’t follow each other. Reason for this is, how the Heater numbers (E) starts with E0 and E1 located on main Duet WiFi board, while the PWM ports are either starts with PWM1 or PWM0 is somewhere not known to me.

The above diagram is a small part I made out of the full diagram.

Firmware Configuration

It’s time to configure our firmware in order to use the BLTouch sensor we just connected. There is some good information on the Connecting a Z probe – BLTouch on the Duet3d wiki.

Disable heater

As shown in the warning in the above diagram, the PWM channels are shared with the heaters, so we need to disable the relevant heater.

We are using the PWM_5 connector, which is the 7th Heater.

We disable it using the M307 Gcode command and setting A, D and C to -1 in our Heaters section in Config.g file. Setting them to -1 means they are disabled.

M307 H7 A-1 C-1 D-1

Note: change H7 to whatever heater you need to disable according to how you choose to wire it up.

RepRapFirmware 1.16 and later allow the PID controller for a heater to be disabled by setting the A, C and D parameters to -1. This frees up the corresponding heater control pin for use as a general purpose I/O pin.

Set Servo Position

Now we need to configure the position of our Servo Pin, which we do using the M280 Gcode command.

Deploy Probe

In order to do so, we put the following into our deployprobe.g file. If you do not have this file, you just hit New File in the System Editor where all the other config files are located and create it.

Insert the following into the file, where the P-number corresponds to our H-number above.

M280 P7 S10

S10 is the “angle” the PIN is put in to engage. You can read more and also see a table of most of the expansion pins. When dealing with BLTouch the engaged position is at angle 10.

Note: In the Duet wiki it is listed to include a Invert parameter: I1 at the end as well, but mine doesn’t work when used.

Retract Probe

Next we need to configure how we retract the Servo Pin in the BLTouch. These settings are configured in the retractprobe.g file. Create it the same way as before if you don’t have this file.

M280 P7 S90

Once again, the P-number corresponds to our H-number while S defines the “angle” to put the probe into. When dealing with BLTouch the retracted position is at angle 90.

Note: In the Duet wiki it is listed to include a Invert parameter: I1 at the end as well, but mine doesn’t work when used.

Configure Endstop Section

Set Z-Probe type

Now we need to setup the Probe Type to Type 5 in our Endstop section in the config.g file using the M558 command.

P5 (from RepRapFirmware 1.14) selects a switch (normally closed) for bed probing between In and Gnd pins of the Z-probe connector (Duet 0.8.5 and Duet WiFi).

Settings legend/explanation:

Overview of what the different parameters means and do:

  • P# = Mode/Type of probe – P5 is for bed probing between In and Gnd pins of the Z-probe connector.
  • XYZ# = 1 use probe for this axis. 0 do not use probe for this axis
  • H# = Dive Height of the Servo pin. 5mm is normal for BLTouch
  • F# = Feed Rate mm/min
  • T# = Travel speed to and between probe points (mm/min)

It all means that we insert the follow line for our new Z-Probe, defining the Type and usage settings.

M558 P5 X0 Y0 Z1 H5 F120 T6000 ; Set Z Probe to type Switch or Digital output where Z probe connector is used. Used for z only.;

  • Put it in the Endstop section in config.g file:

Set or Report Current Probe status

Next we need to setup how the Probe behaves, using the G31 command.

Settings legend/explanations

  • Z# = Trigger height. 1.5mm is normal for BlTouch
  • P# = Trigger value. 25-100. Lower it if nothing happens.
  • XY# = Placement of probe relative to your nozzle. Called offset. In mm.

It means we set trigger value to 50 (don’t worry if it means nothing to you), define where the probe is placed in realtion to our nozzle and the trigger height of the Probe Pin.

The Z value is the Z-offset. Used to tune the distance between trigger location and nozzle. Higher offset value and you get the nozzle closer to bed.

G31 P50 X-25 Y38 Z1.5; Set Z probe trigger value, offset and trigger height

  • This line is also placed in the Endstop section in the config.g file.
  • Just place it under the above M558 line.

G32: Probe Z and calculate Z plane

The G32 Gcode Command can be used to define 3 or more probe points. I am only using mine as a Z-min endstop with 1 point, so not going to use this feature for now.


Relevant Gcode commands:

4 thoughts on “BLTouch on Duet Wifi & RepRapFirmware

  1. I believe the “S” value in deploy and retract correspond to Servo angles, it’s deployed at 10degrees, and retracted at 90 degrees

    1. Hello Jakob. I don’t understand the Servo Angles in regards to BLTouch. Is it just a deprecated value called angles, that has some other function on BLTouch? Asking as the pin goes straight up and down, so not sure what 10 and 90degrees actually means here?

      1. Not that i am really any kind of expert :). The bltouch emulates a servo type probe , so in order to trick firmwares into thinking it was really a servo this was build into the logic- at least that is the logic i apply to this. So it is likely a legacy, but why change it, as that would likely break the functionality build into any number of firmwares.
        Now i just need to make mine work it doesnt deploy when homing Z. Just installed the duet with the help of your excellent guides, thanks. Only have three issues. Extruder thermistor fails, hotend fan fails(i Think that is hardware fail), and the Said non-deployment of BLT on home(it self tests ok). Oh and the motors whine when idle but i suppose that can be tweaked

      2. Most r/c servos operate on PWM (Pulse Width Modulation). It ranges from 0 to 1520 pwm giving it a 120 degree range. Most servos are centered at 760 and the input from the transmitter tells it to move one way or the other. The bl touch pin is deployed or retracted telling the “servo” to go to 10 degrees (a specified pwm) to deploy and 90 degrees ( a different pwm) to retract. It’s a signal to control it.

Leave a Reply

Your email address will not be published. Required fields are marked *