Sinking output switch

Greetings! Hope you're doing great!

On a project I'm developing, I need a sinking digital output from the PLC, wiring it to my ESP8266 module. In other words, my input will be, either an Open circuit (with the proper pull up resistor to 3V3 included), or a connection to GND.

The problem is, that the PLC provides a Sourcing Digital Output of 24 VDC.

I know this can be solved by switching an output properly. Thus I've 2 options:

  1. Use a relay, it's simple, but since I may have fast switching sometimes, I wouldn't like to rely on it.

  2. Use an electronic switch, to which a transistor circuit will do just fine. All I want is to have my 24V output from the PLC as a control input to the transistor, obviously wired an regulated properly. I don't know what kind of circuit could I use for this, or how to set the resistor values. I'll apretiate any kind of help.

Hello
You can use an opto coupler too.

or two resistors (+1) as a voltage divider.

I'd go for a voltage divider also for your case.

This is a useful tool to calculate the resistor values...

R1 of 6.8k, and R2 of 1k, will give Vout of about 3v from a 24v source voltage.

Yeah, I considered the voltage divider for reducing the 24V input to something the transistor can handle better.

I was talking about the circuit to convert a PNP output to a NPN one.