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