I want to use water flow sensor using Raspberry Pi 2 but the water flow sensor accepts only 5v as a input and gives the pulses of 5v as a output but my Raspberry Pi can take only 3.3v.

Is this possible to implement?

And if possible code please.

  • 1
    Could you post a link to the sensor you are using so we can check the details?
    – joan
    Commented Apr 27, 2017 at 12:24

1 Answer 1


This is no software issue.

Look at the sensor's datasheet, it might be able to operate at 3.3V just fine. If it doesn't, you have to build a voltage divider between the sensor's output and your Pi's input.

This question decides whether to connect the sensor's voltage in to 5V or 3V! In turn, it determines the maximum voltage applied to Pi' GPIOs. So never connect it to 5V without the voltage divider!

Assuming your sensor requires almost no power, this can be achieved easily with for example 3x 10K Ohm resistors.

R2 = 10K
R1 = 5K (2x 10K in parallel)
Hence, 10K/15K =~ 0.66
0.66 * 5V = 3.3V

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.