ADC conversion factor

Hi,

I am trying to convert an analog pressure readings into bar values using Arduino Uno.

Reading the pressure with a digital gauge and DMM I found:
Pressure range: 0.00bar to 1.50bar
Voltage range: 0.70V to 1.40V

The voltage conversion result is correct while the bar result is not as you can see in the attached result.
correctV_wrongB
Surely the conversion used to get the bar is not correct.

bar = (avrageAdc - minAdc) * maxBar / (maxAdc - minAdc);

Thanks

You simply solve y = mx + c equation; as a result, the raw pressure will come out exactly in the calibrated form.

it depend on wich µC you use, due to voltage and ADC bits

Thanks both.
I went on averaging the ADC from 50 samples instead of 10 and get better results.

@frfn
This is the correct equation
float voltage = analogRead (A0) * 5.0/1023.0
pressure = ((1.5/0.7) * voltage) - 1.5

float pressure=( analogRead(A0)  - 143 ) / 95.333 ;
1 Like

Try this sketch with Sensor connected at A0-pin of UNO:

void setup()
{
    Serial.begin(9600);
    analogReference(DEFAULT);
}

void loop()
{
      float digitalBar = (7.5/716.1)*analogRead(A0) - 1.5;
      Serial.print("Pressure: ");
      Serial.print(digitalBar, 1); Serial.prinln(" Bar);
      delay(1000);
}

If analogRead is zero you would get a negative pressure, Is that possible?

OP will answer to this question as he has clearly given the following two points responses of his sensor based on which the equation is derived by me and by @kolaha of post #6.

A(0.7 V, 0.00 Bar)
B(1.40 V, 1.50 Bar)
Q(V, Bar)
===> Bar = (7.5/716.1)*analogRead(A0) - 1.5

Is that a YES or a NO?

Theoretically, yes!

not correct. because:

a(0.0V, -1.50 Bar)
A(0.7 V, 0.00 Bar)
B(1.40 V, 1.50 Bar)

(7.5/716.1)* 0 is not -1.5

Sorry for the mistake!

===> Bar = (7.5/716.1)*analogRead(A0) - 1.5

Couple of points .

  1. If your transducer is not a ratiometric device then you will get inaccuracy using the default ADC reference .
  2. The map function will sort your y=mx+c
  3. Beware maths ! You are using small portion of the ADC range ( default ref ) so your resolution will not be great and multiply/dividing by high resolution numbers is meaningless and. Can mislead you ( eg thinking you have 1.005bar when it’s somewhere between 0.9 and 1.1 from ADC Resolution )
  4. Really you need to calibrate with known pressures and read the corresponding ADC numbers and use those numbers in map.
  5. Work in integers , say in 1/10’bar to keep in whole numbers and correct at the output .
1 Like

It's not exactly a straight line so my equation will be a little off on the high end

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