Supports pressure measurement in Pascals (Pa).
For conversion to other units then see: http://en.wikipedia.org/wiki/Pascal_(unit)
Since all of the devices have been implemented in the same way then it means that you can swap one device for another by only changing the #include and the MAKE command used to create the device.
So here is the generic way to work with a <DEVICE> of a given <MAKE> and <MODEL>:-
// Include the relevant sensor file
// Create the device
<DEVICE> myPressure = MAKE_<DEVICE>(ADC pin);
In your appInitHardware you should initialise the device:-
Then in your main loop you can read the sensor using:-
The value can then be read independently into a variable of type 'PRESSURE_TYPE':-
PRESSURE_TYPE pascal = myPressure.pressure.pa;
This can be printed out using:
Or dumped to the current rprintf destination using:-
Pressure readings are often used to calculate altitude or depth under water. WebbotLib provides these calculations for you as follows:-
double depth = pressureRelativeDepth(myPressure);
returns the underwater depth in meters of the device relative to when power was turned on. So make sure your vessel is floating on the surface when it is switched on.
double altitude = pressureAltitude(myPressure);
returns the current altitude (in air) in meters above, or below, sea level.
double height = pressureRelativeAltitude(myPressure);
returns the altitude of the device (in air) in meters above, or below, the location where the power was turned on. Note that this is only equivalent to the height above ground if the whole terrain is totally flat.
- Motorola/MPX5100a.h - Motorola pressure sensor returning 45mV per kPa.
- Bosch/BMP085.h - Bosch I2C pressure and temperature sensor capable of measuring 30000 Pa to 110000 Pa. Equivalent to 500m below sea level up to 9,000m above sea level.