Bed auto leveling for 3D Printers

Spread the love

Are you tired of re-calibrating the endstop on the Z axis? Or tightening the screws on the bed every day? See how to install the bed auto leveling system using an servo motor and an endstop

What is the bed auto leveling feature?

This feature will use a sensor to measure the distance between the nozzle and the bed, on 3 or more points (up to 32), assuring you the perfect bed leveling and adehesion. See this video to understand how it can be useful!

RepRap Bed Auto Leveling by Alex Borro

Why my bed wont stay leved forever?

This is a pretty common issue, caused by a lot of variables, like the room temperature, the hotbed temperature, nozzle temperature (all the three causes dilation), humidity, and mostly the structure (like plywood, acrylic and aluminium/other metals), found on Prusa’s and derivated from it.

But don’t worry anymore, now yuo will learn how to implement a Bed auto leveling. This will save you a LOT of time, and also help to make better prints.  The Autoleveling works by measuring the distance from the nozzle to the bed, in the four corners (or more if we want to!),


firmware modifications are DANGEROUS!, make sure that you have some backups of your working firmware before you begin! (trust me, always have a well-documented backup, so you know which one to use if something goes wrong).  After updating your firmare MAKE SURE to keep an eye on the 3d printer,  things can go really bad if you mess with some setting you should not.

So lets begin! Here are some things that we will need:
1 – A Already working 3D printer (we will need to print a support)
2 – 1x 9g servo motor , 1X Jumper (computer jumpers are great)
3 – Cable to connect the servo and the micro to the board (you will need to make one)
4 – A computer with arduino IDE v1.0.6 (version 1.5+ don’t work, more info on the last page)
5 – Marlin firmware v1.0.x pre-configured (newer versions didn’t worked, more info on the last page)
6 – Write your firmware settings (feedrate, acceleration, step/mm and board type. LCD name is also important to write if you have one)

FILES / Links

Recommended links for supports:
-Model1: Support 1
-Model2:Support 2
-Model3: Support 3

Arduino IDE v1.0.6 with u8glib (ZIP) and Marlin firmware pre-configured (ZIP)

Before everything, click on HOME ALL and make sure that your nozzle is INSIDE the bed limits.

imagem 1

Select move X + to move it to the right and do it until the nozzle is at the edge of the printing area. Do the same for Y. For the Z axis, move it as high as its possible and mark those values


X Max distance = ?
Y Max distance = ?
Z Max distance = ?

After you print the servo support, and before disassembling the printer check if your servo and micro switch works and fit on the support nicely. And if it does, find a place to put the support, it should be as close as possible to the nozzle.
After checking this and test, we will mount the servo support, the servo, and the endstop on the end. Make sure you leave enough wire to the endstop move free,

Installing the Servo motor

Here is a image to help you with the SERVO connector

Usually the pins are


Let’s begin to modify the RAMPS. Here are where you will connect things
YELLOW = Servo motor (negative , positive, signal)
BLUE = the reset switch (only for demonstration)
RED = The pins that you need to jumper. (Here you jumper the 5V and the VCC pins. The mid and bottom pins) – This will provide power to the servo


After connecting them, connect the probe endstop (which was the Z endstop), to the min z endstop (exactly where it was before)

Configuring the OFFSET

Hardware mounted. now we need to check the offset from the hot end to the probe center.

We will use this method included inside a read-me file
a) Make a small mark in the bed with a marker/felt-tip pen.

b) Place the hotend tip as exactly as possible on the mark, touching the bed. Raise the hotend 0.1mm (a regular paper thickness) and zero all axis (G92 X0 Y0 Z0);

d) Raise the hotend 10mm (or more) for probe clearance, lower the Z probe (Z-Endstop) with M401 and place it just on that mark by moving X, Y and Z;

e) Lower the Z in 0.1mm steps, with the probe always touching the mark (it may be necessary to adjust X and Y as well) until you hear the “click” meaning the mechanical endstop was trigged. You can confirm with M119;

f) Now you have the probe in the same place as your hotend tip was before. Perform a M114 and write down the values, for example: X:24.3 Y:-31.4 Z:5.1;

g) You can raise the z probe with M402 command;

Now, open the pre-configured firmware that we provided you on the arduino IDE. Open the configuration.h file. And use control + F to easily find those lines

h) Fill the defines bellow multiplying the values by “-1” (just change the signal)




Configuring the probing positions

The following options define the probing positions. These are good starting values I recommend to keep a better clearance from borders in the first run and then make the probes as close as possible to borders:





REMINDER: the values must be bigger than the offset!. Example, when the X axis on 0mm, the nozzle is also on 0, but the probe will be at 20. So those values must be inside the range that the printer can measure.

A few more options:
* #define XY_TRAVEL_SPEED 2000
X and Y axis travel speed between probes, in mm/min.
Bear in mind that really fast moves may render step skipping. 6000 mm/min (100mm/s) is a good value.


The Z axis is lifted when traveling to the first probe point by Z_RAISE_BEFORE_PROBING value
and then lifted when traveling from first to second and second to third point by Z_RAISE_BETWEEN_PROBINGS.
REMINDER: the raise before probing must be GREATER than the Z offset. if it the offset is 20mm, add 10mm, so 30mm is a good value to use.
All values are in mm as usual.

We will now configure the software. If you use REPETIER HOST or another, you need to find where the “before printing” or “starting script” is and add this two lines

  • G28
  • G29

The G28 means, go home printer!, it will make the printer find the home position of everything. Than, after that, the G29 will tell the printer to auto calibrate itself,


Now, if everything was properly configured. You must try printing something. I recommend printing a cube, with a four lines skirt at 20mm of distance, this way you will see if the auto calibration works.


Why I must use the provided firmware? I don’t like it!.
-this firmware had been tested and worked perfectly. Although its old, it doesn’t means that it is bad. This is a really good firmware!.

Why I need to use the provided arduino IDE?
-From version 1.5.x the WIRE library is not at the same place, making it really hard to make the firmware works. So, is best to use the 1.0.6 version if you are not a advanced programmer.

What are those G-codes?
M401 = Lower the servo probe
M402 = Retract the servo probe
G28 = Home on X, Y, Z
G29 = Auto leveling feature

If you have any question please feel free to ask! Also See My Auto Nozzle Clean post click here!

Comments 3

Leave a Reply