wokwi / avr8js

Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node.js
https://blog.wokwi.com/avr8js-simulate-arduino-in-javascript/
MIT License
481 stars 78 forks source link

Internal temperature sensor #104

Closed Koepel closed 3 years ago

Koepel commented 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
urish commented 3 years ago

Fixed - we now return a constant value of 21.9°C.

Thanks for the detailed report with the reproduction sketch, that's super useful!