Atmospheric Pressure Sensor MPX4250DP

hello everybody

I don't know if any one can help me and i'am so thankful

I search to understand the Nominal Data Value for my Pressure Sensor MPX4250DP that i'am using to calculate the atmospheric pressure and how to make it into my arduino code :slight_smile:

Here is the Nominal Transfer Value:


*Vout = VS x (0.00369 x P + 0.04) *
± (Pressure Error x Temp. Factor x 0.00369 x VS)
*VS = 5.1 ± 0.25 Vdc *


and here is my arduino code

void setup() {
Serial.begin(9600);
}
void loop(){
float pressure = readPressure(A1);
float hpascal = pressure/100;
Serial.println();
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" pascals");
Serial.print("Pressure = ");
Serial.print(hpascal);
Serial.println(" hpascal");
delay(100);
}
/* Reads pressure from the given pin.
* Returns a value in Pascals
*/
float readPressure(int pin){
int pressureValue = analogRead(pin);
float pressure=     (******************************************) nominal tranfer value is missing                               
return pressure;
}

This is what displays

Pressure = 464090.37 pascals
Pressure = 4640.90 hpascal

i'm waiting for your help thanks and so sorry for my bad english

hmm - I have not used that sensor, but like most analog sensors, its most likely returns a voltage, not the pressure. have you tried the map function? for analog inputs, I usually do:

int x = analogRead(A0);
x = map(x, 0, 1023, 0, 180);

the map function takes the var x (your raw sensor voltage) and maps it from 0-1023 (its analog range) to - any range you like. in my example, 0-180.

based on your sensor, it will likely need to be mapped to a specific range. that I dont know.

The down-side of using the map() function is that it only returns integer values. This may well be quite suitable for your application, so I'd try something like...

return map(ADCvalue, 41, 986, 0, 256);

I've calculated (very quickly) those figures from the datasheet and they should give you a fairly reasonable reading in kPa.
If you want a floating point result then use the formula kPa = ((ADCvalue / 1024.0) -0.04) / 0.00369

Hope that helps.