Esp32S3 : Is it possible to get the temperature from the internal T° sensor with a decimal part ?

ThomasESP32
Posts: 282
Joined: Thu Jul 14, 2022 5:15 am

Esp32S3 : Is it possible to get the temperature from the internal T° sensor with a decimal part ?

Postby ThomasESP32 » Tue Apr 29, 2025 1:35 pm

Good afternoon,

I am using an Esp32S3 and I configured/installed the internal emperature sensor using the following lines :

temperature_sensor_handle_t TempSensor;
temperature_sensor_config_t temp_sensor_config;
float Temperature = 0.0f;
char Msg[COM_MSG_MAX_LEN];
uint8_t Length = 0;

temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80);
temperature_sensor_install(&temp_sensor_config, &TempSensor);
temperature_sensor_enable(TempSensor);

Now, I would like to ask the internal temperature of the chip and get it with a decimal part.
So, I do the following thing :

temperature_sensor_get_celsius(TempSensor, &Temperature);
sprintf(Msg, (const char *)"\n%f", Temperature);
Length = strlen(Msg);

When I print the Msg variable, I can see the temperature containing a decimal part.
Unfortunately, this decimal part is always the same and the temperature changes degree by degree.

Do you think it is possible to see the decimal part changing ?
If yes, how to do it please ?

Best regards,

Thomas TRUILHE

Who is online

Users browsing this forum: DuckDuckGo [Bot], Google [Bot] and 1 guest