Hello all, I need some help if I just reading a voltage signal from a 1.2 MPa pressure sensor from a pin it will give a value in serial monitor. If I give pressure on the sensor the value is changing. Everything fine.
I am now adding some new code to transfer the voltage signal into a pressure value. This is the code:
#define SENSOR A0//the YELLOW pin of the Sensor is connected with A0 of Arduino/OPEN-SMART UNO R3
void setup()
{
Serial.begin(9600);
}
void loop()
{
int raw = analogRead(SENSOR);
Serial.println("Pressure is");
float pressure_MPa = (raw / 1024 - 0.1) / 0.75; // voltage to pressure
Serial.print(pressure_MPa);
Serial.println(" MPa");
delay(500);
}
after I uplaod the code 0.13 Mpa is shown, fine! Now when I am giving pressure on the sensor the value isn`t changing? Why is it like this? Is it just because I ony can see two decimal places? If yes how can I change the accurancy, to see more decimal places?
how can I change the accurancy, to see more decimal places?
The print method defaults to 2 decimal places when printing floats. There is an additional parameter that can be supplied to the print method to specify the number of decimal places.
I know that the sensor is working. But why is the pressure stated in the monitor not changing? Blowing the sensor should not go up to 1.2 Mpa taht is clear. But the pressure output should change a bit. But it does nothing!