Anet A8 (Prusa I3) Auto Leveling Using NPN NC Proximity Sensor and Skynet3D V2 Firmware





Introduction: Anet A8 (Prusa I3) Auto Leveling Using NPN NC Proximity Sensor and Skynet3D V2 Firmware

Manually leveling the bed is getting annoying after some time. Most people will want to add auto leveling for this reason and also to gain more precision when printing larger parts. The surface of the bed can change when heated...

You will need very few material for this :

  • the proximity sensor: 4mm is a pain, get a 8mm! Now this instructable is going to concentrate on the 4mm NPN normally closed (NC)
  • optocoupler FL817C (or anything you can find in the electronic trash)
  • soldering iron, solder
  • multimeter (important to test that everything is working)
  • Firmware : skynet 3d v.2 or whatever you think may be better (see facebook page)

Warning : do not "auto home" on your printer before you are absolutely sure the sensor is working! Otherwise you will most likely brake something, the little steppers for the z axis are pretty strong. In doubt, stay close to the power cable.

Please take the time to read the official documentation before you do anything. You may also want to take a look at peoples comment. While this worked for me, depending on the new revisions and the kind of probe you get, you may have to adjust this procedure.

Step 1: Printing the 3d Holder and Fixing the Probe

Get it from thingiverse : OR

(or search for variants)

Now if you have the terrible 4mm probe, you are up for some fun. The probe and the extruder nozzle need to be close in height. I recommend having the nozzle 2mm lower than the probe. Using the Anet A8 menu, lower the z axis by 0.1mm to find the perfect adjustment. Make sure the probe wont touch the print (that is why it needs to be a little higher).

Step 2: Doing the Electronics to Replace the Switch

The switch comes normally openend (NO). If you have a normally closed (NC) sensor, than you will have to change some settings in the firmware to say "STOP" when the circuit is opened. I will assume it is your case also.

Connect the probe

The brown wire goes directly to the power supply 12V (+).

The blue wire can be connected to the board's old switch black wire, which is a common ground.

The black wire will output 12V when the sensor is far from any metal and 0V when it is close to a metallic object. Test this with a multimeter to be sure you have the same kind of sensor I have and adjust accordingly if it is the opposite. Connect this to pin 1 of the optocoupler.

Now from my (only one) experience, the intensity of that 12V is pretty low, just enough to light an LED. That is why I decided to connect the probe's output directly to the optocoupler without any resistor to lower the voltage. Again, measure what comes out with a multimeter in case you have a different sensor and add a resistor if you need!

The role of the optocoupler is to use the 12V from the sensor to close the 5V switch without risking sending some 12V in your Anet controller (that would fry it).

For the rest, just follow the figure above.

Step 3: Optional : Add a Safety Switch

If something goes wrong with the sensor, the steppers may try to lower the z-axis completely, damaging your printer for sure. For example, if something is restricting the plate from moving, or it skips a turn, the probe may be left in the void and won't detect the plate. That is why I recently added a safety switch as a precaution.

This is super easy to do. Cut the red wire from the Z-Stop connector in two parts and connect them to the switch ends so that it is normally closed. The switch will be a little lower that the sensor and if something goes wrong it will trigger the z_min.

Step 4: Testing the Sensor With Cura

Board must be connected to USB and you will need Cura software for this step, with Pronterface UI selected.

Bring the print interface (file, print). Issue the command M119 to see if z is TRIGGERED or opened. Try this a few times with a metal object in close proximity.

If it doesn't change, that is bad! Try testing with a multimeter. Test on the collector/emmiter side of the optocoupler. You should measure 5V when the optocoupler is not triggered and very close to 0V when it is triggered. On the anode/cathode side, you should measure 12V when the sensor is far from metal and 0V when in proximity (that is with no optocoupler connected). Review datasheet if needed, maybe the optocoupler is fried or not triggered? Test it in recommended conditions or try another one...

Step 5: Install the New Firmware and Adjust Z-offset on the Printer

