moved websocket class to work with esp
This commit is contained in:
@@ -9,7 +9,8 @@ nodeReadings::nodeReadings() {
|
||||
dht = new DHT(DHTPIN, DHTTYPE);
|
||||
display = new Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
webSocket = new WebSocketsClient();
|
||||
// webSocket = new WebSocketsClient();
|
||||
webSocket = new websockets(); //nu naar eigen class
|
||||
sgp = new Adafruit_SGP30();
|
||||
|
||||
resetValues();
|
||||
@@ -46,13 +47,15 @@ void nodeReadings::setup(){
|
||||
|
||||
pinMode(MICPIN, INPUT);
|
||||
pinMode(DHTPIN, INPUT);
|
||||
|
||||
webSocket->websocketSetup();
|
||||
|
||||
// webSocketClass.websocketSetup();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void nodeReadings::loop() {
|
||||
// loop the websocket connection so it stays alive
|
||||
// webSocket->loop();
|
||||
|
||||
// update when interval is met
|
||||
if (currentMillis - lastMillis >= interval){
|
||||
lastMillis = millis();
|
||||
@@ -61,6 +64,9 @@ void nodeReadings::loop() {
|
||||
|
||||
// update the counter
|
||||
currentMillis = millis();
|
||||
|
||||
// loop the websocket connection so it stays alive
|
||||
webSocket->loop();
|
||||
}
|
||||
|
||||
void nodeReadings::update(){
|
||||
@@ -69,7 +75,7 @@ void nodeReadings::update(){
|
||||
displayData();
|
||||
|
||||
// webSocket->sendTXT("{\"Temp\":\"" + String(temperature) + "\",\"Humi\":\"" + String(humidity) + "\",\"eCO2\":\"" + String(sgp->eCO2) + "\",\"TVOC\":\"" + String(sgp->TVOC) + "\"}");
|
||||
webSocket->sendTXT("{\"node\": \"" + String(WiFi.macAddress()) + "\", \"Temp\":\"" + String(temperature) + "\",\"Humi\":\"" + String(humidity) + "\",\"eCO2\":\"" + String(sgp->eCO2) + "\",\"TVOC\":\"" + String(sgp->TVOC) + "\"}");
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user