a

Dependencies:   HCSR04_2 MPU6050_2 mbed SDFileSystem3

Fork of Autoflight2018_12 by 航空研究会

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BMP280.h Source File

BMP280.h

00001 /**
00002  *  BME280 Combined humidity and pressure sensor library
00003  *
00004  *  @author  Toyomasa Watarai
00005  *  @version 1.0
00006  *  @date    06-April-2015
00007  *
00008  *  Library for "BME280 temperature, humidity and pressure sensor module" from Switch Science
00009  *    https://www.switch-science.com/catalog/2236/
00010  *
00011  *  For more information about the BME280:
00012  *    http://ae-bst.resource.bosch.com/media/products/dokumente/bme280/BST-BME280_DS001-10.pdf
00013  */
00014  
00015 #ifndef MBED_BMP280_H
00016 #define MBED_BMP280_H
00017 
00018 #include "mbed.h"
00019 
00020 //#define _DEBUG
00021 #define DEFAULT_SLAVE_ADDRESS (0x77 << 1)
00022 
00023 #ifdef _DEBUG
00024 extern Serial pc;
00025 #define DEBUG_PRINT(...) pc.printf(__VA_ARGS__)
00026 #else
00027 #define DEBUG_PRINT(...)
00028 #endif
00029 
00030  
00031 /** BME280 class
00032  *
00033  *  BME280: A library to correct environmental data using Boshe BME280 device
00034  *
00035  *  BME280 is an environmental sensor
00036  *  @endcode
00037  */
00038  
00039 class BMP280
00040 {
00041 public:
00042 
00043     /** Create a BME280 instance
00044      *  which is connected to specified I2C pins with specified address
00045      *
00046      * @param sda I2C-bus SDA pin
00047      * @param scl I2C-bus SCL pin
00048      * @param slave_adr (option) I2C-bus address (default: 0x76)
00049      */
00050     BMP280(PinName sda, PinName sck, char slave_adr = DEFAULT_SLAVE_ADDRESS);
00051 
00052     /** Create a BME280 instance
00053      *  which is connected to specified I2C pins with specified address
00054      *
00055      * @param i2c_obj I2C object (instance)
00056      * @param slave_adr (option) I2C-bus address (default: 0x76)
00057      */
00058     BMP280(I2C &i2c_obj, char slave_adr = DEFAULT_SLAVE_ADDRESS);
00059 
00060     /** Destructor of BME280
00061      */
00062     virtual ~BMP280();
00063 
00064     /** Initializa BME280 sensor
00065      *
00066      *  Configure sensor setting and read parameters for calibration
00067      *
00068      */
00069     void initialize(void);
00070 
00071     /** Read the current temperature value (degree Celsius) from BME280 sensor
00072      *
00073      */
00074     float getTemperature(void);
00075 
00076     /** Read the current pressure value (hectopascal)from BME280 sensor
00077      *
00078      */
00079     float getPressure(void);
00080 
00081     /** Read the current humidity value (humidity %) from BME280 sensor
00082      *
00083      */
00084   //  float getHumidity(void);
00085 
00086 private:
00087 
00088     I2C         *i2c_p;
00089     I2C         &i2c;
00090     char        address;
00091     uint16_t    dig_T1;
00092     int16_t     dig_T2, dig_T3;
00093     uint16_t    dig_P1;
00094     int16_t     dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9;
00095     uint16_t    dig_H1, dig_H3;
00096     int16_t     dig_H2, dig_H4, dig_H5, dig_H6;
00097     int32_t     t_fine;
00098 
00099 };
00100 
00101 #endif // MBED_BME280_H