Digital Read From P-Channel Mosfet Drain

There’s a 10-12V gate voltage from a distant door contact sensor. I want to read that from Arduino. I used a P-Channel Mosfet for this.

For the source I connected 5V because I need a logic level output from the Mosfet drain. 10-12V for the gate. I connected a small cap because the sensor wire is more than 10M and a pull down resistor for avoid
unnecessary on offs due to static charges in gate.

This setup is Normaly Open(0V or pulled to ground in gate) and gives High Logic to Arduino. When sensor emits 10-12V to the Mosfet It will off and gives Low Logic.

I simulated this on Easy Eda. But I get a Noise from Mosfet Drain. I want to Know is it ok to Arduino. will it give floating Logics. If a connect a cap in drain in will reduce a lot. But I want to avoid because I already designed the pcb.

The simplest method for changing the 10-12V from the sensor to something acceptable to an arduino is potential divider using 2 resistors.

10uF is not a small capacitor (value).

I'm not so sure about your simulations. I guess you did one where the sensor voltage was 10 and the other where the sensor voltage was 0. Although the graphs show some oscillation, according to the voltage scale on the left, no measurable oscillation exists.

Use a resistive divider, upper resistor 15k, lower 10k, and add 100nF across the lower resistor if you have noise-pickup issues.

1st I thought about using a voltage divider. But if the length of the sensor cables increases voltage also drops. because of that it can't predict what the output will be for sure(For Arduino digital read). That's why I went for the Mosfet.

Yes you gussed it correct. 5-12V on the gate gives 0V on the drain(Low Logic). If gate is 0V or Pulled to GND drain gives 5V(High). The circuit is normally high.

I'm sceptical about the drain 5V oscillations wether it gives floating logics in Arduino. If it's not i'm good. I'm a software developer this is my 1st circuit design. I wanted to know this will work or not.

Another question:

I choosed 10uF cap for the gate because the sensor cable can vary from 10-30m or beyond until it gives minimum 5v on gate to turn off the Mosfet(Low) when triggered. I thought of giving a low noise constant voltage for the gate by using a cap. Am I correct in this. I choosed 10uF value because sensor triggeres for 10seconds. So it will charge quickly because of low capacitance and aslo discharge quickly becase of the pull down resistor below the cap.

Resistance of the sensor cables should be negligible, certainly compared to a voltage divider.

Screenshot (31).png

Screenshot (32).png

Screenshot (33).png

Unless your cable's made out of wet string voltage drop won't be a problem for a divider made from 10k or thereabouts resistors, the wires might be 5km long and it should still work, although the capacitor may need to
be larger to handle more interference pick-up.

Wires are around 30 to 300 ohms per km or so, compared to 10000 ohm divider impedance - orders of
magnitude different.

I'm going to use cat6 cable with 20-22AWG wires because I have few other cables going to the sensor. I ordered the parts today for the mosfet based one and will receive them tomorrow or so. I will test the mosfet and let you know. Otherwise I will use voltage divider as you all mentioned.

If I have a 500m 22AWG cable to the sensor. what will be a good capactiance. is 10uF is ok or low.

And thanks for all yor responses !!!