const int analogPin = A0; // Analog pin connected to voltage divider
const float fixed_RR = 10000.0; // Fixed resistor value (10kΩ)
const float Beta = 3950.0; // Beta coefficient of thermistor
const float TK = 298.15; // Reference temperature in Kelvin (25°C)
const float RT = 10000.0; // Thermistor resistance at T0
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Initialize serial monitor
}
void loop() {
// put your main code here, to run repeatedly:
int ADC_Value = analogRead(analogPin); // Read analog value (0-1023)
float V_out = ADC_Value * 5.0 / 1023.0; // Convert ADC value to voltage
float Res_thermistor = (R_fixed * V_out) / (5.0 - V_out); // Calculate resistance
// Calculate temperature using Beta equation
float T_kelvin = (Beta * TK) / (Beta + (TK * log(Res_thermistor / RT)));
float T_celsius = T_kelvin - 273.15; // Convert Kelvin to Celsius
Serial.print("Temperature: ");
Serial.print(T_celsius);
Serial.println(" °C");
delay(1000); // Wait 1 second before next reading
}