I bought MPX5500DP Pressure Sensor that capable to output analog value for pressure range 0 to 500 kPa (kilopascal). I googled "mpx5500dp arduino" and found sample code and some information from Learn.Parallax.Com.
Gathered info from MPX5500DP datasheet.
0 to 500 kPa
0.2 to 4.7v output.
I wired the sensor to my Arduino Nano according to wiring guide from Learn.Parallax.Com. Compile and upload code to my Arduino Nano. With no pressure applied to both port of MPX5500DP, I got 16, 17 analog value reading from pin A0.
I'm a little bit confused with the readings.
If I reads 16, does it means that current pressure is 16 kPa?
Info from datasheet stated that output is 0.2 to 4.7v. I am using map function to map the analog value to pressure value. If map(sensorValue,0,1023,0.2,4.7) is correct? Or I need to use the basic value of analog voltage range 0 to 5v = map(sensorValue,0,1023,0,5)?
Kindly need more information related to MPX5500DP or similar pressure sensor. Thanks.
i compiled your sketch, and this is the result received from serial monitor.
Raw A/D is 37 The pressure is -39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 37 The pressure is -39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 37 The pressure is -39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 37 The pressure is -39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
Raw A/D is 36 The pressure is 39 kPa
No, it means the analog voltage is sixteen 1023rds of 5V
Using map() like that, you should be aware that an analog reading of 0 means there is 0 V on the pin. 1023 is 5V
This sensor can actually measure a little bit into the negative, when the pressure on P2 is higher than P1. I don't know if that is useful to you.
Currently i want to detect positive pressure, so I will connect pressure tube to P1, so P1 > P2. So, what if I use map from A/D reading remap to sensor pressure detection range? Like this.
KPAVAL = map(sensorValue, 0, 1023, 0, 500);
So, the KPAVAL is the current detected pressure. I am also eeed some guidance on calibration, offset, fullscale...
int offset = 36; // zero pressure adjust
int fullScale = 922; // max pressure (span) adjust
float pressure; // final pressure
void setup() {
Serial.begin(9600);
}
void loop() {
rawValue = analogRead(A0);
Serial.print("Raw A/D is ");
Serial.print(rawValue);
pressure = (rawValue - offset) * 500.0 / (fullScale - offset); // pressure conversion
Serial.print(" The pressure is ");
Serial.print(pressure, 1); // one decimal place
Serial.println(" kPa");
delay(500); // delays readings
}
Edit.
Corrected an error in the code. Please reload.
As you see, the decimal value jumps in ~0.5kPa increments when I added a decimal place.
That can be fixed with oversampling code.
compiled and uploaded this code. result as below:
Raw A/D is 36 The pressure is 0.0 kPa
Raw A/D is 37 The pressure is 0.6 kPa
Raw A/D is 37 The pressure is 0.6 kPa
Raw A/D is 37 The pressure is 0.6 kPa
Raw A/D is 36 The pressure is 0.0 kPa
Raw A/D is 37 The pressure is 0.6 kPa
Raw A/D is 36 The pressure is 0.0 kPa
Raw A/D is 36 The pressure is 0.0 kPa
Raw A/D is 36 The pressure is 0.0 kPa
Raw A/D is 36 The pressure is 0.0 kPa
Sir, what is fullscale function and value 922? Can you explain it a little. And what is "oversampling code"? Sorry for asking too much questions, learning..
The "offset" value can be changes (slightly) so that 0 kPa pressure on the sensor will read 0 kPa in the serial monitor.
I used 36, because that is what you had (raw) in the serial monitor with zero pressure.
The "fullScale" value can be changes (slightly) so that 500 kPa pressure on the sensor will read 500 kPa in the serial monitor.
I have calculated it for "500kPa=4.5volt" >> 4.5/5 * 1024 = ~922.
If you say "500kPa=4.7volt" then it should be >> 4.7/5 * 1024 = ~963
Oversampling (accumulated readings) is not needed if you're happy with a 0-500kPa readout.
If you want a decimal place, e.g. 350.4kPa, then you need oversampling.
Because 500.0kPa is 5000 values, and you only have ~900 (922-36).
You need to read the analogue input at least six times to have that granulation.
Leo..
Raw A/D is 542 The pressure is -14 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 0 The pressure is -27 kPa
Raw A/D is 481 The pressure is 25 kPa
Raw A/D is 1023 The pressure is -45 kPa
Raw A/D is 1023 The pressure is -45 kPa
Raw A/D is 1023 The pressure is -45 kPa
Raw A/D is 1023 The pressure is -45 kPa
Hi
I am a newbie here. Could you please let me know why is that I receive inconsistent values even if I dont provide any pressure? and mostly it is 1023 and 0?