Measure temperatur sensor multiple times

This commit is contained in:
Ollo 2020-10-30 22:51:32 +01:00
parent 8ce2b7f303
commit 8c840c599a

View File

@ -339,19 +339,18 @@ void readSensors() {
/* Required to read the temperature once */ /* Required to read the temperature once */
float temp[2] = {0, 0}; float temp[2] = {0, 0};
float* pFloat = temp; float* pFloat = temp;
// first read returns crap, ignore result and read twice for(int i=0; i < 10; i++) {
if (dallas.readAllTemperatures(pFloat, 2) > 0) { // first read returns crap, ignore result and read twice
Serial << "t1: " << String(temp[0]) << endl; if (dallas.readAllTemperatures(pFloat, 2) > 0) {
Serial << "t2: " << String(temp[1]) << endl; Serial << "t1: " << String(temp[0]) << endl;
Serial << "t2: " << String(temp[1]) << endl;
}
delay(200);
if (i <= 2) {
temp1.add(temp[0]);
temp2.add(temp[1]);
}
} }
delay(200);
if (dallas.readAllTemperatures(pFloat, 2) > 0) {
Serial << "t1: " << String(temp[0]) << endl;
Serial << "t2: " << String(temp[1]) << endl;
}
temp1.add(temp[0]);
temp2.add(temp[1]);
/* Use the Ultrasonic sensor to measure waterLevel */ /* Use the Ultrasonic sensor to measure waterLevel */