#define TEMP_PIN PA0 // Pin to volt div
#define R1_VALUE 10000 // R=10K ohm
#define BETA_COEFFICIENT 3950
void setup() {
Serial.begin(9600); // serial comm begin
}
void loop() {
int analogValue = analogRead(TEMP_PIN); // Read analog value from thermistor
float resistance = (R1_VALUE * (1023.0 / analogValue - 1)); // Calculate resistance of thermistor
// Calculate temperature in Celsius using Beta formula
float temperature = (1 / ((log(resistance / R1_VALUE) / BETA_COEFFICIENT) + (1 / (25 + 273.15)))) - 273.15;
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
delay(1000); // Wait be4 next reading (time = 1 sec)
}