Class for using BMP180 Bosch Pressure sensor
Dependents: ILI9341_Clock_Nucleo IoT-Polytech-Upmc
BMP180 Class Reference
BMP180 Digital Pressure Sensor class using mbed's i2c class. More...
#include <BMP180.h>
Public Member Functions | |
BMP180 (PinName sda, PinName slc) | |
Create object connected to BMP180 pins ( remember both pins need pull up resisters) | |
int | readTP (long *t, long *p, int oversample) |
Read Temperature and Pressure at the same time. | |
int | startTemperature () |
Start the temperature reading process but return after the commands are issued to BMP180. | |
int | readTemperature (long *t) |
Reads the last temperature reading that was started with startTemperature() function. | |
int | startPressure (int oversample) |
Start the pressure reading process but return after the commands are issued to BMP180. | |
int | readPressure (long *p) |
Reads the last barometric pressure reading that was started with startPressure() function. |
Detailed Description
BMP180 Digital Pressure Sensor class using mbed's i2c class.
Example:
// show how the BMP180 class works #include "mbed.h" #include "BMP180.h" int main() { long temp ; long pressure; int error ; BMP180 mybmp180(p9,p10); while(1) { error = mybmp180.readTP(&temp,&pressure,OVERSAMPLING_ULTRA_HIGH_RESOLUTION); printf("Temp is %ld\r\n",temp); printf("Pressure is %ld\r\n",pressure); printf("Error is %d\r\n\r\n",error); wait(2); } }
Definition at line 71 of file BMP180.h.
Constructor & Destructor Documentation
BMP180 | ( | PinName | sda, |
PinName | slc | ||
) |
Create object connected to BMP180 pins ( remember both pins need pull up resisters)
Ensure the pull up resistors are used on these pins. Also note there is no checking on if you use these pins p9, p10, p27, p28 so ensure you only use these ones on the LPC1768 device
- Parameters:
-
sda pin that BMP180 connected to (p9 or p28 as defined on LPC1768) slc pin that BMP180 connected to (p10 or p27 ad defined on LPC1768)
Definition at line 3 of file BMP180.cpp.
Member Function Documentation
int readPressure | ( | long * | p ) |
Reads the last barometric pressure reading that was started with startPressure() function.
This function will return the fully compensated value of the barometric pressure in Pa. Note this function should follow startPressure() after the time needed to read the pressure. This time will vary but maximum time is 25.5 ms and minimum time is 4.5 ms. Note that this reading is dependent on temperature so the startTemperature() and readTemperature() functions should proceed this function or the pressure value will be incorrect!
- Parameters:
-
p the barometric pressure fully compensated value is returned in this variable. Pressure is in Pa so 88007 is 88.007 kPa. returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
Definition at line 85 of file BMP180.cpp.
int readTemperature | ( | long * | t ) |
Reads the last temperature reading that was started with startTemperature() function.
This function will return the fully compensated value of the temperature in Degrees celsius with one decimal so 253 is 25.3 C. Note this function should normaly follow the startTemperature() function and should also preceed the startPressure() and readPressure() commands! Note this function should follow startTemperature() after 4.5 ms minimum has elapsed or reading will be incorrect.
- Parameters:
-
t the temperature fully compensated value is returned in this variable. returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
Definition at line 55 of file BMP180.cpp.
int readTP | ( | long * | t, |
long * | p, | ||
int | oversample | ||
) |
Read Temperature and Pressure at the same time.
This function will only return when it has readings. This means that the time will vary depending on oversample setting! Note if your code can not wait for these readings to be taken and calculated you should use the functions below. These other functions are designed to allow your code to do other things then get the final readings. This function is only designed as a one shot give me the answer function.
- Parameters:
-
t the temperature fully compensated value is returned in this variable. Degrees celsius with one decimal so 253 is 25.3 C. p the barometric pressure fully compensated value is returned in this variable. Pressure is in Pa so 88007 is 88.007 kPa. oversample is the method method for reading sensor. OVERSAMPLING_ULTRA_HIGH_RESOLUTION is used if an incorrect value is passed to this function. returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
Definition at line 128 of file BMP180.cpp.
int startPressure | ( | int | oversample ) |
Start the pressure reading process but return after the commands are issued to BMP180.
This function is ment to start the pressure reading process but will return to allow other code to run then a reading could be made at a later time. Note the time needed for this reading pressure process will depend on oversample setting. The maximum time is 25.5 ms and minimum time is 4.5 ms.
- Parameters:
-
oversample is the method for reading sensor. OVERSAMPLING_ULTRA_HIGH_RESOLUTION is used if an incorrect value is passed to this function. returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
Definition at line 73 of file BMP180.cpp.
int startTemperature | ( | ) |
Start the temperature reading process but return after the commands are issued to BMP180.
This function is ment to start the temperature reading process but will return to allow other code to run then a reading could be made at a later time. Note the maximum time needed for this measurment is 4.5 ms.
- Parameters:
-
returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
Definition at line 45 of file BMP180.cpp.
Generated on Tue Jul 26 2022 21:55:39 by 1.7.2