Commit 7595b0db authored by Melroy van den Berg's avatar Melroy van den Berg

Select sensor during reading

parent 4a25616f
Pipeline #1072 passed with stages
in 15 seconds
......@@ -121,7 +121,6 @@ void Controller::InitDustSensor() {
void Controller::InitGasSensor(int i2c_fd) {
this->sgp = new SGP30(i2c_fd);
// Select the sensor on the bus
if(!sgp->Select()) {
throw std::runtime_error("Could not select the gas sensor!\n");
......@@ -158,6 +157,9 @@ void Controller::SetAbsoluteHumidity() {
* \return true if everything went successfully
*/
bool Controller::TempHumidPressReading() {
if(!bme->Select()) {
throw std::runtime_error("Could not select the temp/humid/pressure sensor!\n");
}
int counter = 0;
while(counter < 60) {
......@@ -222,7 +224,10 @@ bool Controller::DustReading() {
bool Controller::GasReading() {
// IMPORTANT: According to the specs we need to sent regular internals of 1s to ensure proper dynamic baseline compensation algo.
// This time interval needs to be done forever.
if(!sgp->Select()) {
throw std::runtime_error("Could not select the gas sensor!\n");
}
int counter = 0;
while(counter < 40) {
// Do measurement
......@@ -232,7 +237,6 @@ bool Controller::GasReading() {
}
printf("TVOC : %dppb\n", sgp->TVOC);
printf("eCO2 : %dppm\n", sgp->eCO2);
// Sleep 1 second
// TODO: embedded a delay within DoMeasurement()?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment