MPS20N0040D Barometric Pressure sensor displays a negative number result even though the sensor has not been applied pressure. is there a problem in my code or is my sensor problematic. for the module on this sensor HX710B, and the library that I use is HX710B-base_pressure_sensor. library from roland pelayo
#include "HX710B.h"
const int DOUT_Pin = D2; // Pin data sensor
const int SCLK_Pin = D3; // Pin clock sensor
HX710B pressure_sensor;
void setup() {
Serial.begin(9600);
pressure_sensor.begin(DOUT_Pin, SCLK_Pin, 128); // Gunakan faktor penguatan default 128
}
void loop() {
if (pressure_sensor.is_ready()) {
Serial.print("Pascal: ");
Serial.println(pressure_sensor.pascal());
// Di sini Anda bisa melakukan sesuatu dengan data yang diperoleh dari sensor
} else {
Serial.println("Pressure sensor not found.");
}
delay(3000);
}
The code is from the sample library. but I changed it a little because it was problematic when compiling the code, when I applied pressure, the sensor reading changed or read
I believe what you are seeing is a zero offset error in the sensor. If this sensor is the one that has a range of 0 to 40kPa then 45 Pa is in the order of 0.1% error. Basically no error.
Also know a reading of 0 is difficult for many sensors due to the change in direction of the force.
That's a 3.3volt-logic processor, so you should power the sensor from the 3.3volt pin of the ESP.
The line of code I gave you over-writes the offset that is already used in the library.
You can find it in line28 of the HX710B.h file (-540000).
Leo..
Exactly.
When we pick a sensor we should stop for a minute and try to understand how that specific sensor is working, what is the range that it can measure an so on. If this sensor has a range of 0-40000Pa, I'm sure it's not built to measure changes in 0-40Pa range, but fine to sense difference between 10kPa and 11kPa. Also the output is really just a number that we want it rappresentate, maybe you want this sensor to output 0 when no external load, or maybe 101kPa, the atmospheric pressure.