Skip to content

SensorBSEC2 with conjunction with other sensors #146

@cheuh008

Description

@cheuh008

Not an issue, more a question, dont know best practice to ask apologies.

is there anyway to get other sensor data in conjunction with bsec2. I think I get that BSEC2 uses temp, pres, hum and gas to classify, but as the methods are private, the data itself isn't accessible.

Apologies if dumb question or terrible code. still learning....

#include "Arduino.h"
#include "Arduino_BHY2.h"

Sensor gas(SENSOR_ID_GAS);
Sensor pres(SENSOR_ID_BARO);
Sensor temp(SENSOR_ID_TEMP);
SensorBSEC bsec(SENSOR_ID_BSEC);
SensorBSEC2 bsec2(SENSOR_ID_BSEC2);

const uint8_t BSEC2CONFIG[] = {... };

void setup() {
  Serial.begin(115200);
  BHY2.begin();
  gas.begin();
  pres.begin();
  temp.begin();
  bsec.begin();
  sensortec.bhy2_bsec2_setConfigString(BSEC2CONFIG, sizeof(BSEC2CONFIG) / sizeof(BSEC2CONFIG[0]));
  bsec2.begin();
}

void loop() {
  BHY2.update();
  static auto printTime = millis();
  if (millis() - printTime >= 1000) {
    printTime = millis();
    Serial.println(String("gas: ") + String(gas.value()));
    Serial.println(String("Pressure: ") + String(pres.value()));
    Serial.println(String("temperature: ") + String(temp.value(), 2));
    Serial.print(bsec.toString());
    Serial.print(bsec2.toString());
  }
}

Serial Monitor :

gas: 268484.00
Pressure: 0.00
temperature: 0.00
BSEC output values - iaq: 0 iaq_s: 0 b_voc_eq: 0.00 co2_eq: 0 accuracy: 0 comp_t: 0.00 comp_h: 0.00 comp_g: 0
BSEC2 output values (%) - gas[0]: 99 gas[1]: 0 gas[2]: 0 gas[3]: 0 accuracy: 3

gas: 268484.00
Pressure: 0.00
temperature: 0.00
BSEC output values - iaq: 0 iaq_s: 0 b_voc_eq: 0.00 co2_eq: 0 accuracy: 0 comp_t: 0.00 comp_h: 0.00 comp_g: 0
BSEC2 output values (%) - gas[0]: 99 gas[1]: 0 gas[2]: 0 gas[3]: 0 accuracy: 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions