<p>Another possibility is to create a <a href="https://en.wikipedia.org/wiki/Voltage_divider" rel="nofollow noreferrer">voltage divider</a> circuit. </p>

<blockquote>
  <p>In electronics, a voltage divider (also known as a potential divider)
  is a passive linear circuit that produces an output voltage (V<sub>out</sub>)
  that is a fraction of its input voltage (V<sub>in</sub>). Voltage division is 
  the result of distributing the input voltage among the components of the
  divider. A simple example of a voltage divider is two resistors
  connected in series, with the input voltage applied across the
  resistor pair and the output voltage emerging from the connection
  between them.</p>
</blockquote>

<p>Note that fluctuating voltages of the power supply can have side effects that the voltage of the divider is either too low or high for the pin and could result in either a detection miss or could burn the on board processor. </p>

<p>A voltage divider based on 12&nbsp;V is depicted below based on <a href="https://mertarauh.com/2017/01/18/dont-trust-the-internet-and-how-to-add-an-inductive-proximity-sensor-to-your-3d-printer-the-proper-and-easiest-way" rel="nofollow noreferrer">this source</a>:</p>

<p><a href="https://i.sstatic.net/6HSYk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6HSYk.png" alt="12 V voltage divider"></a></p>

<p>Please note that for different voltage you require a different value, e.g. for 24&nbsp;V you would require (<a href="http://www.ohmslawcalculator.com/voltage-divider-calculator" rel="nofollow noreferrer">by calculation</a>) a 2.63&nbsp;k&#8486; resistor (which does not exist, so put two resistors in <a href="https://en.wikipedia.org/wiki/Series_and_parallel_circuits" rel="nofollow noreferrer">series</a>; a 2.2&nbsp;k&#8486; and a 430&nbsp;&#8486; to get that value).</p>

<hr>

<p><em>NOTE:<br>This is posted as a separate answer as the question by the OP can be answered by different solutions; this solution uses a totally different approach than my other answer. It is up to the OP to decide which of the answers suits the OP best. This is not in contrast to the SE approach as can be taken from various Meta questions on this topic. To incorporated this answer into the other answer (with multiple ways under captions) is per definition not better than having various answers; different solutions should be in different answers so that they can be voted independently of each other</em></p>

CC BY-SA 4.0
2019-08-19T19:01:28.797Z
It is important that the resistors used for the voltage divider be substantially (at least 10x, as a guide, IIRC) smaller than the input impedance of the circuit that the signal is fed to. Resistors in the kΩ range are likely to be suitable; resistors in the MΩ range may give an unreliable circuit without taking into account the input impedance, and may also give problems if there is any EMI around.
Andrew Morton
CC BY-SA 4.0
2018-07-11T08:50:21.987Z
2019-07-17T12:07:31.093Z
2019-07-17T12:07:31.093Z
0scar
<p><strong>Minimalist Solution</strong></p>

<p>The very simplest possible implementation is to use a single resistor(!) to protect the input pin, as described in this <a href="https://scienceprog.com/using-current-limiting-resistors-on-avr-io-pins/" rel="nofollow noreferrer">source</a>. The AVR inputs are protected from over/under voltage by internal silicon diodes D1 and D2. The input resistor must be sized such that it will conduct no more than 1 mA when the internal clamping diode, D1, conducts at Vcc+0.5V, or 5.5V in this case. A 22K resistor could work in this case if we use our 24V supply for the sensor. Our current through the clamping diode is calculated by Ohm's Law as (24V - 5.5V)/22K = 0.84 mA.</p>

<p>There is no reason, in this case, to cut so close to the bone though. We do not need particularly high speed detection for this application, so a 100K resistor would be a better choice, and limits diode D1 to 0.19 mA. This gives additional protection for voltage spikes.</p>

