Almost done with the OOP
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "arduino.h"
|
||||
#include "nodeCodeHeader.h"
|
||||
#include <WebSocketsClient.h>
|
||||
|
||||
WebSocketsClient webSocket;
|
||||
|
||||
nodeReadings::nodeReadings() {
|
||||
}
|
||||
@@ -23,7 +26,7 @@ void nodeReadings::setup(){
|
||||
|
||||
void nodeReadings::loop() {
|
||||
// loop the websocket connection so it stays alive
|
||||
webSocket.loop();
|
||||
// webSocket.loop();
|
||||
|
||||
// update when interval is met
|
||||
if (currentMillis - lastMillis >= interval){
|
||||
@@ -65,4 +68,37 @@ void nodeReadings::update(){
|
||||
|
||||
// check if any errors occured when reading sensors
|
||||
checkForError();
|
||||
}
|
||||
|
||||
void nodeReadings::displayData() {
|
||||
// clear display for new info
|
||||
display.clearDisplay();
|
||||
|
||||
// display the data on the oled screen
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SH110X_WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Temperature: " + String(temperature) + " C");
|
||||
display.println("Humidity: " + String(humidity) + " %");
|
||||
display.println("eCO2: " + String(sgp.eCO2) + " ppm");
|
||||
display.println("TVOC: " + String(sgp.TVOC) + " ppb");
|
||||
display.display();
|
||||
}
|
||||
|
||||
void nodeReadings::checkForError(){
|
||||
if (!sgp.IAQmeasure()) {
|
||||
Serial.println("SGP30: BAD");
|
||||
errorSGP30 = true;
|
||||
} else {
|
||||
Serial.println("SGP30: OK");
|
||||
errorSGP30 = false;
|
||||
}
|
||||
|
||||
if (isnan(temperature) || isnan(humidity)){
|
||||
Serial.println("DHT11: BAD");
|
||||
errorDHT11 = true;
|
||||
} else {
|
||||
Serial.println("DHT11: OK");
|
||||
errorDHT11 = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user