sensor

Dependents:   enviro_copy

Committer:
12104404
Date:
Wed Apr 13 07:19:00 2016 +0000
Revision:
5:7139d5accbc3
Parent:
BME280.h@4:ddcaa259e65b
Child:
6:d03826fe1062
BMP280;

Who changed what in which revision?

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