// Pin assignments
#define NTC_SENSOR_PIN 34 // Analog pin connected to NTC sensor
#define LED_PIN 21 // Digital pin connected to LED
// Calibration constants for the NTC sensor (you may need to adjust these)
#define BETA 3950 // Beta coefficient (change this according to your NTC sensor)
#define R25 10000 // Resistance at 25°C in Ohms
void setup() {
Serial.begin(115200); // Initialize serial communication
pinMode(LED_PIN, OUTPUT); // Set the LED pin as an output
digitalWrite(LED_PIN, LOW); // Initially turn off the LED
}
void loop() {
int rawValue = analogRead(NTC_SENSOR_PIN); // Read the raw value from the NTC sensor
float voltage = (rawValue / 4095.0) * 3.3; // Convert to voltage (3.3V reference)
// Calculate the resistance of the NTC thermistor
float resistance = (3.3 / voltage) - 1;
resistance = R25 / resistance;
// Calculate the temperature using the Beta formula
float temperature = 1.0 / (log(resistance / R25) / BETA + 1.0 / 298.15) - 273.15; // Convert to Celsius
// Print the temperature to the serial monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
// Check if the temperature exceeds or equals 80°C
if (temperature >= 80.0) {
digitalWrite(LED_PIN, HIGH); // Turn on the LED if the temperature is 80°C or above
} else {
digitalWrite(LED_PIN, LOW); // Turn off the LED if the temperature is below 80°C
}
delay(1000); // Wait 1 second before taking another reading
}