sensor

Dependents:   enviro_copy

Committer:
MACRUM
Date:
Mon Apr 06 09:13:00 2015 +0000
Revision:
0:ade9be832910
Child:
1:763a4018aaec
Initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:ade9be832910 1 #ifndef MBED_BME280_H
MACRUM 0:ade9be832910 2 #define MBED_BME280_H
MACRUM 0:ade9be832910 3
MACRUM 0:ade9be832910 4 #include "mbed.h"
MACRUM 0:ade9be832910 5
MACRUM 0:ade9be832910 6 //#define _DEBUG
MACRUM 0:ade9be832910 7 #define DEFAULT_SLAVE_ADDRESS (0x76 << 1)
MACRUM 0:ade9be832910 8
MACRUM 0:ade9be832910 9 #ifdef _DEBUG
MACRUM 0:ade9be832910 10 extern Serial pc;
MACRUM 0:ade9be832910 11 #define DEBUG_PRINT(...) pc.printf(__VA_ARGS__)
MACRUM 0:ade9be832910 12 #else
MACRUM 0:ade9be832910 13 #define DEBUG_PRINT(...)
MACRUM 0:ade9be832910 14 #endif
MACRUM 0:ade9be832910 15
MACRUM 0:ade9be832910 16
MACRUM 0:ade9be832910 17 /** BME280 class
MACRUM 0:ade9be832910 18 *
MACRUM 0:ade9be832910 19 * BME280: A library to correct environmental data using Boshe BME280 device
MACRUM 0:ade9be832910 20 *
MACRUM 0:ade9be832910 21 * BME280 is an environmental sensor
MACRUM 0:ade9be832910 22 * @endcode
MACRUM 0:ade9be832910 23 */
MACRUM 0:ade9be832910 24
MACRUM 0:ade9be832910 25 class BME280
MACRUM 0:ade9be832910 26 {
MACRUM 0:ade9be832910 27 public:
MACRUM 0:ade9be832910 28
MACRUM 0:ade9be832910 29 /** Create a BME280 instance
MACRUM 0:ade9be832910 30 * which is connected to specified I2C pins with specified address
MACRUM 0:ade9be832910 31 *
MACRUM 0:ade9be832910 32 * @param sda I2C-bus SDA pin
MACRUM 0:ade9be832910 33 * @param scl I2C-bus SCL pin
MACRUM 0:ade9be832910 34 * @param slave_adr (option) I2C-bus address (default: 0x76)
MACRUM 0:ade9be832910 35 */
MACRUM 0:ade9be832910 36 BME280(PinName sda, PinName sck, char slave_adr = DEFAULT_SLAVE_ADDRESS);
MACRUM 0:ade9be832910 37
MACRUM 0:ade9be832910 38 /** Create a BME280 instance
MACRUM 0:ade9be832910 39 * which is connected to specified I2C pins with specified address
MACRUM 0:ade9be832910 40 *
MACRUM 0:ade9be832910 41 * @param i2c_obj I2C object (instance)
MACRUM 0:ade9be832910 42 * @param slave_adr (option) I2C-bus address (default: 0x76)
MACRUM 0:ade9be832910 43 */
MACRUM 0:ade9be832910 44 BME280(I2C &i2c_obj, char slave_adr = DEFAULT_SLAVE_ADDRESS);
MACRUM 0:ade9be832910 45
MACRUM 0:ade9be832910 46 /** Destructor of BME280
MACRUM 0:ade9be832910 47 */
MACRUM 0:ade9be832910 48 virtual ~BME280();
MACRUM 0:ade9be832910 49
MACRUM 0:ade9be832910 50 /** Initializa BME280 sensor
MACRUM 0:ade9be832910 51 *
MACRUM 0:ade9be832910 52 * Configure sensor setting and read parameters for calibration
MACRUM 0:ade9be832910 53 *
MACRUM 0:ade9be832910 54 */
MACRUM 0:ade9be832910 55 void initialize(void);
MACRUM 0:ade9be832910 56
MACRUM 0:ade9be832910 57 /** Read the current temperature value (degree Celsius) from BME280 sensor
MACRUM 0:ade9be832910 58 *
MACRUM 0:ade9be832910 59 */
MACRUM 0:ade9be832910 60 float getTemperature(void);
MACRUM 0:ade9be832910 61
MACRUM 0:ade9be832910 62 /** Read the current pressure value (hectopascal)from BME280 sensor
MACRUM 0:ade9be832910 63 *
MACRUM 0:ade9be832910 64 */
MACRUM 0:ade9be832910 65 float getPressure(void);
MACRUM 0:ade9be832910 66
MACRUM 0:ade9be832910 67 /** Read the current humidity value (humidity %) from BME280 sensor
MACRUM 0:ade9be832910 68 *
MACRUM 0:ade9be832910 69 */
MACRUM 0:ade9be832910 70 float getHumidity(void);
MACRUM 0:ade9be832910 71
MACRUM 0:ade9be832910 72 private:
MACRUM 0:ade9be832910 73
MACRUM 0:ade9be832910 74 I2C *i2c_p;
MACRUM 0:ade9be832910 75 I2C &i2c;
MACRUM 0:ade9be832910 76 char address;
MACRUM 0:ade9be832910 77 uint16_t dig_T1;
MACRUM 0:ade9be832910 78 int16_t dig_T2, dig_T3;
MACRUM 0:ade9be832910 79 uint16_t dig_P1;
MACRUM 0:ade9be832910 80 int16_t dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9;
MACRUM 0:ade9be832910 81 uint16_t dig_H1, dig_H3;
MACRUM 0:ade9be832910 82 int16_t dig_H2, dig_H4, dig_H5, dig_H6;
MACRUM 0:ade9be832910 83 int32_t t_fine;
MACRUM 0:ade9be832910 84
MACRUM 0:ade9be832910 85 };
MACRUM 0:ade9be832910 86
MACRUM 0:ade9be832910 87 #endif // MBED_BME280_H