Pressure Sensor, do I need better resolution?

Hi, I am trying to build a water pressure sensor with a cheap 100 psi pressure sensor off Amazon, I am using an Arduino Uno and have followed a guy on Youtubes tutorial, however the output is floating ie when no pressure the output is reading 6 - 8 psi, I know the resolution is 10 bit but my question is would a higher resolution help me and could I use an add on board ?

Thanks In Advance
Stuart B

Higher resolution would give you 6.02 -8,63 psi. Do higher resolution does not do what you think.

Hi Paul,

Is it a case of the actual pressure sensor has to be better ?

Thanks
Stuart B

Something is wrong, probably with the code and/or calibration.

Post the code, using code tags, and a link to the pressure sensor.

Hi,
This is the code from the link: Pressure Sensor - Arduino - YouTube

/* This example demonstrates how to take a standard 3-wire pressure transducer
 *  and read the analog signal, then convert the signal to a readable output and
 *  display it onto an LCD screen.
 *  
 *  Contact Tyler at tylerovens@me.com if you have any questions
 */

#include "Wire.h" //allows communication over i2c devices
#include "LiquidCrystal_I2C.h" //allows interfacing with LCD screens

const int pressureInput = A0; //select the analog input pin for the pressure transducer
const int pressureZero = 102.4; //analog reading of pressure transducer at 0psi
const int pressureMax = 921.6; //analog reading of pressure transducer at 100psi
const int pressuretransducermaxPSI = 100; //psi value of transducer being used
const int baudRate = 9600; //constant integer to set the baud rate for serial monitor
const int sensorreadDelay = 250; //constant integer to set the sensor read delay in milliseconds

float pressureValue = 0; //variable to store the value coming from the pressure transducer

LiquidCrystal_I2C lcd(0x3f, 20, 4); //sets the LCD I2C communication address; format(address, columns, rows)

void setup() //setup routine, runs once when system turned on or reset
{
  Serial.begin(baudRate); //initializes serial communication at set baud rate bits per second
  lcd.begin(); //initializes the LCD screen
}

void loop() //loop routine runs over and over again forever
{
  pressureValue = analogRead(pressureInput); //reads value from input pin and assigns to variable
  pressureValue = ((pressureValue-pressureZero)*pressuretransducermaxPSI)/(pressureMax-pressureZero); //conversion equation to convert analog reading to psi
  Serial.print(pressureValue, 1); //prints value from previous line to serial
  Serial.println("psi"); //prints label to serial
  lcd.setCursor(0,0); //sets cursor to column 0, row 0
  lcd.print("Pressure:"); //prints label
  lcd.print(pressureValue, 1); //prints pressure value to lcd screen, 1 digit on float
  lcd.print("psi"); //prints label after value
  lcd.print("   "); //to clear the display after large values or negatives
  delay(sensorreadDelay); //delay in milliseconds between read values
}

The sensor used is this one:

Thanks
Stuart B

If you are getting a reading of 6 - 8 psi with no pressure applied then I think you need to edit the value assigned to 'pressureZero' in the following line:

const int pressureZero = 102.4; //analog reading of pressure transducer at 0psi

Note that a value of 102.4 isn't an integer.

Hi John,

Thanks for the reply, do you know what might be making it float ? , it is on a breadboard, could that be it ?

Thanks
Stuart B

To calibrate the pressure sensor you need to first subtract off the reading you get when it is at zero relative pressure (exposed to the atmosphere). Then the output is scaled so that the pressure reading is correct when the sensor input is at a known higher pressure.

See this excellent tutorial: Why Calibrate? | Calibrating Sensors | Adafruit Learning System

These lines are obvious (non-fatal) programming errors and both comments are wrong, which makes me suspicious of the rest of the code:

const int pressureZero = 102.4; //analog reading of pressure transducer at 0psi
const int pressureMax = 921.6; //analog reading of pressure transducer at 100psi

Hi,
thanks for the link I will have a read

Stuart B

That means that the pressureZero value must be lowered a lot, maybe to about 55.
Change the value and upload until it displays as close to zero as possible.

The Arduino A/D returns integers.
Using a float with a decimal place indicates that the youtuber is a beginner. There are other things in the code which experienced coders would have done differently, like printing fixed LCD text in setup(). The display will now probably flicker.

Start by updating these lines

const int pressureZero = 55; // calibrate for zero pressure
const int pressureMax = 921; // calibrate if you can for max pressure
const float pressuretransducermaxPSI = 100.0;

Leo..

The first thing I would do is to print out the raw pressureValue in counts. This eliminates any code / conversion error.

The next step would be to add a 0.1µF capacitor to the input of the Arduino A/D pin to the closest Arduino ground. And add a 5k to 10k resistor in series with the pressure sensor signal. This will filter out any "noise" on the signal that could cause unstable readings.

Assuming the pressure transduce and the Uno are both connected to the same 5V. Then:

  • sensor voltage for each psi = 5/100 = 50mv/psi
  • A/D voltage for each count = 5/1024 = 4.88 mv / count

This gives you ~ 10 counts for each PSI. Adding resolution will give you no benefit.

Pressure Transducers:
This type of pressure transducer is notorious for zero pressure issues. The sense element is a disc of stainless steel with a strain gauge attached to it. Its very difficult for the mfg to keep the element from "oil canning" at zero pressure.
So I wouldn't worry too much about an offset at zero pressure.

Not exactly true.
Sensors like this usually have a limited output range of 0.5 to 4.5volt on a 5volt supply.
So only about 800 counts of a 10-bit A/D. Not quite enough to display 100 with one decimal place, unless you take multiple samples and average (smoothing code).
Can't say 50mV'psi (or 40mV/psi) either, because sensors like this are ratiometric, so mV/psi is supply dependent. Just stick with A/D counts per psi, and forget about 'volts'.

At least the ratiometric code the youtuber used is correct.
pressure = (A/D value - zero offset) * sensor rating / ( max A/D value at sensor rating - zero offset)

Good point. I certainly should have caught this as I've used similar transducers many times. Oh well, thanks for catching it.

Still the assumed voltage is 5V (unless the OP provides additional information) and the oil can issue is valid, especially on an cheap sensor.

So assuming it is a 0.5 to 4.5V sensor. That would put zero at approximately 102 counts.

To understand what the sensor is actually reporting, add the following print statements to the code you have now. They report the raw analog readings.

When the sensor input port is exposed to the atmosphere, the value that is reported should (later) be subtracted as the "pressureZero" offset. Let us know what you find.

  pressureValue = analogRead(pressureInput); //reads value from input pin and assigns to variable
Serial.print(" raw: ");
Serial.println(pressureValue);  //print raw analog reading

102 is in the original code, and OP said that zero pressure displays 6 to 8 psi.
That makes me think it's a 0.25volt to 4.75volt sensor.
That would put zero at 51.
Leo..

I didn't read through the code (not my strong point). However I've seen a LOT of pressure transducers working in automotive and I've never seen a 0.25 to 4.75. I can't say such a transducer doesn't exist but it would be a rare bird.

Without additional information I would say your suggestion of 0.5 to 4.5 is most likely with the remainder being just a poor zero on a low cost pressure sensor. But I guess well see....

First random Google hit.
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.