Troubleshooting Inductive Sensor

Hey folks, I’m using an inductive sensor in my 3D printer and seeing behavior I don’t understand, wonder if anyone can help.

I have a 24vdc power source and am wiring the sensor in parallel with a small fan, and the pair in series with an LED. The fan and sensor are nominally 24v parts, the LED is a 12v part.

On the sensor signal pin, I have a voltage divider and a Zener diode to protect my arduino input. I have attached a “schematic” (sorry for powerpoint mess!) to this post and a link to the ouput section of the NPN sensor schematic.

So what I’m expecting is 5v when the sensor is not activated and 0v when it is activated. What I’m seeing instead is 5v either way. Actually the signal goes slightly up when active - something is changing when active but not in a good way…

I measure 10v drop across the fan and sensor, and it doesn’t change when the sensor is activated. Then I measure 14v across the LED, and it also doesn’t appreciably change when activated. Just can’t figure out how 5v is getting to the signal. Thinking maybe I need another diode in there but would like to understand better what’s going on.

Thanks for any help you might provide.

Here’s the link to the sensor (it’s the NPN one!)

There is, basically, nothing correct about that schematic. If you have connected things even approximately in the indicated way, you risk destroying the Arduino.

  1. Connect all the grounds together.

  2. The fan and sensor should NOT be connected through an LED to ground. The LED is not needed.

  3. If the sensor output really is NPN, then you need a pullup resistor from the output to 5V (suggest 10K) and you don't need a voltage divider or a Zener diode.

In general:

  1. A Zener diode, if used, should be connected between ground and the Arduino input, with the cathode (bar end) on the input.

  2. If you ever expect 24 V output from the sensor (i.e. for PNP output), the voltage divider is wrong. It is 2:1 but should be about 5:1. In that case, you don't need a Zener.

Thanks for the quick input, let me make some clarifying remarks...

First, I only have one 24v pin to power these three items, that's what's left of a multiconductor shielded wire to the effector of the printer. It's hard to pull more wires up there at the moment so I'm trying to get that done this way.

The LED is desired, it's lighting the work area under the effector. I've put it where I have in the circuit because it's a 12v LED, I'm already overvolting it a bit at 14v but it isn't getting warm - might shorten it's life a bit.

The board (it's 32 bit AVR based so "Arduino" might be stretching a bit - it does have 5v inputs though) I'm using has firmware settable pullups, which are enabled so I don't think I need an additional one.

I had a previous sensor wired by itself which did deliver 24v and I did have a 4k7/1k divider and it worked great. However, with the fan and LED sharing the power, the previous divider dropped too much and wouldn't trigger the input. I decided to use a 2:1 divider since this curcuit now feeds ~11v through the signal, not 24; but use a zener just in case the sensor ever did somehow send 24 volts, like me shorting something by accident :-0

But, I'm probably using the zener incorrectly. I did wire it according to a schematic I found online, but I don't have that link handy to post. Can you say more about what looks wrong about what I've done? Or maybe a link to a different/correct way to wire it?

It's possible that the grounds are an issue as I'm not 100% clear what's going on inside the board. I do believe though that the gnd of the endstop input is ultimately connected to the power supply (-). I guess there isn't a true ground anywhere except all the way at the supply where it connects out to grounded 110vac. The 24v I'm sending to the fan/led/sensor does come from a different output from the PS, it's just easier to use the other tap, but that might be bad.

Perhaps the ground is not an issue. However, it is not a good idea to wire anything but an appropriate resistor in series with the LED. The sensor will not work correctly, wired as you have it now.

For Zeners, see this link Zener Regulators

The LED is actually a small strip with the appropriate integrated resistors. This strip is designed to be daisy chained with other similar LED strips and so I think it should be OK to wire it as is. Basically the fan and sensor and LED all work fine, and it's probably just the zener and the input itself that I'm not fully understanding how to make work together.

I've actually read a bunch of information about zeners, but somehow not quite getting it and I've not been able to apply what I'm seeing there to the situation at hand. Most of them seem like application notes for protecting against overvoltage on a power input and this application isn't exactly that. These schematics often show the "load" meaning the thing to be powered, but I'm not sure what the analog is here. I'll take a look at your link as well, thanks.

I keep getting twisted around in trying to reason through the input and the sensor - the sensor is trigger low, so it nominally puts out whatever voltage it's given (in this case approx 11v), then when actuated, it drops down to less than one volt.

The input on the board must be set inverted in firmware (which it is) so that when it sees 5v it is untriggered and when it sees 0 it is triggered.

I can't quite see how to use the zener here, and I want to, as Vcc is 24v, if it gets to the sensor and through it's output at some point I wouldn't want it to fry the input. A voltage divider doesn't seem to be enough unless I'm sending the full 24v as before and can use the 5:1.


  1. What is the spec of the inductive sensor?
  2. What is the material that you are detecting with it?
  3. What do you what its output to do when it detects metal?
  4. What do you want the output to control when it detects metal?
  5. What do you want the LED to do?
  6. What do you want the fan to do?
  7. What is the 'endstop" component?
    8 ) Can you please post a picture of your project?

