// Define constants
const float BETA = 3950; // Thermistor beta value (specific to the thermistor you're using)
void setup() {
// Start serial communication
Serial.begin(9600);
}
void loop() {
// Read the analog value from the thermistor
int analogValue = analogRead(A0);
// Calculate the temperature in Celsius using the Steinhart-Hart equation
float c = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
// Convert Celsius to Fahrenheit
float f = ((c * 9.0 / 5.0) + 32);
// Calculate the thermistor resistance
float r = 10000 * ((1023.0 / analogValue) - 1.0);
// Print the results to the serial monitor
Serial.print("Temperature: ");
Serial.print(c); // Temperature in Celsius
Serial.print(" C ");
Serial.print(f); // Temperature in Fahrenheit
Serial.println(" F");
Serial.print("Analog Value: ");
Serial.print(analogValue); // Raw analog value
Serial.print(" Resistance: ");
Serial.println(r); // Thermistor resistance
// Wait for 1 second before reading again
delay(1000);
}