Autolevel for the A8 Anet 3D Printer

With autolevel your printer will scan the surface of your heatbed and adjust the Z-axis offset according to the position. Therefore you will not need to adjust the heatbed any more. You will need the following:

  1. Distance sensor
  2. Connector(JST XHP-3)
  3. Sensor support (normally printed by yourself)
  4. Firmware
  5. Slicer settings

A good combination is highlighted in bold.

The sensor will replace your Z axis switch. There are many sensor types available here an overview selection of some possibilities. The cost is only approximate and for information only. There is information missing, so if you have any knowledge please add it (this is a WIKI!).

A video comparison of the different types can be found here

Sensor name Type glass bedDistancecommentcostlinkvoltageocsig*
ROKO SN04-NNPNno<3mmthe “official” Anet sensor4-15USD10-30V(5V)no
TRONYX XY-08NNPNno8mmWith Support12USD6-38V(5V)no
LJ18A3-8-Z/BX NPN inductive no8mm with connector3USD 6-36V(5V)no3.2µm
LJ18A3-8-Z/BX-5V NPN inductive no8mm 6USD 5Vno3.0µm
LJC18A3-H-Z/BX NPN capacitiveyes1-10mm5USD6-36V0.6µ[email protected]°C [email protected]°C
LJ12A3-4-Z/BXNPN Inductiveno4mm 2USD6-36V
LJ12A3-4-Z/BX-5VNPN Inductiveno4mm 3USD 5V
Pibot Optical

If (5V) is mentioned on the sensor, it has been tested that it works on the 5V provided by the Z-switch connector, but officially it need a higher voltage therefore it might not work reliably. See “wiring chapter” to connect it to the 12V power supply.

*)The standard deviation obtained according to the testing_repeatability_of_the_probe chapter

capacitive sensors vs inductive

  • inductive sensors are using magnetic fields for the detection. They can only detect metal. It can detect the metal under the glass, if the range of the sensor is high enough. But if the metal is deformed beneath the glass the printer will try to compensate a non-existing deformation. Also while using Inductive sensors, the detection range needs to be adjusted according to the metal which the sensor senses. They are designed for sensing Iron based metals. So for other metals, the sensing distance needs to be derated. A rough multiplier for sensing distances for various metals are given in brackets - Steel (1.0), Stainless Steel (0.6 - 1.0), Aluminum (0.30 - 0.45), Brass (0.35 - 0.50), Copper (0.25 - 0.45). For eg: if an 8mm Inductive sensor is used to sense Aluminum, the sensing distance is actually between 2.4mm and 3.6mm. So it would be best to test the sensing distance with the sensor you purchased before installation, especially while using 4mm sensors along with a glass build plate.
  • capacitive sensors are using electrical fields for the detection. They can detect many materials including glass. They have a little screw to adjust the field to fit your needs and your material. The drawback of capacitive sensing is that it is affected by temperature and humidity.

Therefore a general recommendation could be: inductive for metal, capacitive for glass

Read more at:

open collector(oc) & and internal pull up resistor

First of all, why do we need a NPN for the Anet-board? The input on the Anet-board is low-active. That means it is held high at 5v with an internal pullup-resistor and is actively switched down to 0V. That is what a NPN-Sensor does.

If you get an open collector sensor you will have an easier wiring. To know if it is a open collector connect the powersupply (12V) to the brown(+) and blue(-) wire. Then take a multimeter and check the voltage between black and blue. If there is none you have an open collector sensor, which can be directly connected to the board.

Most Chinese sensors do not have an open collector output (might be the LED-circuit). They have an internal pull up resistor. This is why the black wire is not only high impedance when the sensor is not switched but has any voltage on it. For those you need to add at least one resistor between the black and the blue wire to reduce the voltage to nearly 5v. (as mentioned above it is not for switching but securing the board. switching is done with 0v). Another way it to put a diode in, which should also prevent from damaging the board with voltage-peaks from the sensor while switching.

As you can see this topic is not easy to solve. So “universal” way is to put in an optocoupler which is not only working but protects your board from damaging

Descriptionfor SensorPrinterlink/commentoffset Xoffset Y
Official AnetROKO SN04-NA8expensive, fragile and collides the heat bed harness and connector15mm55mm
Official Anet likeROKO SN04-NA8
18mm capacitive sensorA8
12mm inductive sensor
Bowden A8

