All,
Recently I purchased a DFRobot water pressure sensor. My "test" code is below. It appears to be functioning correctly although I did modify the sample code because I felt mine would give more accurate results.
Concern: I do not have a good way to test the pressure sensor unless I install into my application. The install is not easy and requires much work and time therefore I want to make certain my code is working correctly and accurately.
Does anyone have experience with the sensor? Does any have a sensor that can be tested with my code to confirm the function is 100% ok?
I am open to suggestions for my code. Please confirm it.
*Disclaimer: On the website it has examples of their code. I did not understand why they would multiple by 250 and 400... it confused me so I changed that portion of math based off what I thought was correct.
const float OffSet = .71 ; // See Calibration Note!
float V, V2Comp, PMpa, psi; // Voltage & Pressure
void setup() {
Serial.begin(9600);
Serial.println("/** Water Pressure Sensor Data **/");
}
void loop() {
//Connect sensor’s output (SIGNAL) to Analog 0
V = (5. / 1023.)*analogRead(0);
V2Comp = (V-OffSet); //Target should be 0.0V with no load, static.
PMpa = (1.0/4.5)*V2Comp;
psi = PMpa * 145.037738; //1Mpa = 145.037738psi
Serial.print("Voltage:");
Serial.print(V, 3);
Serial.print("V");
Serial.print(" Calibrated Voltage:");
Serial.print(V2Comp, 3);
Serial.print("V");
Serial.print(" Pressure(Mpa):");
Serial.print(PMpa, 3);
Serial.print(" Mpa");
Serial.print(" psi");
Serial.print(psi, 2);
Serial.println();
delay(3000);
}