Please answer these questions ONE at a time please.

Tom...... :slight_smile:

Hey Tom,

It’s not the function of the sensor itself that’s the issue it’s how to hook it up - I’ve been using this same sensor for a while but now trying to add the fan and LED. But, I’ll answer your questions…

  1. Sensor is Fotek 6-30v inductive sensor, 8mm sense distance.
    This one
  2. Steel
  3. Output is normally the same as the power provided to the sensor, in this case ~11v. I want the output to drop to ~0v when the sensor is near steel
  4. The output is intended to control a 5v digital input on an arduino-like board - the input is set to “inverting” in that the firmware detects a trigger when the signal goes low
    5/6) I want the LED and fan to both always be on, no change when sensor triggers or not (this is already working)
  5. The “endstop” is a terminal strip on the board in which one pin is gnd, the other is the digital input, and the other is a 5v source in case you need to power a sensor with it. I’m not using the 5v because I’m powering with ~11v
  6. Here’s a slightly older picture of the project - you can see at the end of the effector a little red box, that’s the older 5mm sensor which worked with a 5:1 voltage divider - you can see there’s no light at the end of the effector, and the wires/umbilical going down to the effector are a mess. Now I have a nice neat 8 pin din connector but don’t have enough conductors to power everything I need, hence the desire to power the fan/led/sensor all with one 24v/gnd pair.

The Picture

Thanks for any help.

OK, I think I understand at least what's happening but not yet what to do about it...

I'm expecting the sensor to drop from 11v to ~0, but in fact the sensor negative is elevated from the board ground by 14 volts so it actually is dropping its output 11 volts but from 24 to 14. 24 and 14, when cut in half through the voltage divider are both above 5v, hence always 5v showing.

So, the zener (if I could figure out how to use it) wouldn't be "needed" after all because that sensor is dropping the full 24 volts anyway. However, the original 5:1 divider won't work because 14/5=2.8, not enough to register low. In fact, there's no two resistor divider that will get me above or at 5 on the high side and below, say 1 on the low.

Maybe there's a more complicated divider and/or a zener application that will get me there.

I have a different idea, instead of making it more complicated, make it simple for yourself.

If the fan, sensor, and LED strip all run of around 12V instead of putting them in a convoluted series/parallel combination why not get a 12V regulator and run all three from the regulator in parallel.

You can easily get a 12V switching regulator capable of delivering high currents if you have proper heat sinking etc.

Then all would be in parallel and getting a steady 12V and referenced to ground.

I recommend the approach above... but you could probably find a way (albeit more of a hack) to make it work with your current setup.

If sensor were powered from 12V and referenced to ground, then you could easily hook pnp output to arduino pin using either a voltage divider with appropriate scale of maybe 1:3 so 12V would turn into 4V on arduino input pin (and of course when pnp goes low you will get 0V on input pin so long as the divider resistors you use dont overpower the high impedance resistance of your avr development board

If you can't/dont want to get a 12V regulator a possible alternative would be to flip the LED and fan/sensor combo in the circuit. So LED will drop 12V or so (from 24V down to 12V) and then fan and sensor will drop 12V (12V to GND) but they will then be ground referenced and so a low on your sensor would in fact be GND not floating up at 12V

Wes, thanks for the input - the regulator is a good idea, but I would at least like to understand what's actually happening in this circuit - it feels like a learning opportunity :slight_smile:

I breadboarded this all out before putting it on the machine (except the sensor output duh) and it turns out that putting the LED in front drops too much voltage across it - it gets brighter than I want and will likely burn out fast. Maybe an additional resistor in series would put it back in a comfortable range? Then I suppose the sensor would be referenced to ground and drop it's signal to ~0v through a suitable divider as you said.

The strange thing I'm not getting at this point is that, while it makes sense that the ground of the sensor is floating, I would have expected to be able to adjust that signal with a divider/zener. However, nothing I do to the signal seems to change it. If the circuit is isolated and I just have a meter from the signal output to ground I see the 24v vs 14v I mentioned earlier. But if I connect the signal to ground through any sort of divider, the signal just sits around 12v and, I guess, continues to float up regardless of divider configuration. It's mysterious to the uninitiated but maybe obvious to someone on this board :slight_smile:

I have a complete other set of fan/sensor/LED so I can test again with LED and resistor in front, this time also testing the sensor output. Dreading de/resoldering that din connector though! If there's and easy way to get that sensor to reference to ground and not float around I'd like to know it!

Thanks again!

The information on the sensor you have is really vague ... all I could find is that it appears there is already an internal pull-up to it's power source (as per you're first link). If so, then you could try this:

