Closed
Description
Related area
System/Chip
Hardware specification
ESP32-S3
Is your feature request related to a problem?
no
Describe the solution you'd like
i propose a new getter function to the ESP class to get the chip internal temperature.
here is an example function to read the chip internal temperature sensor:
#include "soc/adc_periph.h"
void init_temperature_sensor()
{
*((uint32_t*) SENS_SAR_TSENS_CTRL_REG) |= SENS_TSENS_POWER_UP_FORCE | SENS_TSENS_POWER_UP;
}
float temprature_sens_read()
{
*((uint32_t*) SENS_SAR_TSENS_CTRL_REG) |= SENS_TSENS_DUMP_OUT;
ulong time0 = millis();
while(true)
{
if(millis() - time0 > 250)
return -1;
bool ready = *((uint32_t*) SENS_SAR_TSENS_CTRL_REG) & SENS_TSENS_READY;
if(ready)
{
uint8_t value = *((uint32_t*) SENS_SAR_TSENS_CTRL_REG) & SENS_TSENS_OUT;
float temp = 0.4386 * value - 20.52;
*((uint32_t*) SENS_SAR_TSENS_CTRL_REG) &= ~SENS_TSENS_DUMP_OUT;
return temp;
}
}
}
Improvements might be to check the offset value as described in TRM on page 1164
Describe alternatives you've considered
to my knowledge the is no hal function implemented to read the internal temperature sensor from the main processor
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.
Metadata
Metadata
Assignees
Type
Projects
Status
Done