-
Notifications
You must be signed in to change notification settings - Fork 1
/
bme280.cpp
37 lines (29 loc) · 876 Bytes
/
bme280.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "bme280.h"
void BME280::init() {
bool bme_status;
bme_status = _bme.begin(DEFAULT_ADDRESS); //address either 0x76 or 0x77
if (!bme_status) {
Serial.println("BME280: Could not find a valid BME280 sensor, check wiring!");
Serial.print("SensorID was: 0x"); Serial.println(_bme.sensorID(),16);
}
}
float BME280::getTemperature() {
return _bme.readTemperature();
}
float BME280::getPressure() {
return _bme.readPressure() / 100.0F;
}
float BME280::getAltitude() {
return _bme.readAltitude(SEALEVELPRESSURE_HPA);
}
float BME280::getHumidity() {
return _bme.readHumidity();
}
BME280::Measurement BME280::getMeasuredData() {
Measurement measurement;
measurement.temperature = getTemperature();
measurement.pressure = getPressure();
measurement.altitude = getAltitude();
measurement.humidity = getHumidity();
return measurement;
}