EasyManua.ls Logo

Espressif ESP32-S2 - Page 406

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
The conversion relationship is the first columns of the table below. Among them, offset = 0 is the main measurement
option, and other values are extended measurement options.
offset measure range(Celsius) measure error(Celsius)
-2 50 ~ 125 < 3
-1 20 ~ 100 < 2
0 -10 ~ 80 < 1
1 -30 ~ 50 < 2
2 -40 ~ 20 < 3
Driver Usage
1. Initialize the temperature sensor by calling the function temp_sensor_set_config() and pass to it a
temp_sensor_config_t structure. The temp_sensor_config_t structure should contain all the
required parameters. See the example below.
temp_sensor_config_t temp_sensor = {
.dac_offset = TSENS_DAC_L2,
.clk_div = 6,
};
temp_sensor_set_config(temp_sensor);
2. Start the temp_sensor by calling :cpp:func:temp_sensor_start. The temperature sensor will now measure
the temperature.
3. To get the current temperature, take the example below as a reference, the value you get is in Celsius.
float tsens_out;
temp_sensor_read_celsius(&tsens_out);
4. To stop the temperature sensor, please call :cpp:func:temp_sensor_stop.
Note: If you want dynamic reconfiguration, you need to stop the sensor first (temp_sensor_stop), set the new
configuration (temp_sensor_set_config), then start the sensor again (temp_sensor_start).
Application Example
Temperature sensor reading example: peripherals/temp_sensor.
API Reference - Normal Temp Sensor
Header File
components/driver/esp32s2/include/driver/temp_sensor.h
Functions
esp_err_t temp_sensor_set_config(temp_sensor_config_t tsens)
Set parameter of temperature sensor.
Return
ESP_OK Success
Parameters
tsens:
esp_err_t temp_sensor_get_config(temp_sensor_config_t *tsens)
Get parameter of temperature sensor.
Espressif Systems 395
Submit Document Feedback
Release v4.4

Table of Contents