Now I am just going to cover this very quickly for skynet3dv2.0. Follow instructions from skynet or whatever other firmware you choose for more details.

Ok, so you are in Arduino IDE and you need to change a few parameters in Configuration.h :

  • The sensor offset x and y from the extruder nozzle. Measure the distances with a ruler.
  • Invert the value for the z_min position (if applicable).
  • Choose the LCD display (this firmware supports a better display or the regular one, you need to choose).

Once it is changed, upload it. If you did it right you should have the display updated with the new firmware logo...

Adjust the z-offset on the printer

For this, simply lower the z-axis with Cura Ponterface UI. Home All and then manually lower z by 1 or 0.1mm steps with a piece of paper underneath the nozzle. When you feel some resistance, issue a M114 command to know the position of the z-axis.

Now on the printer, go to the motionmenu and select z-offset. Enter the value you just found. Go to control and store memory. Try to Home All again and lower the z-axis by 10mm (by default at the end it will be raised 10mm above the plate). Check if you see some resistance.

Adjust the start G-code

Simply put G29 just after G28, this is for the auto leveling.

That's it, you did it, hopefully! Let me know how it goes in the comment section :)



    • Oil Contest

      Oil Contest
    • Casting Contest

      Casting Contest
    • Woodworking Contest

      Woodworking Contest

    We have a be nice policy.
    Please be positive and constructive.




    Hi, thanks for the guide.

    According to the wiring "diagram" i need to link the ground to the optocoupler cathode and then it goes form the emitter to the board ground, but do i need to link them directly too?

    7 replies

    They should be the same ground already, so just use the one from the board.

    So i can't understand the meaning of that "blue bridge" between cathode and emitter

    It only means that you can use the GND from the board or from the power supply, or both, they are the same actually (test it with a multimeter using the continuity mode: it will go beeeeeeep!). If you use the one from the board then you only have one wire to connect to the power supply... for me it seemed easier at the time. You are right, I could change the diagram if it is confusing, but I am too lazy ;-)

    it doesn't work... the led which show if circuit is closed is always on and I can't get any output from pin 4

    You mean the LED on the probe? If that is the case, it is either a bad probe or the wiring is not ok. Don't trust the color of the wires, verify the spec sheet (or the ebay page if you bought it there). Now if it was connected to a 12V source, it may be fried. Get a multimeter and test the probe alone before going any furether.

    Hello, thank you for the guide.

    i have one question before start with the installation. I'm not sure if the components that i have are compatible with your guide.

    i have this sensor: LJ12A3-4-Z/BY, Capacitive proximity switch, blue cap, PNP NO

    and i have also a set of STK. 10 x EL 817 Optoisolatore/Optocoupler

    i can use those components, or i have to order a new one?

    thanks in advance!

    1 reply

    It should work, but always test every step of the way to be sure. With a multimeter you can verify the 12V output of the probe when it is in proximity of a metallic object or not. As for the optocoupler, you can cheat with a higher input voltage if the current coming out of the probe is very low, 12V won't be a problem (so far for me it has always been the case, tried with two different probes). Try to light a LED if you have one (make sure to check the polarity) and if it lights up just a little you are good to go. Next step, connect the optocoupler and measure the output while playing with the probe. Let us know how it goes! One advice I can give you is that with a 4mm probe you better always watch your printer (at calibration time) and make sure the probe is perpendicular to the plate on every corner (there is no room for errors when you only have 4mm). Make sure to put back the switch as a safety measure, in case the head crashes on the plate. After awhile, I have upgraded one of my printer with a 8mm, both are working fine, but I prefer the 8mm one.

    Hey Kev_MTL, I'm totally puzzled by electronics part. I have an LJ18A3-B-Z/BX probe (i think that is the same as -8 version) and an optocoupler SRD-12VDC-SL-C with 6 nodes and an H/L switch (pic -
    1. So in which position I should set that small jumper-switch? Near "L" or "H" or remove it?
    2. Which cables and colors go where? NO, COM, NC and DC+, DC-, IN
    3. My Z end stop switch currently have red wire in COM and B-R wire in NO, how to hook up it to the new system and do I need to solder a Black-red wire to NC like on your pic?

    I'm ready to provide better pictures when everything will be done, so you can extend your tutorial with optocoupler SRD-12VDC-SL-C for the future.

    2 replies

    What you have is a relay board, protected by an optocoupler. A relay is not good because it is mechanical and it will not fire instantly. What I did was unsolder the optocoupler from a similar relay board and that is the only thing I used. For the wiring, make sure not to fry your probe. Check the listing, the spec sheet, etc. If you can get your hands on a multimeter it will help you. Before you connect anything, try your probe alone and see how it reacts when it gets closer to metal, etc. Then you can connect the optocoupler. I believe the spec sheet is this :

    Thanks for quick response.Since I barely understand anything in that manual and don't have a multimeter, I guess will keep leveling manually. I ordered that pre-made board to avoid soldering resistors and other things, thought i can just connect everything with crimps and that it. Too bad wasted time on firmware updates and other stuff.

    I have made my sensor with a voltage divider and it triggers good, but I have a problem with the homing. Home position of the x axis is in my case -33 and of course in this case when the z is going home, the sensor can't trigger because it is in empty space. How can I solve this problem?

    Does anyone know what the Vcc on the atmega1284p on anet a8 controller board is? I need it to work out the logic voltage levels. I currently get a signal at 3.45 V going into the controller board but I'm worrying it might be too little to properly register as a high. What do you guys think?

    4 replies

    The 7805 voltage regulator brings the 12V input down to 5V, so the logic of the board is 5V. Try to measure the voltage between the red and black wire of the z-stop connector, you should get 5V. Now keep in mind that there is a 10k pull up resistor, so the pin on the chip is set to high by default. When you bring it to ground, it goes down to 0V.

    Many Thanks for your help. I am however facing another issue now :<.

    I am attempting to setup auto leveling on my A8 with the LJ18A3-8-Z/BX. I tried the potential divider approach with 10K and 15K resistors first. Before hooking those up the output from the sensor was 12V and theoretically my potential divider should drop this down to about 4.8V. This however was not the case as I was getting 3.45V. I checked the output voltage from the sensor after connecting said resistors and it dropped down to 9.12V O.o .Effectively making my potential divider not valid anymore. I tested the potential divider by itself in a separate circuit and it worked great.

    I had some L7805's laying about so I also tried it with those instead of the potential divider approach. In a regular circuit without the sensor it worked great as 12V got converted to about 5V. As soon as I changed the input to the L7805 to be from the sensor output, I was only getting out just over 2V.

    To summarise it seems that as soon as I connect anything on the sensors output it drops in voltage which breaks the setup that was hooked up. I ordered some optocouplers as suggested in this instructable however I can't get over why the above is happening in the other approach. Any ideas? Thanks.

    I did this instructable because I went through the same kind of issues. In the end, I realized that the 12V output from the proximity sensor has a very weak intensity, a few milliamps from what I recalled. So I tried connecting a LED directly to it, to see if it would light up like crazy (and burn) and it did not, it was pretty dim. That made me think that I could just hook up the optocoupler without any resistor, because the internal LED of the optocoupler would not burn if the voltage is dropped by the internal resistance. So far it still works. So in the end, I think the proximity sensor is just sending a weak signal. V = R * I could be helpful to figure out what is going on, but first we would need to understand how the proximity sensor really works and why is the output so weak. I am no expert in electronic, just a guy trying to print! If anyone can dig into this, that would be awesome!

    Well. I'm glad I wasn't the only one going crazy. Had resistors laying about so I thought I'd go with the potential divider approach. If I knew I would have ordered the optocouplers earlier. As for the reason to all this I have my suspicions as to whether the stock PSU is powerful enough.

    what kind of specification are acceptable for thes octocouplers? because i am not familiar with the kind of electronics.