![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
aaa
Dependencies: HCSR04_2 MPU6050_2 mbed SDFileSystem3
Fork of AutoFlight2017_now2 by
BMP280/BMP280.h@0:92024886c0be, 2017-08-01 (annotated)
- Committer:
- TUATBM
- Date:
- Tue Aug 01 12:27:13 2017 +0000
- Revision:
- 0:92024886c0be
??????????????????????; ????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TUATBM | 0:92024886c0be | 1 | /** |
TUATBM | 0:92024886c0be | 2 | * BME280 Combined humidity and pressure sensor library |
TUATBM | 0:92024886c0be | 3 | * |
TUATBM | 0:92024886c0be | 4 | * @author Toyomasa Watarai |
TUATBM | 0:92024886c0be | 5 | * @version 1.0 |
TUATBM | 0:92024886c0be | 6 | * @date 06-April-2015 |
TUATBM | 0:92024886c0be | 7 | * |
TUATBM | 0:92024886c0be | 8 | * Library for "BME280 temperature, humidity and pressure sensor module" from Switch Science |
TUATBM | 0:92024886c0be | 9 | * https://www.switch-science.com/catalog/2236/ |
TUATBM | 0:92024886c0be | 10 | * |
TUATBM | 0:92024886c0be | 11 | * For more information about the BME280: |
TUATBM | 0:92024886c0be | 12 | * http://ae-bst.resource.bosch.com/media/products/dokumente/bme280/BST-BME280_DS001-10.pdf |
TUATBM | 0:92024886c0be | 13 | */ |
TUATBM | 0:92024886c0be | 14 | |
TUATBM | 0:92024886c0be | 15 | #ifndef MBED_BMP280_H |
TUATBM | 0:92024886c0be | 16 | #define MBED_BMP280_H |
TUATBM | 0:92024886c0be | 17 | |
TUATBM | 0:92024886c0be | 18 | #include "mbed.h" |
TUATBM | 0:92024886c0be | 19 | |
TUATBM | 0:92024886c0be | 20 | //#define _DEBUG |
TUATBM | 0:92024886c0be | 21 | #define DEFAULT_SLAVE_ADDRESS (0x77 << 1) |
TUATBM | 0:92024886c0be | 22 | |
TUATBM | 0:92024886c0be | 23 | #ifdef _DEBUG |
TUATBM | 0:92024886c0be | 24 | extern Serial pc; |
TUATBM | 0:92024886c0be | 25 | #define DEBUG_PRINT(...) pc.printf(__VA_ARGS__) |
TUATBM | 0:92024886c0be | 26 | #else |
TUATBM | 0:92024886c0be | 27 | #define DEBUG_PRINT(...) |
TUATBM | 0:92024886c0be | 28 | #endif |
TUATBM | 0:92024886c0be | 29 | |
TUATBM | 0:92024886c0be | 30 | |
TUATBM | 0:92024886c0be | 31 | /** BME280 class |
TUATBM | 0:92024886c0be | 32 | * |
TUATBM | 0:92024886c0be | 33 | * BME280: A library to correct environmental data using Boshe BME280 device |
TUATBM | 0:92024886c0be | 34 | * |
TUATBM | 0:92024886c0be | 35 | * BME280 is an environmental sensor |
TUATBM | 0:92024886c0be | 36 | * @endcode |
TUATBM | 0:92024886c0be | 37 | */ |
TUATBM | 0:92024886c0be | 38 | |
TUATBM | 0:92024886c0be | 39 | class BMP280 |
TUATBM | 0:92024886c0be | 40 | { |
TUATBM | 0:92024886c0be | 41 | public: |
TUATBM | 0:92024886c0be | 42 | |
TUATBM | 0:92024886c0be | 43 | /** Create a BME280 instance |
TUATBM | 0:92024886c0be | 44 | * which is connected to specified I2C pins with specified address |
TUATBM | 0:92024886c0be | 45 | * |
TUATBM | 0:92024886c0be | 46 | * @param sda I2C-bus SDA pin |
TUATBM | 0:92024886c0be | 47 | * @param scl I2C-bus SCL pin |
TUATBM | 0:92024886c0be | 48 | * @param slave_adr (option) I2C-bus address (default: 0x76) |
TUATBM | 0:92024886c0be | 49 | */ |
TUATBM | 0:92024886c0be | 50 | BMP280(PinName sda, PinName sck, char slave_adr = DEFAULT_SLAVE_ADDRESS); |
TUATBM | 0:92024886c0be | 51 | |
TUATBM | 0:92024886c0be | 52 | /** Create a BME280 instance |
TUATBM | 0:92024886c0be | 53 | * which is connected to specified I2C pins with specified address |
TUATBM | 0:92024886c0be | 54 | * |
TUATBM | 0:92024886c0be | 55 | * @param i2c_obj I2C object (instance) |
TUATBM | 0:92024886c0be | 56 | * @param slave_adr (option) I2C-bus address (default: 0x76) |
TUATBM | 0:92024886c0be | 57 | */ |
TUATBM | 0:92024886c0be | 58 | BMP280(I2C &i2c_obj, char slave_adr = DEFAULT_SLAVE_ADDRESS); |
TUATBM | 0:92024886c0be | 59 | |
TUATBM | 0:92024886c0be | 60 | /** Destructor of BME280 |
TUATBM | 0:92024886c0be | 61 | */ |
TUATBM | 0:92024886c0be | 62 | virtual ~BMP280(); |
TUATBM | 0:92024886c0be | 63 | |
TUATBM | 0:92024886c0be | 64 | /** Initializa BME280 sensor |
TUATBM | 0:92024886c0be | 65 | * |
TUATBM | 0:92024886c0be | 66 | * Configure sensor setting and read parameters for calibration |
TUATBM | 0:92024886c0be | 67 | * |
TUATBM | 0:92024886c0be | 68 | */ |
TUATBM | 0:92024886c0be | 69 | void initialize(void); |
TUATBM | 0:92024886c0be | 70 | |
TUATBM | 0:92024886c0be | 71 | /** Read the current temperature value (degree Celsius) from BME280 sensor |
TUATBM | 0:92024886c0be | 72 | * |
TUATBM | 0:92024886c0be | 73 | */ |
TUATBM | 0:92024886c0be | 74 | float getTemperature(void); |
TUATBM | 0:92024886c0be | 75 | |
TUATBM | 0:92024886c0be | 76 | /** Read the current pressure value (hectopascal)from BME280 sensor |
TUATBM | 0:92024886c0be | 77 | * |
TUATBM | 0:92024886c0be | 78 | */ |
TUATBM | 0:92024886c0be | 79 | float getPressure(void); |
TUATBM | 0:92024886c0be | 80 | |
TUATBM | 0:92024886c0be | 81 | /** Read the current humidity value (humidity %) from BME280 sensor |
TUATBM | 0:92024886c0be | 82 | * |
TUATBM | 0:92024886c0be | 83 | */ |
TUATBM | 0:92024886c0be | 84 | // float getHumidity(void); |
TUATBM | 0:92024886c0be | 85 | |
TUATBM | 0:92024886c0be | 86 | private: |
TUATBM | 0:92024886c0be | 87 | |
TUATBM | 0:92024886c0be | 88 | I2C *i2c_p; |
TUATBM | 0:92024886c0be | 89 | I2C &i2c; |
TUATBM | 0:92024886c0be | 90 | char address; |
TUATBM | 0:92024886c0be | 91 | uint16_t dig_T1; |
TUATBM | 0:92024886c0be | 92 | int16_t dig_T2, dig_T3; |
TUATBM | 0:92024886c0be | 93 | uint16_t dig_P1; |
TUATBM | 0:92024886c0be | 94 | int16_t dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9; |
TUATBM | 0:92024886c0be | 95 | uint16_t dig_H1, dig_H3; |
TUATBM | 0:92024886c0be | 96 | int16_t dig_H2, dig_H4, dig_H5, dig_H6; |
TUATBM | 0:92024886c0be | 97 | int32_t t_fine; |
TUATBM | 0:92024886c0be | 98 | |
TUATBM | 0:92024886c0be | 99 | }; |
TUATBM | 0:92024886c0be | 100 | |
TUATBM | 0:92024886c0be | 101 | #endif // MBED_BME280_H |