added comments

This commit is contained in:
Dano van den Bosch
2024-03-21 11:31:03 +01:00
parent ec336f914a
commit f94c452a19
2 changed files with 9 additions and 5 deletions

View File

@@ -4,12 +4,10 @@ nodeReadings esp32Node;
void setup() {
// put your setup code here, to run once:
esp32Node.setup();
esp32Node.resetValues();
}
void loop() {
// put your main code here, to run repeatedly:
esp32Node.loop();
}

View File

@@ -2,16 +2,19 @@
nodeReadings::nodeReadings() {
//Making all the new object as defined in the .h file
dht = new DHT(DHTPIN, DHTTYPE);
display = new Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
webSocket = new websockets(); //nu naar eigen class
webSocket = new websockets();
sgp = new Adafruit_SGP30();
//setting the reding for every 5 sec
interval = 5000;
resetValues();
}
//Script for simpley reseting every value to 0
void nodeReadings::resetValues() {
counter = 0;
eCO2 = 0;
@@ -25,6 +28,7 @@ void nodeReadings::resetValues() {
noise = false;
}
//Setup for initilising the dht and sgp sensors. Also the display is set up.
void nodeReadings::setup(){
// make serial connection at 115200 baud
Serial.begin(115200);
@@ -63,6 +67,7 @@ void nodeReadings::update(){
// display sensordata on oled screen
displayData();
//send the data to the websockets
webSocket->sendMyText("{\"node\": \"" + String(WiFi.macAddress()) + "\", \"Temp\":\"" + String(temperature) + "\",\"Humi\":\"" + String(humidity) + "\",\"eCO2\":\"" + String(sgp->eCO2) + "\",\"TVOC\":\"" + String(sgp->TVOC) + "\"}");
sgp->getIAQBaseline(&eCO2_base, &TVOC_base);
@@ -83,13 +88,14 @@ void nodeReadings::displayData() {
display->setTextSize(2);
display->setTextColor(SH110X_WHITE);
display->setCursor(0,0);
display->println("Temp: " + String(int(temperature)) + " C");
display->println("Humi: " + String(int(humidity)) + " %");
display->println("Temp: " + String(int(temperature)) + "C");
display->println("Humi: " + String(int(humidity)) + "%");
display->println("eCO2: " + String(sgp->eCO2));// + " ppm");
display->println("TVOC: " + String(sgp->TVOC));// + " ppb");
display->display();
}
//function
void nodeReadings::checkForError(){
if (!sgp->IAQmeasure()) {
Serial.println("SGP30: BAD");