dvdsk / HomeAutomation

System to automate lighting and audio interacting through a web interface and telegram bot
3 stars 1 forks source link

[bug][improvement] endless loop possible in CO2 meting #14

Open dvdsk opened 7 years ago

dvdsk commented 7 years ago

while (Serial1.available() > 8){ //TODO needs a fail condition if (!Serial1.read() == 0XFF){//check if reply from sensor in buffer Serial1.read(); } else{ Serial1.readBytes(response+1, 8); responseHigh = (uint8_t) response[2]; responseLow = (uint8_t) response[3]; ppm = ((uint16_t)responseHigh)*256+(uint16_t)responseLow; Serial.println(ppm); *(slowData+Idx::CO2) = ppm; *(slowData+Idx::UPDATED) |= 1 << Idx::CO2; //indicate co2 has been updated return; } } return; }