AskSin++
Bme280.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin++
3 // 2018-04-03 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 //- -----------------------------------------------------------------------------------------------------------------------
5 
6 #ifndef __SENSORS_BME280_h__
7 #define __SENSORS_BME280_h__
8 
9 #include <Sensors.h>
10 #include <Wire.h>
11 #include <BME280I2C.h>
12 
13 namespace as {
14 
15 BME280I2C::Settings settings(
16  BME280::OSR_X1, // Temperature Oversampling Rate (tempOSR): OSR Enum, default = OSR_X1
17  BME280::OSR_X1, // Humidity Oversampling Rate (humOSR): OSR Enum, default = OSR_X1
18  BME280::OSR_X1, // Pressure Oversampling Rate (presOSR): OSR Enum, default = OSR_X1
19  BME280::Mode_Forced, // Mode (mode): Mode Enum, default = Mode_Forced
20  BME280::StandbyTime_1000ms, // Standby Time (standbyTime): StandbyTime Enum, default = StandbyTime_1000ms
21  BME280::Filter_Off, // Filter (filter): Filter Enum, default = Filter_16
22  BME280::SpiEnable_False // SPI Enable: SpiEnable Enum, default = false
23 );
24 
25 // https://github.com/finitespace/BME280
26 class Bme280 : public Temperature, public Pressure, public Humidity {
27  BME280I2C _bme;
28 public:
29  Bme280 () {}
30  void init () {
31  Wire.begin();
32  _present = _bme.begin();
33  _bme.setSettings(settings);
34  }
35  bool measure (__attribute__((unused)) bool async=false) {
36  if( present() == true ) {
37  float t, p, h;
38  _bme.read(p,t,h);
39  _temperature = t * 10;
40  _pressure = p;
41  _humidity = h;
42  return true;
43  }
44  return false;
45  }
46 };
47 
48 }
49 
50 #endif
as::Bme280
Definition: Bme280.h:26
as::Humidity
Definition: Sensors.h:39
as::Temperature
Definition: Sensors.h:30
as::Pressure
Definition: Sensors.h:48