Hi, I am doing a project with an MPX 5700DP pressure sensor, along with a 20x4 lcd screen to display the pressure data. In the first project I used an MPX5700AP and using the first program I attached it worked.
On the other hand, in the second project I had to change the sensor for the MPX5700DP, in the same way I only need an air inlet, but the pressure does not feel on the screen and the value is negative.
Code with sensor MPX5700AP
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F //0x38 Simulación 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
//LiquidCrystal_I2C lcd ( 0x3F , 2 , 1 , 0 , 4 , 5 , 6 , 7 );
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
/*int rawValue; // Lectura A/D
int offset = 45; // Ajuste en cero (valor recomendado 410)
int fullScale = 980; // ajuste en presión maxima (valor recomendado 9630)
float pressure; // presion en kpa
float pressurepsi; // presion en psi*/
int rawValue; // Lectura A/D
int offset = 480;//45; // Ajuste en cero (valor recomendado 410)
int fullScale =9630;// 980; // ajuste en presión maxima (valor recomendado 9630)
float pressure; // presion en kpa
float pressurepsi; // presion en psi
void setup() {
//Serial.begin(9600); // monitor para probar sensor por software
lcd.begin(20,4); // Inicia el LCD 20x04 (columnas,filas)
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home(); // Coloca el cursor en las coordenadas (0,0)
lcd.print(" ENDOSEC "); // Escribe en el LCD
lcd.setCursor(0,1); // Coloca el cursor en las coordenadas (0,1)
lcd.print("Presion: "); // Escribe en el LCD
}
void loop() {
rawValue = 0;
for (int x = 0; x < 10; x++) rawValue = rawValue + analogRead(A0);
pressure = (rawValue - offset) * 700.0 / (fullScale - offset); // conversión de la presion
pressurepsi = pressure/6.895; // de kpa a psi
Serial.print("Raw A/D is ");
Serial.print(rawValue);
Serial.print(" Pressure is ");
Serial.print(pressurepsi, 1); // un decimal
Serial.println(" PSI");
delay(500);
lcd.setCursor(9,1); // Coloca el cursor en las coordenadas (6,1)
lcd.print(pressurepsi, 1); // Escribe en el LCD con un decimal
lcd.setCursor(13,1);
lcd.print(" PSI ");
delay(100);
lcd.setCursor(0,4);
lcd.print("Cel:311 387 0563");
}
Second code with sensor MPX 5700DP
//Secadora de material endoscopico
//EndoCol SAS
// Manizales Caldas
// 30/01/2020
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F //0x38 Simulación 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
//LiquidCrystal_I2C lcd ( 0x3F , 2 , 1 , 0 , 4 , 5 , 6 , 7 );
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
/*int rawValue; // Lectura A/D
int offset = 45; // Ajuste en cero (valor recomendado 410)
int fullScale = 980; // ajuste en presión maxima (valor recomendado 9630)
float pressure; // presion en kpa
float pressurepsi; // presion en psi*/
int rawValue; // Lectura A/D
int offset = 45;//45; // Ajuste en cero (valor recomendado 410)
int fullScale = 980;// 980; // ajuste en presión maxima (valor recomendado 9630)
float pressure; // presion en kpa
float pressurepsi; // presion en psi
void setup() {
//Serial.begin(9600); // monitor para probar sensor por software
lcd.begin(20,4); // Inicia el LCD 20x04 (columnas,filas)
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home(); // Coloca el cursor en las coordenadas (0,0)
lcd.print(" ENDOSEC "); // Escribe en el LCD
lcd.setCursor(0,1); // Coloca el cursor en las coordenadas (0,1)
lcd.print("Presion: "); // Escribe en el LCD
}
void loop() {
rawValue = 0;
for (int x = 0; x < 10; x++) rawValue = rawValue + analogRead(A0);
pressure = (rawValue - offset) * 700.0 / (fullScale - offset); // conversión de la presion
pressurepsi = pressure/6.895; // de kpa a psi
Serial.print("Raw A/D is ");
Serial.print(rawValue);
Serial.print(" Pressure is ");
Serial.print(pressurepsi, 1); // un decimal
Serial.println(" PSI");
delay(500);
lcd.setCursor(9,1); // Coloca el cursor en las coordenadas (6,1)
lcd.print(pressurepsi, 1); // Escribe en el LCD con un decimal
lcd.setCursor(13,1);
lcd.print(" PSI ");
delay(100);
lcd.setCursor(0,4);
lcd.print("Cel:311 387 0563");
}