The offset in X,Y, and Z are the values defined in the firmware (In Marlin Configuration.h). The value for X and Y can be quite coarse. Z has to be accurate and has to be adjusted quite accurately. This value you can set also via display (Marlin): Menu→Control→ Motion→Z-Offset. Procedure to get this value:

  1. Set a large Z-offset value (i.e. 2mm)
  2. Autohome your printer
  3. place a sheet of paper beneath the nozzle (make sure it is clean)
  4. move Z-axis down by steps of 0.1 until it touches the paper.
  5. note the Z value (i.e 0.7mm) and subtract it from the initial value (2mm-0.7mm).
  6. Set the value as Z-offset (1.3mm)

The Sensor will be replace the Z switch. You will need a “JST XPH-3” 3 pin connector. You might also use the connector of your Z probe if you do not need a 5V power supply as the middle pin is missing. The position of the pins on the board is described in the picture:

Normally the following color code is used for the sensor Harness :

  • Black - Signal - for NPN it is 0V=active, high impedance OR supply voltage for inactive
  • Brown - Power supply - See sensor for the Voltage*
  • Blue - Ground - 0V

As most sensors need a voltage larger than the 5V provided by the connector there are two options:

  1. Purchase a pre made board:
  2. For 5V sensors or for some 6-36V sensors use the 5V supply of the connector. Anet and Skynet uses this option for their sensor and it works for the LJ18A3-8-Z/BX. According to some users the low voltage acceptable for the “orange” sensors. But the this might lead to unreliable readings as it is not designed for this voltage.
  3. If you have an open collector NPN sensor (see above) than you may connect the brown wire to the the 12V input of your board and the blue to the ground and finally the black wire to the Z switch (the board should have an internal pull up).
  4. If you have an sensor with an internal pull up resistor(see above) than you may connect the Brown wire to the the 12V input of your board and the blue to the ground. There are the following options:
    1. Than add a resistor between the black(signal) and the blue(ground) wire to reduce the resulting voltage from 12V to 5V. The best way is to test it with different resistors and measure the voltage between the signal(black) and ground (blue). Best to start with is 10k, for me it worked with 5k. Increase the resistance if the voltage is to low, decrease if it is to high. When you found the correct resistor you can connect the signal pin (black) to the signal pin of the z-probe plug as shown on the picture.
    2. The disadvantage of using resistors is that it depends on the power supply voltage and a change of this voltage my damage your printer. This can be avoided by using diodes see here. Method nr. 3 is the recommended one, just be careful with the polarity of the diode.
  5. Some tutorials recommend to use two resistors. But this is only for PNP-sensors and for high-active inputs. In our case this would lead to errors. When the sensor switches to 0V and the Atmega internal pull up is activated there would be about 2,5V on the signal pin which is not recognized as low by the AVR.
  6. last but not least there is the universal/safe way for your NPN-Sensor. Putting the optocoupler in:

(R2 is optional for Anet-Boards as it has its own Pullup)

Normally the installed printer software does not support autolevel. Therefore you will have to upload a new one via the USB port. There are 2 options:

* Skynet 3D A marlin-based firmware modified for the Anet A8 Skynet is obsolete. Use Marlin.


Instructions and information can be found here: Marlin Anet Board Defs for Arduino

You will have to make the following changes in the configuration.h file:

Set the position of the probe according to the probe support table above:

 #define X_PROBE_OFFSET_FROM_EXTRUDER 65  // X offset: -left  +right  [of the nozzle] 
 #define Y_PROBE_OFFSET_FROM_EXTRUDER -36  // Y offset: -front +behind [the nozzle] 


 #define X_PROBE_OFFSET_FROM_EXTRUDER -21  // X offset: -left  +right  [of the nozzle]
 #define Y_PROBE_OFFSET_FROM_EXTRUDER -43  // Y offset: -front +behind [the nozzle]

To define the positions(of the probe) of the points for the autolevel (sometimes needed):


Goes With Alternative:


These points have to reachable with the x,y offset defined for your probe support otherwise you get an error message when compiling and uploading.

Set the auto leveling method that you will be using (in this case Bilinear), just uncomment it:


