ESP32 Internal Temperature Sensor Example
Introduction
The ESP32-S2 has a built-in temperature sensor used to measure the chip's internal temperature. This sensor is not usable to monitor external temperature, It is used to monitor its core temperature. The temperature sensor module contains an 8-bit analog-to-digital converter (ADC) and a digital-to-analog converter (DAC) to compensate for the temperature measurement.
Note - The temperature sensor is designed primarily to measure the temperature changes inside the chip. The internal temperature of a chip is usually higher than the ambient temperature, and is affected by factors such as the microcontroller's clock frequency or I/O load, and the external thermal environment.
Step 1: Connect Board to Laptop
Step 2: Internal Temperature Sensor Example Code
Select boar ESP32 DEV Module from Tools >> Boards menu, then select appropriate com port. Upload this program to ESP32.
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
uint8_t temprature_sens_read();
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.print("Temperature: ");
Serial.print(temprature_sens_read());// Print raw temperature in F
Serial.println(" F");
delay(1000);
}