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(); }