From a70575d8b8bc35579524adeb06098942b712d1b2 Mon Sep 17 00:00:00 2001 From: Sietse Jonker Date: Fri, 1 Mar 2024 14:14:24 +0100 Subject: [PATCH] adds comments --- arduino/node-code/node-code-final.ino | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arduino/node-code/node-code-final.ino b/arduino/node-code/node-code-final.ino index 2dc8896..475d905 100644 --- a/arduino/node-code/node-code-final.ino +++ b/arduino/node-code/node-code-final.ino @@ -148,6 +148,8 @@ bool checkForError(){ void update(){ // display sensordata on oled screen displayData(); + + // send data to websocket server webSocket.sendTXT("Temp: " + String(temperature)); webSocket.sendTXT("Humi: " + String(humidity)); webSocket.sendTXT("eCO2: " + String(sgp.eCO2)); @@ -159,6 +161,7 @@ void update(){ temperature = float(dht.readTemperature()); humidity = float(dht.readHumidity()); + // check if any errors occured when reading sensors checkForError(); } @@ -177,12 +180,14 @@ void displayData() { + "Humi: " + int(humidity) + "%" + '\n' + "eCO2: " + int(sgp.eCO2) + '\n' + "TVOC: " + int(sgp.TVOC)); - + + // display the screen display.display(); } // setup function void setup() { + // make serial connection at 115200 baud Serial.begin(115200); // tell display what settings to use @@ -196,7 +201,10 @@ void setup() { pinMode(MICPIN, INPUT); pinMode(DHTPIN, INPUT); + // setup websocket connection websocketSetup(); + + // reset values resetValues(); }