// Basic NTC Thermistor demo
// Assumes a 10K@25℃ NTC thermistor connected in series with a 10K resistor.
// Based on Copyright (C) 2021, Uri Shaked https://wokwi.com/arduino/projects/299330254810382858
const int Temp_pin = 15;
double Thermistor(int RawADC) {
double Temp;
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
Temp = 1.0 / (log(1 / (4095.0 / RawADC - 1)) / BETA + 1.0 / 298.15) - 273.15;
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void setup() {
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(Temp_pin);
Serial.print("analogValue: ");
Serial.print(analogValue);
// const float BETA = 3950; // should match the Beta Coefficient of the thermistor
// float celsius = 1.0 / (log(1 / (4095. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
double celsius = Thermistor(analogValue);
Serial.print(" Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
delay(1000);
}