4 Commits

Author SHA1 Message Date
Yannick van Etten
db8758e1e5 removed unnecessary code 2024-11-13 14:45:27 +01:00
Yannick van Etten
08dff8bbc1 changed test code for the m5stack sensor 2024-11-13 14:37:14 +01:00
Yannick van Etten
f0260c1a91 changed file location 2024-11-13 13:46:04 +01:00
Yannick van Etten
40d601a35b Name change and small changes 2024-11-13 13:02:22 +01:00
3 changed files with 40 additions and 33 deletions

View File

@@ -20,8 +20,8 @@ void loop() {
int mq5Value = analogRead(MQ5_PIN);
// if sensor isn't connected properly display error message
if (isnan(h) || isnan(t)) {
Serial.println("Fout bij het lezen van de sensor!");
if (isnan(h) || isnan(t) || isnan(mq5Value)) {
Serial.println("Fout bij het lezen van de sensors!");
return;
}
// puts sensor values in the serial monitor

View File

@@ -1,31 +0,0 @@
#include <M5Stack.h>
#include <Wire.h>
#include "Adafruit_SGP30.h"
Adafruit_SGP30 sgp;
void setup() {
M5.begin();
Serial.begin(9600);
if (!sgp.begin()) {
Serial.println("SGP30 sensor niet gevonden :(");
while (1);
}
Serial.println("SGP30 sensor gevonden!");
}
void loop() {
delay(1000);
if (!sgp.IAQmeasure()) {
Serial.println("Error bij meting!");
return;
}
Serial.print("eCO2: ");
Serial.print(sgp.eCO2);
Serial.print(" ppm\tTVOC: ");
Serial.print(sgp.TVOC);
Serial.println(" ppb");
}

View File

@@ -0,0 +1,38 @@
#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
}