added comments
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
@@ -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);
|
||||
@@ -90,6 +95,7 @@ void nodeReadings::displayData() {
|
||||
display->display();
|
||||
}
|
||||
|
||||
//function
|
||||
void nodeReadings::checkForError(){
|
||||
if (!sgp->IAQmeasure()) {
|
||||
Serial.println("SGP30: BAD");
|
||||
|
Reference in New Issue
Block a user