In the case that the sensor is outside of the plate after homing the Y and X axis, use Z safe homing (applies if you are using a sensor support with a negative Y-offset:

  #define Z_SAFE_HOMING

The slicer needs some specific setup to execute the autolevel before each print and that the autohome works.

There are already some configuration files available at Cura

Gcode (only needed if there is no configuration file available for download)

Auto home

Before homing of the Z axis the probe has to be positioned above the heat bed. When the code G28 is send to the printer this is done automatically. But if “G28 Z” is send it is not. This is the case for some Cura 2.1 json files.

Auto level

The G code G29 starts the autolevel procedure. It should be executed after the G28 command

Implementing Gcode in CURA 2.1

The Gcode executed before a print is defined in the json file (see also Cura) Example:

"default": "G21 ;metric values\nG90 ;absolute positioning\nM82 ;set extruder to absolute mode\nM107 ;start with the fan off\nG28;move X/Y/Z to min endstops\nG29 ;auto level"\n

Testing repeatability of the probe

To test the repeatability of the probe Marlin/Skynet3D has the G-code M48. Which has to be activated in the configuration.h file: #define Z_MIN_PROBE_REPEATABILITY_TEST

For the following G-code “M48 P50 X100 Y100 V4” was used to obtain the values for the table above.

Measuring your heat bed flatness

With the “G29 T P10 V4” your printer will scan your heatbed in a 10×10 point matrix.

FreeMat/Matlab tool and instruction to analyze your output can be found here A online tool can be found here (send G-code “G29 T P7 V4” to your printer to get the output)

Another, more interactive online tool can be found here - paste the same output as above.

Automatic bed levelling is a complex beast. When set up well it can work extremely well, but if it isn't working well for you, there are a few basic things to check.

A very typical problem scenario is where the print is fine on one edge or in the middle, but the nozzle is too near the bed in one corner or on one edge. In this case, the first thing to check is if the probe X and Y offsets are correct.

Another common problem is the nozzle being too high above the bed when printing starts. This is often caused by the Z offset being incorrect.

These problems, and many others, can be solved by working through these simple troubleshooting steps.

Is the bed as flat and level as it can be?

ABL can't work miracles. You need to make sure your bed is as level as you can get it by adjusting the corner screws. When you have ABL working well you may like to consider to swap the springs and screws for fixed stands. (Like these, for example

There's no magic number for how flat your bed needs to be, but you probably want any variations to be no more than 1mm across the entire bed. You can check it manually by laying a straight edge (such as a steel rule) across it, or using your probe by increasing the number of probed points using the instructions under 'Measuring your bed flatness'.

Which levelling method are you using?

The two main levelling methods in Marlin are linear and bilinear. Linear creates a single tilted plane, and is best suited to a perfectly flat surface which is tilted lower or higher on one side or corner. Bilinear is best suited to an uneven bed with dips and rises, and is the Marlin-recommended method.

It is unlikely that your bed is perfectly flat, so bilinear is usually a good option, especially if linear does not give good results.

Is your probe working well?

One of the first things you should do after installing your Z-probe is check how well it works using the M48 command to test it.

In order to run M48 you need to uncomment this line in configuration.h:


Use commands like this to run 10 probes and get the measurements:

M48 P10 X100 Y100

The output will look similar to this:

M48 Z-Probe Repeatability Test
Mean: 3.450000 Min: 3.442 Max: 3.452 Range: 0.010
Standard Deviation: 0.004330

This shows the absolute maximum and minimum measurements the sensor took, the mean (average) of all the measurements, the range between the maximum and minimum, and the standard deviation.

The standard deviation is interesting because it tells us that 68% of all the measurements were within 0.00433mm (one standard deviation) of either side of the mean, and 95% of the measurements were within 0.00866 (two standard deviations) of the mean.

A good probe should consistently give a range in the hundredths of mm, e.g. 0.05mm. A very good probe will have a range in the thousandths.

More information about standard deviation:

If you get a very large range or standard deviation you should look for sources of movement in your Z-axis. The motor couplers can contribute to excess play and you can consider upgrading them to better ones. Failing that, consider getting a new probe.

Probe area

You should do the M48 probe test in multiple places across your build area to ensure your probe is consistent everywhere. If you're using a capacitive sensor, make sure you check at the extremes of your probing grid to make sure you're not suffering from any wrap-around near the bed edges.

These lines in configuration.h define the probing grid boundaries:


Some tips for probe accuracy

  • The 'spring' type Z-motor couplers allow vertical play, which can affect the Z-probe results. You can replace them with 'Plum' style couplers (like these) which have no vertical movement.
  • Capacitive probe measurements will vary near the edge - ensure that your probe boundaries are far enough from the edge to avoid this.

Are you probing enough points?

If your bed is curved or particularly warped you can increase the number of points the probe measures in order to create a more detailed correction matrix (at the expense of time - more probes means G29 takes longer).

Try a 5×5 or 7×7 grid by changing this line:


Are your X and Y offsets correct?

For ABL to work correctly it is essential that the printer knows the exact offset from the nozzle to the probe, otherwise any correction is not going to be applied in the right place, and it may look like the printer isn't correcting at all.

If you downloaded SkyNet3D and used one of the example configurations, it probably came with some pre-configured probe offsets and a recommended sensor mount for you to print. It is absolutely vital that you check the sensor offsets once your probe is installed, and update the values in configuration.h accordingly.

These are the relevant lines:

 #define X_PROBE_OFFSET_FROM_EXTRUDER 65  // X offset: -left  +right  [of the nozzle] 
 #define Y_PROBE_OFFSET_FROM_EXTRUDER -36  // Y offset: -front +behind [the nozzle] 

Typically, sensors are most sensitive in the center, so we need to know the offset from the tip of the nozzle to the center of the probe. Here is an approach you can use to measure it:

Measuring X and Y offsets

  1. Measure the bed and make a mark in the center (X110 Y110)
  2. Home the printer then move to X110 Y110 Z0
  3. If the nozzle is not on the mark you will need to make small movements to get it on the mark
  4. With the nozzle on the mark in the center of the bed, measure the X and Y distance from the edge of the bed to the side of the probe
  5. Measure the diameter of the probe
  6. The probe offset values are 110 - [the distance from the bed edge to the probe] + [probe diameter / 2]

The offset parameters are integers, so round your results to whole numbers before updating configuration.h

Is your Z-offset correct?

Getting the Z-offset right is critical to get your first layer. Use this process to find and set it:

With a firmware based on Marlin 1.1.x the procedure is a bit different as the behaviour of G92 in pre 1.1.x versions was buggy:

  1. Heat your printer up to your printing temperature and allow a few minutes for it to expand and settle
  2. Reset the existing Z-offset to zero
    M851 Z0
  3. Home all axes
  4. Move the nozzle to the middle
    G1 X110 Y110
  5. Turn off the software endstops with
    M211 S0
  6. Move the nozzle down so it is just gripping a piece of standard printer paper
  7. Set the Z-offset to the displayed value. E.g. if the printer displays a Z-Value of -1.23 enter
    M851 Z-1.23
  8. Store it to the EEPROM
  9. Important Enable the endstops again with
    M211 S1

    or the printer head will collide with the bed on the next G28 command

Pre Marlin 1.1.x

  1. Heat your printer up to your printing temperature and allow a few minutes for it to expand and settle
  2. Reset the existing Z-offset to zero
    M851 Z0
  3. Home all axes
  4. Move the nozzle to the middle
    G1 X110 Y110
  5. Move the nozzle down so it is just gripping a piece of standard printer paper
  6. Mark this position as Z zero
    G92 Z0
  7. Use the sensor to probe the middle of the bed (where we just set Z0)
    G30 X110 Y110
  8. Take the Z value of the bed and put a minus sign in front; this is the Z-offset. E.g. 1.23 becomes -1.23
  9. Set the Z-offset
    M851 Z-1.23
  10. Store it to the EEPROM

Did you let it warm up?

Before setting your Z-offset you need to make sure your printer is up to temperature and you've given it a few minutes for any thermal expansion to occur. Differences in nozzle height of around 0.2mm have been observed between a hot and a cold nozzle. If you set your Z-offset with the nozzle cold, you will most likely find it is too close to the bed when it is hot.

You should also ensure that the printer has had sufficient time at temperature before starting a print. Ideally give the printer 3-5 minutes after it reaches printing temperatures before you start to print.

Several experts have edited and corrected this page. This is just an recommendation without any warranty. If you are an expert and knows something better or just has found an error, please feel free to edit this wiki and add your knowledge.