Go Down

Topic: MPX5700GP pressure sensor (Read 572 times) previous topic - next topic

teutek213

Dec 07, 2017, 09:11 pm Last Edit: Dec 07, 2017, 09:29 pm by teutek213
Hello,

i have problem with my gauge pressure sensor

i found  2 different topics with MPX5700GP

https://forum.arduino.cc/index.php?topic=425830.0

https://forum.arduino.cc/index.php?topic=99381.0

an they still didnt solve my problems

maybe sth is with my sensor maybe with code or arduino idk :/

im using arduino nano with lcd and LCM1602

there is my code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);

void setup()
{
  lcd.begin(16, 2);
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home();

  lcd.print("Voltage");
  lcd.setCursor (0, 1);
  lcd.print("Pressure");
}

void loop()
{
// averaging for noise removal
  float sensorValue = analogRead(A0);
  float voltage = 5000.0 * sensorValue * (1.0/1024.0);  // mV
  float pressure = ((((voltage / 5) - 0.04) / 0.0012858)/1000.0) ;  // kPa
  lcd.setCursor (10,0);
  lcd.print(voltage);
  delay(500);
  lcd.setCursor (10,1);
  lcd.print(pressure);
  delay(500);
 
}


in attachments there is data sheet for this sensor

after vcc connection on display
i can see

voltage  258.79 (in mV)
and pressure 40.22 (and this in kPa)

this valuse sometimes are softly lower or higher but those are slight changes
so for me it is big offset of valid value


thank you in advance for any help  ;)  ;)


Wawa

#1
Dec 07, 2017, 11:15 pm Last Edit: Dec 07, 2017, 11:56 pm by Wawa
Not a good idea to see a pressure sensor as a voltmeter.
Your code assumes a 5.000volt supply, but a Nano on USB power is more like 4.6volt.
Sensors like this are ratiometric, and you should convert directly from A/D value to pressure.

Try this example.
I already calculated the offset and span for this MPX5700, but it might need finetuning.

Don't expect that a pressure sensor and 10-bit A/D (1024 values) can display 700 with two decimal places precision.
Leo..
Code: [Select]
// MPX5700 pressure sensor (700kPa)

int rawValue; // A/D readings
int offset = 41; // zero pressure adjust
int fullScale = 963; // max pressure (span) adjust
float pressure; // final pressure

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

void loop() {
  rawValue = analogRead(A0);
  pressure = (rawValue - offset) * 700.0 / (fullScale - offset); // pressure conversion

  Serial.print("Raw A/D is  ");
  Serial.print(rawValue);
  Serial.print("   Pressure is  ");
  Serial.print(pressure, 1); // one decimal places
  Serial.println("  kPa");
  delay(500);
}

Or, with a bit of averaging for a more stable readout and better offset adjustment.
Code: [Select]
// MPX5700 pressure sensor (700kPa)

int rawValue; // A/D readings
int offset = 410; // zero pressure adjust
int fullScale = 9630; // max pressure (span) adjust
float pressure; // final pressure

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

void loop() {
  rawValue = 0;
  for (int x = 0; x < 10; x++) rawValue = rawValue + analogRead(A0);
  pressure = (rawValue - offset) * 700.0 / (fullScale - offset); // pressure conversion

  Serial.print("Raw A/D is  ");
  Serial.print(rawValue);
  Serial.print("   Pressure is  ");
  Serial.print(pressure, 1); // one decimal places
  Serial.println("  kPa");
  delay(500);
}

 

Go Up