I have a normal 3 line (V,GND,SIG) Analog pressure sensor and I want to connect and read data using Raspberry Pi GPIO. Can anyone help with a Python code?

Pressure sensor

ebay link

  • What is a standard pressure sensor? Similar looking sensors or those with the same number of wires can be very different when it comes to interface and software. Is that a digital sensor? Please edit your question and add a link to the datasheet and a link to where you purchased it. Commented Aug 29, 2016 at 7:21
  • "Normal analog pressure sensor" is meaningless. Does the device have part number? Further, just because a device is "analog" does not necessarily tell us anything about its interface. This could well be an analog device (i.e. it reads pressure) with a digital interface. Equally, it could be a digital device (i.e. tells us when a particular setpoint has been achieved) but not give any indication of what the pressure is.
    – KDM
    Commented Sep 12, 2018 at 21:29

3 Answers 3


Raspberry pi does not have any Analog input so you will need an external ADC. Your sensor is 5V, so go with a 5V torrent ADC. you can use ADS1115 because it has 4 ADC channels so you can connect upto 4 sensor to one board. it has inbuilt voltage ref so you dont need any external Vref. its a 16 bit ADC so your readings will be highly accurate. it also has gain multiplier. its input are 5V torrent.

You can find the python code for ADC ADS1115 over here

if you are looking for video tutorial for connecting an ADC with raspberry pi please check over here. interfacing ADC with raspberry Pi


You are going to have a few problems with the Pi. These problems are not insurmountable.

  1. The first is the Pi does not have any analog inputs.
  2. Second the sensor requires 5V as input and the Pi operates at 3.3V and will not tolerate 5V.

This tutorial on reading analog values with an ADC an the PI includes Python code.

You will also need a way to convert the 5V sensor to 3.3V for the Pi (e.g. logic level shifter, a voltage divider etc.) This related question will have some additional specifics.


While the OP probably figured out a solution, I stumbled across this question on my own search for how to get meaningful readings out of what I think is the same sensor. I am hoping this info may help others.

I'm not sure who the actual manufacturer is but LOTS of people sell the same sensor under various brands for water and fuel applications with a working range of 0 to 1.2 mPa (approximately 0 - 175 psi). The reason I suspect it is the same is that the product photo is identical to the manufacturer photo used by some of the suppliers.

It is indeed an analog device and as mentioned previously requires an A/D converter to work with the RPi. The 5v nature of the device is not a concern since the ADC merely provides a numeric value to the RPi via spi or i2c representing the voltage. Most ADCs accept up to 5V in. Some ADCs allow you to switch the VCC from 5v to 3.3v if you want to be consistent with the RPi and avoid problems in case you accidentally connect it to the RPi directly.

However, the output of the device is really just a function of voltage in and you can also run in on 3.3v if it makes you feel more comfortable.

All that said, similar-looking sensors run at also much lower pressures (0-10 psi, for instance) and their performance will be very different. Regardless it is necessary to locate the vendor-specific piece of info for your device that explains the transfer function.

In the case of what I think is this sensor, the function is Vout = Vcc(.66667 * P + .1) This info is also embedded in a few python examples that are floating around out there for reading this sensor.

For example, at 100psi (.69 mPa) and 5v Vcc, you should see something like:

5 * (.66667 * .69 + .1) = 2.8v

Note that if you used 3.3v as Vcc you would get something more like 1.848v out reported to your ADC.

Note that both the constants ".66667" and ".1" can also be thought of as a voltage bias that may vary depending on whether a pull-up, pull-down, or current limiting resistor is used; some ADC modules provide this circuitry built-in and already account for it.

If you bought a naked ADC such as the 16 channel PI-16ADC, you may have done so externally, although pull up/down resistors are probably not needed for this device in most applications. You may need to fiddle with these numbers and compare them to a known pressure reference. Note that the curve is at least linear ;)

Pressure Transducer Transfer Function

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.