MPX5700 Pressure Sensor

Ok so this is the bit that confuses me ... i have the code displaying the sensor value on a lcd and all nicely .... Now i need that sensor value to be in PSI or Bar so it makes sense .... I have the data sheet here : http://docs-europe.electrocomponents.com/webdocs/0ef4/0900766b80ef41d6.pdf

The closest code i could find to do this is a for somewhat the same sensor but its max read is a whole lot less than this model ...

void loop()
{
mapval= analogRead(mapsen); //Reads the MAP sensor raw value on analog port 0
boost = (mapval*(.00488)/(.022)*(0.145)-14.5); //Converts raw MAP value to PSI and accounts for atmospheric pressure

This code is for a boost gauge above , im using it as a example to follow and also to show you guys the part that puzzles me ...

I'm using this sensor to read air pressure for my air suspension in my car so i don't need to account for atmospheric pressure ... Which i guess is the -14.5 off the end i think ... I would be very grateful if someone could help me out here thanks again :slight_smile:

if you look at page 4 you see there is a discontinuity in the graph and your formula doesn't cope with that,
Further you have rounded the floats a bit I think and given that the sensor itself has an error of ~2.5% that may easy add up to 5% or more in the end result.

So code to try and tweak :slight_smile:

void loop()
{
  // MEASUREMENT
  int raw = analogRead(mapsen); //Reads the MAP sensor raw value on analog port 0

  float voltage = raw * 0.004887586;  // let the compiler determine how many digits it can handle
  float pressure = 0.0;
 
  // MATH
  if (voltage < 4.6)
  {
    pressure = voltage * 700.0/4.6;   // it raises 700KPA over 4.6 volt      faster =>   pressure =  voltage * 152.173913;
  }
  else
  {
    pressure = 700 + (voltage-4.6) * 100 / 0.3;   //   last piece raises  100KPa over 0.3 Volt.   // can be optimized to   p = c1 + v * c2
  }

  // DISPLAY
  Serial.print("KPa:\t");
  Serial.println(pressure,  3 ); 
  Serial.print("PSI:\t");
  Serial.println(pressure*0.145037738,  3 );   // convert to PSI
}

pressure = voltage * 700.0/4.6;
might need to be
pressure = (voltage - zeroPressureOffset) * 700.0/4.6;

4.6 is the value where the discontinuity is (imho)

update: fixed typo in code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int mapsen = 1; // Set MAP sensor input on Analog port 0
int mapval;


void setup(){
  
  Serial.begin(9600); // Open serial port
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Air Suspension");
  lcd.setCursor(0,1);
  lcd.print("Gauge");
  delay(1000);
  lcd.clear();
}

void loop()
{
  // MEASUREMENT
  int raw = analogRead(mapsen); //Reads the MAP sensor raw value on analog port 0

  float voltage = mapval * 0.004887586;  // let the compiler determine how many digits it can handle
  float pressure = 0.0;
 
  // MATH
  if (voltage < 4.6)
  {
    pressure = voltage * 700.0/4.6;   // it raises 700KPA over 4.6 volt      faster =>   pressure =  voltage * 152.173913;
  }
  else
  {
    pressure = 700 + (voltage-4.6) * 100 / 0.3;   //   last piece raises  100KPa over 0.3 Volt.   // can be optimized to   p = c1 + v * c2
  }

  // DISPLAY
  Serial.print(mapsen);
  Serial.print("KPa:\t");
  Serial.println(pressure,  3 ); 
  Serial.print("PSI:\t");
  Serial.println(pressure*0.145037738,  3 );   // convert to PSI
  delay(1000);

 
}

I'm constantly getting "0.00" it never changes .... I think my code may be wrong

Thanks for you help mate cheers

use raw iso mapval ;):

  // MEASUREMENT
  int raw = analogRead(mapsen); //Reads the MAP sensor raw value on analog port 0

  float voltage = raw * 0.004887586;  // let the compiler determine how many digits it can handle
  float pressure = 0.0;
  ...

Thanks so much ...

Studied your code and i am now able to understand how it actually works :slight_smile: :slight_smile:

So I hope you guys can help me out! I'm using this same sensor.. although I probably shouldn't be, but I can't seem to get it to read correctly! The max pressure I'll be reading is about 30psi.. but It's off by about 3 or 4 psi? :confused: Here's my code.. am I missing something? Btw sorry for reviving a dead thread..

When sitting in a regular room with no load.. It reads ~18psi :confused: and it should be reading 14.7 or so right?

void showBoost()
{
  float voltage = 0;
  float mInput = 0;

  voltage = analogRead(Boost) * 0.004887586;
 
  if (voltage < 4.6)
  {
    mInput = voltage * 700.0/4.6;   // it raises 700KPA over 4.6 volt      faster =>   pressure =  voltage * 152.173913;
  }
  else
  {
    mInput = 700 + (voltage-4.6) * 100 / 0.3;   //   last piece raises  100KPa over 0.3 Volt.   // can be optimized to   p = c1 + v * c2
  }
 
  mInput = mInput * 0.145037738;

  //go display it
}

Friend Do you still have the programming code?