Peaks on my temperature graphs

Getting 100% accurate readings all the time when using $10 worth of hardware is mostly wishful thinking I guess :sunglasses:

I too had random spikes in my otherwise so pretty graph from time to time that I couldn’t derive to something specific. So instead of doing a ton of trouble shooting I just added some “sanity code”.

Readings that deviate more than +/- 30 degrees from the previous are simply ignored and a notice is printed in my terminal window:

void startSensorConversation() {
	
	DS18B20.requestTemperatures();
	newTemp = true;
}

void getSensorData() {
	
	if (newTemp) {

		float temp1E = DS18B20.getTempC(sensor1E);
		float roundedValue1E = ceilf(temp1E * 100) / 100;

		if (roundedValue1E < (lastValue1E - 30) || roundedValue1E > (lastValue1E + 30) ) {
			terminal.println("Error reading sensor 1E !");
		}
		
		else {
			lastValue1E = roundedValue1E;
			Serial.print("Bedroom: ");
			Serial.println(roundedValue1E);
			Blynk.virtualWrite(6, roundedValue1E);
		}

		float temp4B = DS18B20.getTempC(sensor4B);
		float roundedValue4B = ceilf(temp4B * 100) / 100;
		
		if (roundedValue4B < (lastValue4B - 30) || roundedValue4B > (lastValue4B + 30) ) {
			terminal.println("Error reading sensor 4B !");
		}
		
		else {
			lastValue4B = roundedValue4B;
			Serial.print("Living room: ");
			Serial.println(roundedValue4B);
			Blynk.virtualWrite(5, roundedValue4B);
    	}
    	
		newTemp = false;
	}
}

The code is from my old 433 Mhz project

1 Like