nose_electronique.ino

Arduino Nicla Sense ME · File : nose_electronique.ino · Language : Arduino · Use case : Sentir l’air avec le BME688 (eNose)

The BME688 turns the board into an electronic nose: MOX gas resistance, T/RH, and above all the IAQ (indoor air quality index) computed by BSEC in the hub. A digital pinch of nose for a room, cellar or terrarium.

Hardware

An Arduino Nicla Sense ME (nRF52832, BLE only) with Bosch BHI260AP hub, BMM150, BMP390, BME688 sensors, RGB LED on an I2C driver and LiPo charger. The board alone. Allow 10 s warm-up on the first cycle (typical scan 10.8 s per the datasheet); ventilate before judging IAQ.

Wiring

No wiring. Do not blow on it on purpose: the MOX sensor calibrates on ambient air, and alcohol or solvent vapors skew the learning.

How it works

BHY2.enable(GAS_IAX) arms the hub BSEC pipeline; bsec.iaq() gives the index (0-500, lower = healthier), readGasResistance the raw MOX resistance in ohms.

Running it

Programmed from the Arduino IDE (ArduinoCore-mbed); Arduino_BHY2 and Nicla_System libraries; USB through a serial bridge.

Variants

Store the IAQ curve as CSV for an air-quality history, trigger ventilation on threshold, or compare two rooms with two BLE-synced boards.

nose_electronique.ino

// BME688 : MOX gaz + T/RH/pression, avec sorties BSEC (IAQ)
// calculées par le hub. Cycle de préchauffe du capteur : ~10 s.

#include "Arduino_BHY2.h"

SensorBSEC bsec(0);   // IAQ / bVOC / CO2-eq calculés par le hub

void setup() {
  Serial.begin(115200);
  BHY2.begin();
  BHY2.enable(BHY2_ENABLE_GAS_IAX);   // index d'air intérieur
  BHY2.enable(BHY2_ENABLE_AMBIENT_TEMPERATURE);
  BHY2.enable(BHY2_ENABLE_RELATIVE_HUMIDITY);
  BHY2.update();
  Serial.println("Préchauffe BME688 (~10 s), puis lecture 1 Hz");
}

void loop() {
  BHY2.update();

  static unsigned long t = 0;
  if (millis() - t > 1000) {
    t = millis();
    Serial.print("IAQ="); Serial.print(bsec.iaq());
    Serial.print("  T="); Serial.print(BHY2.readTemperature());
    Serial.print(" C  RH="); Serial.print(BHY2.readHumidity());
    Serial.print(" %  Rgaz="); Serial.print(BHY2.readGasResistance());
    Serial.println(" ohm");
  }
  delay(5);
}

← Back to the board