Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BMP180.h
00001 /* 00002 @file BMP180.h 00003 @brief Barometric Pressure and Temperature Sensor BMP180 Breakout I2C Library 00004 */ 00005 00006 #ifndef BMP180_H 00007 #define BMP180_H 00008 00009 #include "mbed.h" 00010 00011 /// default address is 0xEF => (0x77<<1 + 1) 00012 #define BMP180_I2C_ADDRESS 0xEF 00013 #define DEGREES '\u00B0' 00014 #define DEGREES_CELCIUS "\u00B0C" 00015 00016 // Oversampling settings 00017 typedef enum { 00018 ULTRA_LOW_POWER = 0, ///< 1 pressure sample : 4.5 ms delay 00019 STANDARD = 1, ///< 2 pressure samples : 7.5 ms delay 00020 HIGH_RESOLUTION = 2, ///< 4 pressure samples : 13.5 ms delay 00021 ULTRA_HIGH_RESOLUTION = 3 ///< 8 pressure samples : 25.5 ms delay 00022 } OverSamplingSetting; 00023 00024 /** BMP180 class. 00025 * Read Pressure and temperature from the BMP180 Breakout I2C sensor 00026 * 00027 * Example: 00028 * @code 00029 * #include "mbed.h" 00030 * #include "BMP180.h" 00031 * 00032 * int main() { 00033 * BMP180 bmp180(PIN_SDA, PIN_SCL); 00034 * float pressure, temperature; 00035 * 00036 * // bmp180.Initialize(); // no altitude compensation and normal oversampling 00037 * bmp180.Initialize(64, BMP180_OSS_ULTRA_LOW_POWER); // 64m altitude compensation and low power oversampling 00038 * 00039 * while(1) { 00040 * if (bmp180.ReadData(&pressure, &temperature)) 00041 * printf("Pressure(hPa): %8.2f \t Temperature(C): %8.2f\n", pressure, temperature); 00042 * wait(1); 00043 * } 00044 * } 00045 * @endcode 00046 */ 00047 class BMP180 { 00048 public: 00049 /** Create a BMP180 instance 00050 * @param i2c object 00051 */ 00052 BMP180(I2C& i2c); 00053 00054 /** Initialization: set member values and read BMP180 calibration parameters 00055 * @param altitude (in meter) 00056 * @param overSamplingSetting 00057 * @returns 00058 * 1 on success, 00059 * 0 on error 00060 */ 00061 int initialize(float altitude = 0.F, OverSamplingSetting oss = STANDARD); 00062 00063 /** Read pressure and temperature from the BMP180. 00064 * @param pressure (hPa) 00065 * @param temperature (C) 00066 * @returns 00067 * 1 on success, 00068 * 0 on error 00069 */ 00070 int readData(float& pTemperature, float& pPressure); 00071 00072 protected: 00073 /** Perform temperature measurement 00074 * 00075 * @returns 00076 * temperature (C) 00077 */ 00078 int ReadRawTemperature(long* pUt); 00079 00080 /** Perform pressure measurement 00081 * 00082 * @returns 00083 * pressure (mbar) 00084 */ 00085 int ReadRawPressure(long* pUp); 00086 00087 /** Calculation of the temperature from the digital output 00088 */ 00089 float TrueTemperature(long ut); 00090 00091 /** Calculation of the pressure from the digital output 00092 */ 00093 float TruePressure(long up); 00094 00095 OverSamplingSetting m_oss; 00096 float m_altitude; 00097 00098 I2C m_i2c; 00099 char m_data[2]; 00100 00101 //short mb; // Not used? 00102 uint16_t ac4, ac5, ac6; 00103 int16_t ac1, ac2, ac3, b1, b2, b5, md; 00104 long x1, x2, x3, b3, b6, mc; 00105 unsigned long b4, b7; 00106 }; 00107 00108 #endif //BMP180_H
Generated on Wed Jul 13 2022 19:46:59 by
1.7.2