<p>This solution works well until the internal diode gets fried by a spike or surge, so it is much better to add redundancy, and use a pair of external Schottky clamping diodes, which have a lower forward voltage drop and will conduct before the internal silicon diodes.</p>

<p>So, my solution, (the one I plan to implement soon on my own Ender 3 Pro*), is from <a href="https://scienceprog.com/using-current-limiting-resistors-on-avr-io-pins/" rel="nofollow noreferrer">this source article</a> and looks like this:</p>

<p><a href="https://i.sstatic.net/Iudxx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Iudxx.png" alt="Circuit diagram showing protection diodes for AVR input"></a></p>

<p>Where R1, D3, and D4 are my external components as described, and C1 is omitted for simplicity. (If C1 is used, it forms a low-pass RC filter, so you'd need to size it appropriately. If we find that noise or 'bounce' is an issue, we can add C1 easily later.)</p>

<p>In my opinion a single 100K resistor and two Schottky diodes are adequate protection for this circuit, and the 6-36V proximity sensor will work very well on the available 24V supply.</p>

<p>*Based on the first comment to this proposed solution, I recognize the need to look carefully at the failsafe property here. Depending on whether the existing Z endstop is included in the loop, and how Marlin handles this too will determine whether this is a satisfactory solution.
I'll leave my part of the discussion there for now, until I get closer to design and implementation on my own machine.</p>

CC BY-SA 4.0
2019-06-14T15:05:27.170Z
While this is technically an option, a properly rated (MOS)FET in use as a Voltage Controlled Resistor (or switch) would be preferable. Using the 24 V on the in and putting both outs directly to the pins of the switch turns it into an NC switch that opens upon voltage from sensor, so it needs an NC probe to have a failsafe - on loosing signal from the probe (ripped cable) the limit switch triggers just like on detection.
Trish
CC BY-SA 4.0
2019-06-14T13:58:46.527Z
2019-06-15T04:56:23.200Z
2019-06-15T04:56:23.200Z
JPC
<p>The inductive sensors work better when you apply a higher voltage than 5&nbsp;V. Usually they are rated for 6-36&nbsp;V, but please do check.</p>

<p>To prevent frying your board when connecting the sensor to (12 or) 24 Volts you could optically isolate the 5&nbsp;V and the (12 or) 24&nbsp;V circuit with an OptoCoupler module:</p>

<p><em>Image of an optocoupler module</em><br>
<a href="https://i.sstatic.net/Xfrlg.jpg" rel="noreferrer"><img src="https://i.sstatic.net/Xfrlg.jpg" alt="OptoCoupler module"></a></p>

<p>This module uses an optical switch based on the output of the sensor and should be correctly connected:</p>

<p><em>Image of connecting an optocoupler module to the sensor and to the board</em><br>
<sub>Please note that the image uses a capacitive sensor rather than a inductive sensor, both are connected similarly</sub>
<a href="https://i.sstatic.net/munY6.jpg" rel="noreferrer"><img src="https://i.sstatic.net/munY6.jpg" alt="wiring of an optocoupler module"></a></p>

<p>Note that there are many sorts of sensors, a few are listed <a href="https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling#sensor_support" rel="noreferrer">here</a>. Generally speaking, the larger the diameter of the sensor, the larger the detection distance to the bed. Note that these work well with metal beds (Iron/steel better than Aluminium), but will not work for glass (capacitive sensors work on glass but are prone to drift by moisture in the air, a touch sensor may then be a better alternative).</p>

CC BY-SA 4.0
2018-07-10T14:43:03.377Z
The specs for the indicated linked sensor does show up to 36vdc capability. Nice solution.
fred_dot_u
CC BY-SA 4.0
2018-07-10T14:20:01.547Z
2019-02-20T22:57:54.973Z
2019-02-20T22:57:54.973Z
0scar
<p>I am getting a 24&nbsp;V based Ender 3. From the factory, it has an aluminium bed. So I also put this <a href="https://www.amazon.de/gp/product/B071ZQ6VV6/ref=oh_aui_detailpage_o01_s00?ie=UTF8&amp;psc=1" rel="noreferrer">LJ12 A3-4-Z/BX Inductive NPN NO 4 mm</a> with 6-36&nbsp;V operation current into the box together with a few other spare parts. Now, as I read up on these things something dawns on me: The normal input and output voltage of a simple switch is 5&nbsp;V, as sensors are ran on 5&nbsp;V on most boards (and in digital logics). The sensors run on 6&nbsp;V plus though.</p>

<p>I do not want to fry my machine by putting in 24&nbsp;V into the sensor input: What do I have to do (besides making a mount)?</p>

<z-probe><creality-ender-3><inductive-sensor>
Inductive Sensor in 24 V machine?
Trish
# Inductive Sensor in 24 V machine?

(Asked by: username_0 on 2018-07-10)

I am getting a 24 V based Ender 3. From the factory, it has an aluminium bed. So I also put this [LJ12 A3-4-Z/BX Inductive NPN NO 4 mm](https://www.amazon.de/gp/product/B071ZQ6VV6/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1) with 6-36 V operation current into the box together with a few other spare parts. Now, as I read up on these things something dawns on me: The normal input and output voltage of a simple switch is 5 V, as sensors are ran on 5 V on most boards (and in digital logics). The sensors run on 6 V plus though.

I do not want to fry my machine by putting in 24 V into the sensor input: What do I have to do (besides making a mount)?

**Tags:** z-probe, creality-ender-3, inductive-sensor


---

## 3 answers

### Answer by username_1 on 2018-07-10. Score: 11 | Accepted answer

The inductive sensors work better when you apply a higher voltage than 5 V. Usually they are rated for 6-36 V, but please do check.

To prevent frying your board when connecting the sensor to (12 or) 24 Volts you could optically isolate the 5 V and the (12 or) 24 V circuit with an OptoCoupler module:

*Image of an optocoupler module*  
[![OptoCoupler module](https://i.sstatic.net/Xfrlg.jpg)](https://i.sstatic.net/Xfrlg.jpg)

This module uses an optical switch based on the output of the sensor and should be correctly connected:

*Image of connecting an optocoupler module to the sensor and to the board*  
Please note that the image uses a capacitive sensor rather than a inductive sensor, both are connected similarly
[![wiring of an optocoupler module](https://i.sstatic.net/munY6.jpg)](https://i.sstatic.net/munY6.jpg)

Note that there are many sorts of sensors, a few are listed [here](https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling#sensor_support). Generally speaking, the larger the diameter of the sensor, the larger the detection distance to the bed. Note that these work well with metal beds (Iron/steel better than Aluminium), but will not work for glass (capacitive sensors work on glass but are prone to drift by moisture in the air, a touch sensor may then be a better alternative).

> **Comments:**
> **username_4**: The specs for the indicated linked sensor does show up to 36vdc capability. Nice solution.  

---

### Answer by username_1 on 2018-07-11. Score: 4

Another possibility is to create a [voltage divider](https://en.wikipedia.org/wiki/Voltage_divider) circuit.

> In electronics, a voltage divider (also known as a potential divider)
> is a passive linear circuit that produces an output voltage (Vout)
> that is a fraction of its input voltage (Vin). Voltage division is
> the result of distributing the input voltage among the components of the
> divider. A simple example of a voltage divider is two resistors
> connected in series, with the input voltage applied across the
> resistor pair and the output voltage emerging from the connection
> between them.

Note that fluctuating voltages of the power supply can have side effects that the voltage of the divider is either too low or high for the pin and could result in either a detection miss or could burn the on board processor.

A voltage divider based on 12 V is depicted below based on [this source](https://mertarauh.com/2017/01/18/dont-trust-the-internet-and-how-to-add-an-inductive-proximity-sensor-to-your-3d-printer-the-proper-and-easiest-way):

[![12 V voltage divider](https://i.sstatic.net/6HSYk.png)](https://i.sstatic.net/6HSYk.png)

Please note that for different voltage you require a different value, e.g. for 24 V you would require ([by calculation](http://www.ohmslawcalculator.com/voltage-divider-calculator)) a 2.63 kΩ resistor (which does not exist, so put two resistors in [series](https://en.wikipedia.org/wiki/Series_and_parallel_circuits); a 2.2 kΩ and a 430 Ω to get that value).

---

*NOTE:  
This is posted as a separate answer as the question by the OP can be answered by different solutions; this solution uses a totally different approach than my other answer. It is up to the OP to decide which of the answers suits the OP best. This is not in contrast to the SE approach as can be taken from various Meta questions on this topic. To incorporated this answer into the other answer (with multiple ways under captions) is per definition not better than having various answers; different solutions should be in different answers so that they can be voted independently of each other*

> **Comments:**
> **username_2**: It is important that the resistors used for the voltage divider be substantially (at least 10x, as a guide, IIRC) smaller than the input impedance of the circuit that the signal is fed to. Resistors in the kΩ range are likely to be suitable; resistors in the MΩ range may give an unreliable circuit without taking into account the input impedance, and may also give problems if there is any EMI around.  

---

### Answer by username_3 on 2019-06-14. Score: 2

**Minimalist Solution**

The very simplest possible implementation is to use a single resistor(!) to protect the input pin, as described in this [source](https://scienceprog.com/using-current-limiting-resistors-on-avr-io-pins/). The AVR inputs are protected from over/under voltage by internal silicon diodes D1 and D2. The input resistor must be sized such that it will conduct no more than 1 mA when the internal clamping diode, D1, conducts at Vcc+0.5V, or 5.5V in this case. A 22K resistor could work in this case if we use our 24V supply for the sensor. Our current through the clamping diode is calculated by Ohm's Law as (24V - 5.5V)/22K = 0.84 mA.

There is no reason, in this case, to cut so close to the bone though. We do not need particularly high speed detection for this application, so a 100K resistor would be a better choice, and limits diode D1 to 0.19 mA. This gives additional protection for voltage spikes.

This solution works well until the internal diode gets fried by a spike or surge, so it is much better to add redundancy, and use a pair of external Schottky clamping diodes, which have a lower forward voltage drop and will conduct before the internal silicon diodes.

So, my solution, (the one I plan to implement soon on my own Ender 3 Pro\*), is from [this source article](https://scienceprog.com/using-current-limiting-resistors-on-avr-io-pins/) and looks like this:

[![Circuit diagram showing protection diodes for AVR input](https://i.sstatic.net/Iudxx.png)](https://i.sstatic.net/Iudxx.png)

Where R1, D3, and D4 are my external components as described, and C1 is omitted for simplicity. (If C1 is used, it forms a low-pass RC filter, so you'd need to size it appropriately. If we find that noise or 'bounce' is an issue, we can add C1 easily later.)

In my opinion a single 100K resistor and two Schottky diodes are adequate protection for this circuit, and the 6-36V proximity sensor will work very well on the available 24V supply.

\*Based on the first comment to this proposed solution, I recognize the need to look carefully at the failsafe property here. Depending on whether the existing Z endstop is included in the loop, and how Marlin handles this too will determine whether this is a satisfactory solution.
I'll leave my part of the discussion there for now, until I get closer to design and implementation on my own machine.

> **Comments:**
> **username_0**: While this is technically an option, a properly rated (MOS)FET in use as a Voltage Controlled Resistor (or switch) would be preferable. Using the 24 V on the in and putting both outs directly to the pins of the switch turns it into an NC switch that opens upon voltage from sensor, so it needs an NC probe to have a failsafe - on loosing signal from the probe (ripped cable) the limit switch triggers just like on detection.  

---

