mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
changed test code for the m5stack sensor
This commit is contained in:
@@ -1,31 +1,39 @@
|
|||||||
#include <M5Stack.h>
|
#include <Wire.h>
|
||||||
#include <Wire.h>
|
#include "Adafruit_SGP30.h"
|
||||||
#include "Adafruit_SGP30.h"
|
|
||||||
|
|
||||||
Adafruit_SGP30 sgp;
|
Adafruit_SGP30 sgp;
|
||||||
|
|
||||||
void setup() {
|
#define SDA_PIN 10
|
||||||
M5.begin();
|
#define SCL_PIN 11
|
||||||
Serial.begin(9600);
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
if (!sgp.begin()) {
|
Serial.begin(115200);
|
||||||
Serial.println("SGP30 sensor niet gevonden :(");
|
while (!Serial) { delay(10); }
|
||||||
while (1);
|
|
||||||
}
|
Wire.begin(SDA_PIN, SCL_PIN);
|
||||||
Serial.println("SGP30 sensor gevonden!");
|
|
||||||
|
Serial.println("SGP30 test");
|
||||||
|
|
||||||
|
if (!sgp.begin()) {
|
||||||
|
Serial.println("SGP30 sensor not found :(");
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
Serial.print("Found SGP30 serial #");
|
||||||
|
|
||||||
|
// Start measurements (initialize baseline)
|
||||||
|
if (! sgp.IAQinit()) {
|
||||||
|
Serial.println("SGP30 IAQinit failed!");
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
delay(1000);
|
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");
|
||||||
|
|
||||||
if (!sgp.IAQmeasure()) {
|
delay(1000); // 1 second delay
|
||||||
Serial.println("Error bij meting!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Serial.print("eCO2: ");
|
|
||||||
Serial.print(sgp.eCO2);
|
|
||||||
Serial.print(" ppm\tTVOC: ");
|
|
||||||
Serial.print(sgp.TVOC);
|
|
||||||
Serial.println(" ppb");
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user