/*===========================================================================
I’m trying to read the pressure from a pressure sensor. I have a math equation that I think is correct and a map() statement. The equation is close to the reading on an old pressure gauge I have. Where the mep() statement is about 1 lb or higher than the gauge. I would think the two should be about the same.
SSCSNBN015PGAB5 Pressure Sensor - ( Mouser # 785-SSCSNBN015PGAB5 )
The analog reading goes from 0 to 1023 for a 5 volt supply.
The sensor delivers 0.25 volts for 0 PSI and 4.75 volts for 15 PSI.
0.25 volts is an analog reading of 51.15 for 0 PSI
4.75 volts is an analog reading of 971.85 for 15 PSI
So the formula is Pressure (PSI) = (ANALOGE READING - 51.15)15/(971.58 - 51.15)
971.85 - 51.15 = 920.7
Pricision Liquid Level measurement using arduino RDS 8-27-18
==============================================================================/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float raw;
float psi1;
long int psi2;
void setup(){
lcd.begin(16,2);
Serial.begin(9600);
}
void loop() {
psi1 = ((analogRead(A0)-51.15)*15)/920.7; // variation on the Arduino map() function
raw = analogRead(A0); // MEASUREMENT
raw = raw * 100; // remove decimal point
psi2 = map(raw,-51.15,971.85,0,15); // Arduino map() function
psi2 = psi2 / 100; // add decimal point back in
lcd.setCursor(0 , 0);
lcd.print("psi-1"); // psi 1
lcd.print(psi1);
lcd.setCursor(0 , 1);
lcd.print("psi-2"); // psi 2
lcd.print(psi2);
Serial.print("psi-1 "); // psi 1
Serial.print(psi1);
Serial.print(" ");
Serial.print("psi-2 "); // psi 2
Serial.println(psi2);
delay(1000);
}