So I have this costume Pressure sensor that I have tried to program it a couple of times and I'm not reading the right values. See below for the coding. I only need to read the analog voltage and convert it to mmHg (units of air Pressure). Also I have attached the data sheet of the pressure sensor. Any help will be appreciated.
Thanks.
How did you come up with these numbers for the offset, Full Scale and the Pressure formula? could you explain a little, I'm kinda new to these stuff, any explanation will clarify a lot of things.
~0.625volt will display 30mmHg.
What do you want in the serial monitor. A fake value?
Change 300 into 3000, and you see 10x the value on the serial monitor.
One decimal place with 300mmHg is already pushing it over the limit, because you only have 768 values (819-51) to work with, and 300.0 is 3000 values.
If you want bar or psi or anything else, feel free to change that number "300" into anything you like.
Leo..
aghaderi2006:
How did you come up with these numbers for the offset, Full Scale and the Pressure formula? could you explain a little, I'm kinda new to these stuff, any explanation will clarify a lot of things.
If you look at the datasheet of the sensor, you see that the sensor outputs ~0.25volt at zero pressure.
And 4volt at max pressure of 300mmHg.
0.25volt on the analogue input is a digital value of 1024/5 * 0.25 = 51
4volt volt is 1024/5 *4 = 819
The rest is just maths.
You should at least calibrate the zero offset.
Change the offset value by +/-1, and re-upload untill you have 0mmHg in the serial monitor at zero pressure.
Leo..
This will get you a higher granularity (more values) if you just want to use the values to do something with.
Control LEDs, motors, etc.
Output is ~250-1023.
Use "map" to scale it to e.g. 0-256.
Leo..
So I have a have a hand manometer connected directly to the pressure sensor. On the gauge I can read 300mmHg and when I measure the voltage of the pressure sensor, As you mentioned that "30mmHg should be ~0.625volt, and 300mmHg should be ~4volt." I read these exact values, However on the serial monitor I see 30mmHg when I pressurize the pressure sensor to 300mmHg. I understand your calculations but why the pressure sensor is showing the right voltage and the micro controller is reading 30 mmHg ? The hand Manometer is calibrated and the pressure sensor is new (I tried at least 3 pressure sensors) but no luck.
Thanks the Code works as a champ. Hey one quick question though, Is there any way that I could write a .TXT file or a scrip to be able to change the offset and the Fullscale numbers without uploading the hole code to the Arduino every single time. Something that I could change in the .TXT file and it will effect the offset and the Fullscale numbers in general without uploading the code.