From 7ae860ec72e92ad9c20b07aad2cf52abe6a4e4ce Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 9 Jan 2021 09:33:09 +0100 Subject: [PATCH] Fixed incorrect reading of analog temperature --- src/HwTools.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/HwTools.cpp b/src/HwTools.cpp index 6dabb67a..94219145 100644 --- a/src/HwTools.cpp +++ b/src/HwTools.cpp @@ -176,12 +176,11 @@ double HwTools::getTemperature() { double HwTools::getTemperatureAnalog() { if(tempAnalogSensorPin != 0xFF) { float adcCalibrationFactor = 1.06587; - int adcRead = analogRead(tempAnalogSensorPin); int volts; #if defined(ESP8266) - volts = (analogRead(vccPin) / 1024.0) * 3.3; + volts = (analogRead(tempAnalogSensorPin) / 1024.0) * 3.3; #elif defined(ESP32) - volts = (analogRead(vccPin) / 4095.0) * 3.3; + volts = (analogRead(tempAnalogSensorPin) / 4095.0) * 3.3; #endif return ((volts * adcCalibrationFactor) - 0.4) / 0.0195; }