Merged m5 code into sensor code

This commit is contained in:
Yannick van Etten
2024-11-18 11:09:13 +01:00
parent db8758e1e5
commit 0ae0b83e4b

View File

@@ -1,16 +1,33 @@
#include <DHT.h> #include <DHT.h>
#include <Wire.h>
#include "Adafruit_SGP30.h"
Adafruit_SGP30 sgp;
// define pins and type of DHT sensor // define pins and type of DHT sensor
#define DHTPIN 4 #define DHTPIN 4
#define DHTTYPE DHT11 #define DHTTYPE DHT11
#define MQ5_PIN 2 #define MQ5_PIN 2
#define SDA_PIN 10
#define SCL_PIN 11
DHT dht(DHTPIN, DHTTYPE); DHT dht(DHTPIN, DHTTYPE);
void setup() { void setup() {
//initialize serial communication and the sensors //initialize serial communication and the sensors
Serial.begin(9600); Serial.begin(9600);
dht.begin(); dht.begin();
pinMode(MQ5_PIN, INPUT); pinMode(MQ5_PIN, INPUT);
Wire.begin(SDA_PIN, SCL_PIN);
Serial.println("SGP30 test");
Wire.begin(SDA_PIN, SCL_PIN);
Serial.println("SGP30 test");
} }
void loop() { void loop() {
@@ -24,6 +41,12 @@ void loop() {
Serial.println("Fout bij het lezen van de sensors!"); Serial.println("Fout bij het lezen van de sensors!");
return; return;
} }
if (! sgp.IAQmeasure()) {
Serial.println("Measurement failed");
return;
}
// puts sensor values in the serial monitor // puts sensor values in the serial monitor
Serial.print("Luchtvochtigheid: "); Serial.print("Luchtvochtigheid: ");
Serial.print(h); Serial.print(h);
@@ -34,5 +57,8 @@ void loop() {
Serial.print("MQ5 waarde: "); Serial.print("MQ5 waarde: ");
Serial.println(mq5Value); Serial.println(mq5Value);
Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");
Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");
delay(500); delay(500);
} }