/**
Basic NTC Thermistor demo
https://wokwi.com/arduino/projects/299330254810382858
Assumes a 10K@25℃ NTC thermistor connected in series with a 10K resistor.
Copyright (C) 2021, Uri Shaked
*/
#define NTC 0
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
void setup() {
Serial.begin(9600);
Serial.println("Hello, ESP32-C6!");
pinMode(NTC, INPUT);
}
void loop() {
int analogValue = analogRead(NTC);
Serial.println(analogValue);
float celsius = 1 / (log(1 / (4096. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
delay(1000);
}
// // Constants for the NTC thermistor
// const int thermistorPin = 0; // Pin connected to the NTC thermistor
// const int seriesResistor = 10000; // Series resistor value in ohms (10kΩ)
// const float nominalResistance = 10000; // Resistance of the thermistor at 25 degrees Celsius
// const float nominalTemperature = 25; // Nominal temperature in Celsius
// const float bCoefficient = 3950; // Beta coefficient of the thermistor
// void setup() {
// Serial.begin(115200);
// pinMode(thermistorPin, INPUT);
// }
// void loop() {
// // Read the analog value (0-1023 for 10-bit ADC)
// int analogValue = analogRead(thermistorPin);
// Serial.println(analogValue);
// // Convert the analog value to resistance
// float resistance = seriesResistor / ((1023.0 / analogValue) - 1);
// // Calculate temperature in Celsius using the Steinhart-Hart equation
// float temperature = 1 / (log(1 / (4096. / analogValue - 1)) / bCoefficient + 1.0 / 298.15) - 273.15;
// // Print the temperature to the Serial Monitor
// Serial.print("Temperature: ");
// Serial.print(temperature);
// Serial.println(" °C");
// delay(1000); // Read every second
// }Loading
esp32-c6-devkitc-1
esp32-c6-devkitc-1