const int ntcPin = 33; // Pin connected to the NTC thermistor
// Constants for NTC thermistor calculation
const float R1 = 10000; // Resistor value (10k ohm)
const float T_REF = 298.15; // Reference temperature (in Kelvin)
const float B = 3950; // Beta value of the thermistor
const float R0 = 10000; // Resistance at T_REF
void setup() {
Serial.begin(9600);
}
void loop() {
int rawValue = analogRead(ntcPin);
float voltage = rawValue * (3.3 / 4095.0); // Convert to voltage
float resistance = R1 * (3.3 / voltage - 1); // Calculate thermistor resistance
// Calculate temperature in Kelvin
float temperatureKelvin = B / (log(resistance / R0) + (B / T_REF));
// Convert to Celsius
float temperatureCelsius = temperatureKelvin - 273.15;
Serial.print("Temperature: ");
Serial.print(temperatureCelsius);
Serial.println(" °C");
delay(2000); // Read every 2 seconds
}