BMP 280 library files

Dependents:   ELEC350_Project2

Committer:
Swabey89
Date:
Sun Nov 04 23:12:04 2018 +0000
Revision:
0:eef68cb8c174
BMP280 library files added

Who changed what in which revision?

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