Language: EN

esp32-sensor-temperatura-integrado

How to read the integrated temperature sensor in the ESP32

The ESP32 has an integrated temperature sensor in the SoC itself, which allows us to measure the processor temperature accurately, without the need for additional components.

The purpose of this sensor is not to measure the ambient temperature, but the temperature of the CPU. Normally, to detect if it is overheating excessively.

However, if the ESP32 has just turned on after a long disconnected period (for example, after a long Deep Sleep), it can give an approximate measurement of the ambient temperature.

It is important to note that the accuracy of the integrated temperature sensor may vary due to environmental conditions and hardware tolerances.

For more accurate measurements, it is recommended to perform a calibration. This involves comparing the temperature sensor measurements with a reference thermometer and making adjustments in the software as necessary.

Temperature Reading

To read the temperature with the ESP32, you can use the software API provided by Espressif Systems.

Below is an example of how to read the sensor temperature in code:

void setup() {
  Serial.begin(115200);
}

void loop() {
  float temp_celsius = temperatureRead();

  Serial.print("Temp onBoard ");
  Serial.print(temp_celsius);
  Serial.println("°C");

  delay(1000);
}