Closed Koepel closed 3 years ago
The channel for the internal temperature sensor of the ATmega328P returns a random value. For an Arduino board, the internal temperature sensor is just a gimmick. A fixed value of 350 for the raw ADC value (for 21.1 °C) is good enough.
Test sketch: theorycircuit.com/arduino-internal-temperature-sensor
Wokwi project: wokwi.com/arduino/projects/308789665572323906
Result with real Arduino Uno (at room temperature of 22 °C, offset in sketch not adjusted):
Internal Temperature Sensor 13.7 12.9 13.7 12.9 12.9
Result with Wokwi:
Internal Temperature Sensor -43.7 -252.7 512.9 467.0 446.5
Fixed - we now return a constant value of 21.9°C.
Thanks for the detailed report with the reproduction sketch, that's super useful!
The channel for the internal temperature sensor of the ATmega328P returns a random value. For an Arduino board, the internal temperature sensor is just a gimmick. A fixed value of 350 for the raw ADC value (for 21.1 °C) is good enough.
Test sketch: theorycircuit.com/arduino-internal-temperature-sensor
Wokwi project: wokwi.com/arduino/projects/308789665572323906
Result with real Arduino Uno (at room temperature of 22 °C, offset in sketch not adjusted):
Result with Wokwi: