
デジタルマルチピクセルガスセンサのユニットで、空気中のさまざまなVOC(揮発性有機化合物)と水素を主に測定することができ、TVOC(総揮発性有機化合物)とeCO2(二酸化炭素相当量)濃度を測定し検出するようにプログラムすることが可能

サンプルコード
#include <M5Unified.h>
#include "Adafruit_SGP30.h"
Adafruit_SGP30 sgp;
long last_millis = 0;
void setup() {
M5.begin(true, false, true, true);
M5.Display.setTextSize(2);
M5.Display.setCursor(80, 0);
M5.Display.println("TVOC TEST");
if (!sgp.begin()) { // Init the sensor. 初始化传感器
M5.Display.println("Sensor not found");
while (1)
;
}
M5.Display.setCursor(0, 80);
M5.Display.println("\nInitialization...");
}
void loop() {
static int i = 15;
while (i > 0) {
if (millis() - last_millis > 1000) {
last_millis = millis();
i--;
M5.Display.fillRect(20, 120, 60, 30, BLACK);
M5.Display.drawNumber(i, 20, 120, 2);
}
}
M5.Display.fillRect(0, 80, 90, 100, BLACK);
if (!sgp.IAQmeasure()) { // Commands the sensor to take a single eCO2/VOC
// measurement. 命令传感器进行一次eCO2/VOC测量
Serial.println("Measurement failed");
return;
}
M5.Display.fillRect(100, 40, 220, 90, TFT_BLACK);
M5.Display.setCursor(0, 50);
M5.Display.printf("TVOC:%d ppb\n", sgp.TVOC);
M5.Display.printf("eCO2:%d ppm\n", sgp.eCO2);
delay(500);
}

息を吹きかけて数値が変わればOK