-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbme280.cpp
39 lines (29 loc) · 807 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
38
39
#include "bme280.h"
void BME280::init() {
Serial.print("BME280: Initializing... ");
if (!_bme.begin(DEFAULT_ADDRESS)) {
Serial.println("BME280: Could not find a valid BME280 sensor, check wiring!");
while (1);
}
Serial.println("DONE.");
}
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;
}