Skip to content

Commit c1adfe5

Browse files
committed
esp32/modesp32: Updated to idf v5.0.2.
Signed-off-by: Patrick Joy <patrick@joytech.com.au>
1 parent 6ec94dd commit c1adfe5

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

docs/library/esp32.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,18 @@ Functions
4444

4545
Read the raw value of the internal temperature sensor, returning an integer.
4646

47-
.. Note::
48-
Only available on ESP32.
47+
Only available on ESP32.
4948

5049
.. function:: temperature()
5150

5251
Read the value of the internal temperature sensor in celsius, returning a float.
5352

53+
Available on ESP32-S2, S3 and C3.
54+
5455
.. Note::
55-
Available on ESP32-S2 and ESP32-C3.
56+
The temperature sensor is designed primarily to measure the temperature changes inside
57+
the chip. The temperature value depends on factors like microcontroller clock frequency
58+
or I/O load. Generally, the chip’s internal temperature might be higher than the ambient temperature.
5659

5760
.. function:: hall_sensor()
5861

ports/esp32/modesp32.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,20 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp32_raw_temperature_obj, esp32_raw_temperatur
170170

171171
#endif
172172

173-
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
173+
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
174174

175-
#include "driver/temp_sensor.h"
175+
#include "driver/temperature_sensor.h"
176176

177177
STATIC mp_obj_t esp32_temperature(void) {
178178

179-
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT();
180-
temp_sensor_get_config(&temp_sensor);
181-
temp_sensor.dac_offset = TSENS_DAC_DEFAULT; // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
182-
temp_sensor_set_config(temp_sensor);
183-
temp_sensor_start();
179+
temperature_sensor_handle_t temp_sensor = NULL;
180+
temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(0, 50);
181+
temperature_sensor_install(&temp_sensor_config, &temp_sensor);
182+
temperature_sensor_enable(temp_sensor);
184183
float tsens_out;
185-
temp_sensor_read_celsius(&tsens_out);
186-
temp_sensor_stop();
184+
temperature_sensor_get_celsius(temp_sensor, &tsens_out);
185+
temperature_sensor_disable(temp_sensor);
186+
temperature_sensor_uninstall(temp_sensor);
187187

188188
return mp_obj_new_float(tsens_out);
189189
}
@@ -223,7 +223,7 @@ STATIC const mp_rom_map_elem_t esp32_module_globals_table[] = {
223223
#if CONFIG_IDF_TARGET_ESP32
224224
{ MP_ROM_QSTR(MP_QSTR_raw_temperature), MP_ROM_PTR(&esp32_raw_temperature_obj) },
225225
#endif
226-
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
226+
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
227227
{ MP_ROM_QSTR(MP_QSTR_temperature), MP_ROM_PTR(&esp32_temperature_obj) },
228228
#endif
229229
{ MP_ROM_QSTR(MP_QSTR_idf_heap_info), MP_ROM_PTR(&esp32_idf_heap_info_obj) },

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy