Skip to content

Instantly share code, notes, and snippets.

@OYTIS
Created September 16, 2019 12:39
Show Gist options
  • Save OYTIS/35547320c684f0b5eacfb1758cc059d0 to your computer and use it in GitHub Desktop.
Save OYTIS/35547320c684f0b5eacfb1758cc059d0 to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#include "sensirion_common.h"
#include "sgp30.h"
void setup() {
s16 err;
u16 scaled_ethanol_signal, scaled_h2_signal;
SerialUSB.begin(115200);
SerialUSB.println("serial start!!");
pinMode(32,OUTPUT);
digitalWrite(32,1);
SerialUSB.println("Set wio link power!");
delay(500);
/*Init module,Reset all baseline,The initialization takes up to around 15 seconds, during which
all APIs measuring IAQ(Indoor air quality ) output will not change.Default value is 400(ppm) for co2,0(ppb) for tvoc*/
while (sgp_probe() != STATUS_OK) {
SerialUSB.println("SGP failed");
while(1);
}
/*Read H2 and Ethanol signal in the way of blocking*/
err = sgp_measure_signals_blocking_read(&scaled_ethanol_signal,
&scaled_h2_signal);
if (err == STATUS_OK) {
SerialUSB.println("get ram signal!");
} else {
SerialUSB.println("error reading signals");
}
err = sgp_iaq_init();
}
void loop() {
s16 err=0;
u16 tvoc_ppb, co2_eq_ppm;
err = sgp_measure_iaq_blocking_read(&tvoc_ppb, &co2_eq_ppm);
if (err == STATUS_OK) {
SerialUSB.print("tVOC Concentration:");
SerialUSB.print(tvoc_ppb);
SerialUSB.println("ppb");
SerialUSB.print("CO2eq Concentration:");
SerialUSB.print(co2_eq_ppm);
SerialUSB.println("ppm");
} else {
SerialUSB.println("error reading IAQ values\n");
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment