ESP32 has on chip temperature sensor, This sensor is not usable to monitor external temperature, It is used to monitor its core temperature. In this tutorial we are monitoring on chip temperature sensor data.
Update: The temp sensor is obsolete on most of the ESP32.
Arduino Code for ESP32 Internal Temperature Sensor
/* * https://circuits4you.com * ESP32 Internal Temperature Sensor Example */ #ifdef __cplusplus extern "C" { #endif uint8_t temprature_sens_read(); #ifdef __cplusplus } #endif uint8_t temprature_sens_read(); //==================================================== // Setup //==================================================== void setup() { Serial.begin(115200); } //==================================================== // Loop //==================================================== void loop() { Serial.print("Temperature: "); // Convert raw temperature in F to Celsius degrees Serial.print((temprature_sens_read() - 32) / 1.8); Serial.println(" C"); delay(1000); }
Results
Open Serial monitor at baud rate of 115200 and see the temperature of chip.
Example shows 53.33 ° C because the function just returns 128 (sensor not present).