int ThermistorPin;
double adcMax, Vs;
double R1 = 10000.0; // voltage divider resistor value
double Beta = 3950.0; // Beta value
double To = 298.15; // Temperature in Kelvin for 25 degree Celsius
double Ro = 10000.0; // Resistance of Thermistor at 25 degree Celsius
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
ThermistorPin = A0;
adcMax = 1023.0;
Vs = 3.3;
}
void loop() {
double Vout, Rt = 0;
double T, Tc, Tf = 0;
Vout = analogRead(ThermistorPin) * Vs / adcMax;
Rt = R1 * Vout / (Vs - Vout);
T = 1 / (1 / To + log(Rt / Ro) / Beta); // Temperature in Kelvin
Tc = T - 273.15; // Celsius
Tf = Tc * 9 / 5 + 32; // Fahrenheit
//Serial.println(Vout);
//Serial.println(Tc);
delay(500);
}
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1