/**
Basic NTC Thermistor demo
https://wokwi.com/arduino/projects/299330254810382858
Assumes a 10K@25℃ NTC thermistor connected in series with a 10K resistor.
Copyright (C) 2021, Uri Shaked
*/
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
int DELAY_MS = 50; // 1000ms/50ms = 20Hz
// Va0 = Vdd/(Rt+R4) * R4
// R4 = Rt = 10k
// Va0 = 5/(10k+10k) * 10k = 2.5V ~ 512 value
// Rt = 5k
// R4 = 10k
// Va0 = 5/(5k+10k) * 10k = 3.33V
void setup() {
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(A0);
Serial.print("Analog value: ");
Serial.print(analogValue);
Serial.print(" - ");
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
delay(DELAY_MS);
}