Skip to main content

wokwi-ntc-temperature-sensor Reference

Analog temperature sensor: NTC (negative temperature coefficient) thermistor.

Pin names#

NameDescription
VCCPositive power supply
OUTOutput signal (analog)
GNDGround

Attributes#

NameDescriptionDefault value
temperatureInitial temperature value (celsius)"24"
betaThe beta coefficient of the thermistor"3950"

Reading the temperature#

The temperature sensor module includes a 10K NTC thermistor in series with a 10K resistor.

This setup produces a voltage that depends on the temperature. You can read this voltage by connecting the OUT pin of the thermistor to an analog input pin and then using the analogRead() function.

Use the following code to convert the return value of analogRead() into a temperature value (in celsius):

const float BETA = 3950; // should match the Beta Coefficient of the thermistor
int analogValue = analogRead(A0);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;

Simulator examples#