-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (41 loc) · 1.48 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (41 loc) · 1.48 KB
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
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <memory>
#include <unistd.h>
#include "bme280.h"
#include "logger.h"
using namespace std;
int main()
{
TData sensorData;
// logger initialization
Logger *logger = Logger::GetInstance();
logger->Msg("MAIN::BME280 test app");
// bme280 initialization
shared_ptr<BME280> sen = make_shared<BME280>();
sen->Init("/dev/i2c-2");
// bme280 settings
uint8_t settings_sel;
settings_sel = BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL;
sen->SetSensorSettings(settings_sel);
//while(true) {
for(int i=0; i<3; i++) {
sen->SetSensorMode(BME280_FORCED_MODE);
// Wait for the measurement to complete and print data @25Hz
usleep(1000*40);
#ifdef ALT_MEAS
string temp = string("MAIN::Temp: ") + to_string(sen->GetTemperature());
string pres = string("MAIN::Pres: ") + to_string(sen->GetPressure());
string hum = string("MAIN::Hum : ") + to_string(sen->GetHumidity());
#else
sen->GetSensorData(BME280_ALL);
string temp = string("MAIN::Temp: ") + to_string(sen->GetTemperature());
//string pres = string("MAIN::Pres: ") + to_string(sen->GetPressure());
//string hum = string("MAIN::Hum : ") + to_string(sen->GetHumidity());
#endif
logger->Msg((char*)temp.c_str());
//logger->Msg((char*)pres.c_str());
//logger->Msg((char*)hum.c_str());
sleep(3);
}
return EXIT_SUCCESS;
}