EDIT: To strengthen the signal, I would connect a 1K resistor between +5V and SIG.

Thanks dlloyd, I think this illustrates what I wasn't getting about zener use in general, once the voltage goes above its breakdown, it opens a path from signal to ground. That makes sense.

The challenge I have is that the (-) of the sensor can't go directly to gnd, it is connected to the LED, and then on to ground. So I guess its reference floats up to 14v. So when the sensor isn't active the zener sees 24v and when the sensor is active, the zener sees 14v, both of which conduct to ground, so the input would never change state.

I thought I might get around this with a voltage divider in addition to a zener, but the divider isn't behaving as I was expecting.

Not sure you’re getting the zener deal, so here’s the situation with an “ideal” zener (see pic attached.)


I want the LED and fan to both always be on, no change when sensor triggers or not

I would remove the LED from where you've shown it. Then:

  • connect one end of a 4.7K resistor to +24V
  • connected the other end of the resistor to the anode of the LED
  • connect the cathode of the LED to (-) of the 24V power source.

Thanks Pancake for the additional clarity on the zener, I do think I get it in isolation (check me!), but not certain how to use it in the circuit.

Can I start from the beginning and get help to build from there?

So, the board input is trigger low. That means I need to connect the signal of the board to ground for it to trigger. (This is at least one thing I forgot in the original schematic, wherein I was trying to deliver 5v to the signal input) There is an internal pullup enabled, so it’s high and nominally off.

In case A from your picture, which is the configuration dlloyd drew also, when the Vin is <5 then the zener is closed and the signal input is isolated from ground by the zener so the board input remains untriggered.

Then, when Vin>5, the zener breaks down and current flows from Vin to gnd through the zener. Is it true also that in such configuration current also flows from the signal input to gnd, (or at least it’s shorted to ground) i.e the board input will trigger?

If that is true then comes the next problem. (if not true, please help me see what I’m missing!)

The drop between the sensor and ground is 24v when it is not sensing, so the zener would be open and the board input would see ground and so will be triggered. When the sensor is sensing, due to it’s position in the circuit, the drop from the sensor output changes from 24v to its reference, which is actually 14v from board ground. At this potential, the zener is still in avalance, and so the input is still connected to ground, and still triggered. So, the input is always triggered regardless of the state of the sensor. That’s the issue I’m trying to resolve. (granted of course I’m understanding correctly above)

So dlloyd, you're suggesting to put the fan and the sensor and the 4k7+LED all in parallel? That will be fine for the sensor, and will get me the low from the output I'm looking for, but will cause my fan to blow more than desired, but I guess I could also put a resistor in front of it as well? Adding a resistor to the fan though would I guess heat it up and waste some power.

So dlloyd, you're suggesting to put the fan and the sensor and the 4k7+LED all in parallel? That will be fine for the sensor, and will get me the low from the output I'm looking for, but will cause my fan to blow more than desired, but I guess I could also put a resistor in front of it as well?

It will have no effect on the fan as it's connected across the 24V DC power source. It will provide about 4.7mA through the LED (using I=V/R, I=(24-2)/4700 = 4.7mA). You have +24 •---4.7K---•---►|---• (-)

The fan was not previously connected across 24v - it was connected in parallel with the sensor but in series with the LED, so the fan was only seeing 10v.

Did my replay of your suggested zener configuration make sense with respect to how it would work with the trigger low board sensor?

The fan was not previously connected across 24v - it was connected in parallel with the sensor but in series with the LED, so the fan was only seeing 10v.

It would be really good to know the purpose of the LED and fan.

… I want the LED and fan to both always be on, no change when sensor triggers or not …

From this, It seems the purpose of the LED is a power indicator for the 24V supply.

For the fan, it seems it’s for basic cooling, always running as long as 24V DC power is available.
If the fan is only rated for +12V, you’ll need a resistor connected in series with it. With a multimeter, you could measure the resistance across the fan, then use something very close to this for the series connected resistor value. The minimum power rating of the resistor would be I2R or V2/R where V =12V.

Did my replay of your suggested zener configuration make sense with respect to how it would work with the trigger low board sensor?

See reply#12 by Runaway Pancake