Skip to main content
Analog temperature sensor: NTC (negative temperature coefficient) thermistor.

Pin names

VCC
Power
Positive power supply
OUT
Analog Output
Output signal (analog)
GND
Ground
Ground

Attributes

temperature
string
default:"24"
Initial temperature value (celsius)
beta
string
default:"3950"
The beta coefficient of the thermistor

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

Build docs developers (and LLMs) love