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