mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
40 lines
835 B
C++
40 lines
835 B
C++
// Test code is merged to main sensor code os this file is not needed anymore
|
|
|
|
#include <Wire.h>
|
|
#include "Adafruit_SGP30.h"
|
|
|
|
Adafruit_SGP30 sgp;
|
|
|
|
#define SDA_PIN 10
|
|
#define SCL_PIN 11
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
while (!Serial) { delay(10); }
|
|
|
|
Wire.begin(SDA_PIN, SCL_PIN);
|
|
|
|
Serial.println("SGP30 test");
|
|
|
|
if (!sgp.begin()) {
|
|
Serial.println("SGP30 sensor not found :(");
|
|
while (1);
|
|
}
|
|
|
|
// Start measurements (initialize baseline)
|
|
if (! sgp.IAQinit()) {
|
|
Serial.println("SGP30 IAQinit failed!");
|
|
while (1);
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
if (! sgp.IAQmeasure()) {
|
|
Serial.println("Measurement failed");
|
|
return;
|
|
}
|
|
Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");
|
|
Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");
|
|
|
|
delay(1000); // 1 second delay
|
|
} |