# How does a pull up resistor change a voltage divider calculation?

I am using this proximity sensor with a raspberry pi. the sensor outputs a 24V signal when triggered, which I need to step down to 3.3V using a voltage divider so as to not blow out the pi. The datasheet shows that I need a pull-up resistor between the output signal and the 24V power, but I'm wondering how this would change the calculations for figuring out the right resistor values to use.

Not considering the pull up resistor, I'd pick 100ohm for R15 and 680ohm for R14 but I'm not sure how to factor in the pull up resistor (would it change the values or R14 and R15?) or how to find the right value for it.

• please add a circuit diagram Nov 5 at 17:02
• pull-up resistor between the output signal and the 24V power ... try putting the pullup resistor between the output signal and 3.3 V instead Nov 5 at 17:05
• Looks like open collector NPN or PNP output with a max VCE of 1.0V. What is your part number?
– vir
Nov 5 at 17:05
• it's the E1-D version for npn, e2-d for pnp Nov 5 at 17:07
• @LilMamiChula Well which one you have, NPN or PNP? Nov 5 at 17:15

So you are using the NPN output version.

You don't have to pull up the output to 24V.

So if the output is really just an NPN open collector output then you don't even need any resistors at all, just enable internal pull-up in software.

EDIT: It seems there are internal pull-ups or the sensor is not NPN type. It is also unclear how much current the device can sink or source. But according to your measurements it might have PNP output.

As the datasheet does not say how it works and how much current it can sink or source, to be on the safe side, the current should be kept below 1mA.

Just calculate a simple divider that divides 24V to 3.3V when 1mA flows through the divider. 1mA at 3.3V is obviously 3.3kohms and 1mA at 20.7V can be rounded to a resistor of 21k or 22k.

• the output is 24V with no resistors I need it to be 3.3 for the pi to read Nov 5 at 17:22
• @LilMamiChula If it has an NPN output then it should not be 24V but either open or grounded. How did you measure it? Nov 5 at 17:23
• with a multimeter between the output wire and ground Nov 5 at 17:24
• @LilMamiChula That's unfortunate, the datasheet you linked to does not mention anything about this. Are you sure about the part number? What if you put say 10kohm resistor to ground, what is the output voltage then? Maybe without load there is some leakage via some built-in snubber diode? Nov 5 at 17:26
• Assuming you have the PNP version, I would use higher value resistors than the ones in your original post. 780 ohms on 24V is 30mA which is within the datasheet limits but much more than you really need. Just multiply everything by 10 and go with 6k8 over 1k. Since the output is "open circuited" when the sensor is off, the 1k resistor acts as the pull-down.
– vir
Nov 5 at 17:45

The proximity switch has an NPN open-collector output.

It's to be wired as show below.

The Raspberry Pi input will normally be high and go low when the proximity switch senses.