adds last changes to code that clean it up
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
// Sietse Jonker & Dano Bosch
|
// Sietse Jonker & Dano Bosch
|
||||||
// 27/02/2024
|
// 27/02/2024
|
||||||
|
|
||||||
|
// include these libraries
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_SH110X.h>
|
#include <Adafruit_SH110X.h>
|
||||||
#include <Adafruit_SGP30.h>
|
#include <Adafruit_SGP30.h>
|
||||||
@@ -9,6 +10,7 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WebSocketsClient.h>
|
#include <WebSocketsClient.h>
|
||||||
|
|
||||||
|
// define pins on esp32
|
||||||
#define MICPIN 6
|
#define MICPIN 6
|
||||||
#define DHTPIN 7
|
#define DHTPIN 7
|
||||||
#define SCL 9
|
#define SCL 9
|
||||||
@@ -91,6 +93,7 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
|
|||||||
// special function to setup websocket
|
// special function to setup websocket
|
||||||
void websocketSetup(){
|
void websocketSetup(){
|
||||||
WiFiMulti.addAP("iotroam", "vbK9gbDBIB");
|
WiFiMulti.addAP("iotroam", "vbK9gbDBIB");
|
||||||
|
WiFiMulti.addAP("LansanKPN-boven", "19sander71vlieland14");
|
||||||
|
|
||||||
while(WiFiMulti.run() != WL_CONNECTED) {
|
while(WiFiMulti.run() != WL_CONNECTED) {
|
||||||
delay(100);
|
delay(100);
|
||||||
@@ -117,6 +120,7 @@ void resetValues() {
|
|||||||
TVOC = 0;
|
TVOC = 0;
|
||||||
noise = false;
|
noise = false;
|
||||||
lastCounter = 0;
|
lastCounter = 0;
|
||||||
|
currentCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to check for errors in sensors
|
// function to check for errors in sensors
|
||||||
@@ -124,16 +128,21 @@ bool checkForError(){
|
|||||||
if (!sgp.IAQmeasure()) {
|
if (!sgp.IAQmeasure()) {
|
||||||
Serial.println("SGP30: BAD");
|
Serial.println("SGP30: BAD");
|
||||||
errorSGP30 = true;
|
errorSGP30 = true;
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Serial.println("SGP30: OK");
|
Serial.println("SGP30: OK");
|
||||||
errorSGP30 = false;
|
errorSGP30 = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isnan(temperature) || isnan(humidity)){
|
if (isnan(temperature) || isnan(humidity)){
|
||||||
Serial.println("DHT11: BAD");
|
Serial.println("DHT11: BAD");
|
||||||
|
errorDHT11 = true;
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Serial.println("DHT11: OK");
|
Serial.println("DHT11: OK");
|
||||||
errorDHT11 = false;
|
errorDHT11 = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,9 +155,6 @@ void update(){
|
|||||||
|
|
||||||
sgp.getIAQBaseline(&eCO2_base, &TVOC_base);
|
sgp.getIAQBaseline(&eCO2_base, &TVOC_base);
|
||||||
|
|
||||||
// if sensor doesnt work print in serialmonitor
|
|
||||||
|
|
||||||
|
|
||||||
// read dht11 sensor
|
// read dht11 sensor
|
||||||
temperature = float(dht.readTemperature());
|
temperature = float(dht.readTemperature());
|
||||||
humidity = float(dht.readHumidity());
|
humidity = float(dht.readHumidity());
|
||||||
|
Reference in New Issue
Block a user