3DTouch is an automatic leveling system for 3D printers that can measure the inclinations or variations of the printing surface in a precise and simple way.


It is compatible with any type of surface: glass, metal, etc. since, unlike other systems, it works by contact, which is a great advantage over other capacitive, inductive and other sensors.


This device has a probe that collects the position data different points of the printing surface, so that it can calculate the deviations and correct it during printing.


In this post we will explain each step necessary to configure the sensor using Marlin and Ramps board. Mention that there are multiple options for the configuration of this sensor, we will explain what we are using and consider most useful.



Main functions:

  • It works as if it were composed of an RC servo and a micro switch.
  • Small, lightweight and easy to assemble.
  • Self-test when turned on: the pin acts twice, so that if there is something that prevents the free movement of the probe, a flashing red light will be displayed.
  • LED alarm: if it finds a problem during its operation the light will flash.
  • High precision, 0.005mm.
  • Great versatility in the sampling configuration.




Depending on each extruder, it can be mounted using different parts that adapt it, but it must always be installed perpendicular to the surface.

In a correct assembly, the height of the contracted probe should be about 2mm above the height of the nozzle.

If you are going to assemble in our P3steel of an extruder, you can use this piece that adapts it shared in thingiverse.com:






It is important to test the sensor well before homing or leveling the platform. Incorrect placement or installation can damage the printer.



Electronic connections

3DTouch has two connections, one corresponds to the limit switch function of Z and the other to the self-leveling function.

To make the connections, just for each cable or line we have to prepare the cable with the supplied dupont connector.


The connection in the Ramps is the following:

As we can see, the black and white cable (signal) is connected in the position of the limit switch of Zmin.

The other cable is connected in the Servo position, with the order of the scheme (Signal, 5V, Ground). In addition, you have to place a jumper to reach the 5V.



Modifications Marlin Firmware

We have to upload the firmware again with the configuration for our 3DTouch.

To configure the sensor we must modify Marlin Configuration.h:


Ensure that the Zmin endstop is enabled:





Enable the line that assigns the sensor PIN of the limit switch Zmin to the 3DTouch sensor, in this way the sensor will also be the limit switch Zmin:





Now we start with the 3DTouch configuration. We will put the lines that we recommend to activate with the values that we recommend as an example or starting point, depending on the printer that is installed, you may need other values, these are only reference values:

We enable the BLTouch sensor (equivalent to 3DTouch):


#define BLTOUCH



In this line we choose the time it will last to take the reading since the probe is out, we have set 50 milliseconds. If the sensor becomes dirty or stops working properly, we can modify this value:


#define BLTOUCH_DELAY 50   // (ms) Enable and increase if needed



Lines to place our 3Dtouch regarding our nozzle:


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


In this example case, the sensor will be 22mm to the right of the nozzle, for each printer model it will be different.



In the following lines we assign how much we want the probe to contract depending on when it is performing the sampling:


#define Z_CLEARANCE_DEPLOY_PROBE   9 // Distance in mm that the probe deploys or stows in a first sampling
#define Z_CLEARANCE_BETWEEN_PROBES  6 // Distance in mm that the probe deploys or stows between different sampling points
#define Z_CLEARANCE_MULTI_PROBE     3 // Distance in mm that deploys or stows the probe in different measurements from the same sampling point (when enabled)
#define Z_AFTER_PROBING           5 // Distance in mm in which the probe remains with respect to the printing surface after sampling



We choose the type of sampling we want: Bilinear:





We choose the number of points we want for sampling, in this case 9:





In these lines, we set the limits for sampling, so that you do not make the measurement on the outside of the printing surface, where you can find, for example, clamps that hold the glass:




To make Z Safe Home, which is, checking the position 0 of the Z axis in the center of the printing surface, we must enable the following lines:


#define Z_SAFE_HOMING 

#define Z_SAFE_HOMING_X_POINT ((X_MIN_POS + X_MAX_POS) / 2) // X point for Z homing when homing all axis (G28). 
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28). 



Optionally, we can enable a fast function for Babystepping or Z Offset. By enabling this line, we can access this function by pressing twice on the LCD potentiometer. We see it in Configuration_adv.h:


#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z



Add in gcode


We have to add certain commands to our gcodes to execute the leveling correctly:


G28 ; global home
G29; platforma leveling
G1 Z5 F5000 ; lift nozzle
G1 X-10 Y100 Z3 F5000; avoid clamps or clips


With these codes, you will perform a Home and perform self-leveling before you start printing.


For more information about these codes visit:







Checking the Z offset


Once you start printing, we should see if the height of the nozzle with respect to the bed is correct.

If it is not, we must adjust the offsetin Z.


To do this, by pressing twice the potentiometer of the LCD, if we have activated this function, we enter the option of Z Offset, there we adjust the offset. And once the printing is finished we must Save in memory.