GROUP Z

Committer:
mslade
Date:
Fri Jan 05 15:08:15 2018 +0000
Revision:
0:9cdd03a41c04
s

Who changed what in which revision?

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