I am working with GPIO where I want to read a vacuum sensor's output voltage. Using a voltmeter from the output to the pi's ground, I measured the voltages.

  • ON State: 21V
  • OFF State: 15V I know that GPIO is designed to only receive 3.3v for input. How can I wire the pi so that it can receive the vacuum sensor's output without damaging the pi?

Here is a related link that I looked at: Connecting 15V to GPIO w/o dividing voltage

If there are any components that I have to purchase to make this work, please let me know.

Thank You!

  • Might be easiest to use a voltage divider to reduce the voltage and a ADC chip to read the analogue voltage.
    – CoderMike
    Commented Jul 30, 2023 at 19:18
  • what is preventing you from supplying the vacuum sensor with lower voltage?
    – jsotola
    Commented Jul 30, 2023 at 19:47
  • jsotola, The vacuum switch is rated 10.8 to 30 VCC. We are currently supplying it 24V. We could supply it less voltage, but it would still be over 3.3V.
    – Danny
    Commented Jul 30, 2023 at 22:54
  • This is not a Pi question but about designing a circuit to connect to an unspecified source. If the device ACTUALLY returns those voltages it would difficult to detect the 7:5 change in value without some external electronics. I expect the voltages you measure are an artefact of the circuit and would vary with loading.
    – Milliways
    Commented Jul 31, 2023 at 4:02

2 Answers 2


The pi is very sensitive when it comes to the tension on the GPIO. When you are working with higher tensions, be very careful.

I would use an opto-coupler to protect my Pi.

enter image description here

Your zener would be somewhere above 15V. The resistor on the led-side of the opto-coupler depends on the zener value and the opto-coupler that is used..


To me it looks more of an analog job than digital one. Since the Pi doesn't have analog pis you may be a bit far from your objective.

Using what "Ljm Dullaart" described will work to detect a single level of voltage (either 15V or 21V), so I don't see that as a great solution.

I would go with an analog to digital converter, something along these lines: How can I use the raspberry pi to read analog voltages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.