Merge branch 'docs/format_temp_sensor' into 'release/v4.4'

format temp_sensor.rst

See merge request espressif/esp-idf!22475
This commit is contained in:
Krzysztof Budzynski
2023-03-14 14:15:30 +08:00

View File

@@ -6,54 +6,63 @@ Overview
The {IDF_TARGET_NAME} has a built-in temperature sensor used to measure the chip's internal temperature, and hard to measure the environmental temperature accurately. Being built-in means that the temperature sensor should work on any {IDF_TARGET_NAME} regardless of what board the chip is embedded in. The temperature sensor module contains an 8-bit Sigma-Delta ADC and a temperature offset DAC. The {IDF_TARGET_NAME} has a built-in temperature sensor used to measure the chip's internal temperature, and hard to measure the environmental temperature accurately. Being built-in means that the temperature sensor should work on any {IDF_TARGET_NAME} regardless of what board the chip is embedded in. The temperature sensor module contains an 8-bit Sigma-Delta ADC and a temperature offset DAC.
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. The conversion relationship is the first columns of the table below. Among them, Offset = 0 is the default measurement option, and other values are extended measurement options.
+--------+------------------------+------------------------+ .. list-table::
| offset | measure range(Celsius) | measure error(Celsius) | :header-rows: 1
+========+========================+========================+ :widths: 25 50 50
| -2 | 50 ~ 125 | < 3 |
+--------+------------------------+------------------------+ * - Offset
| -1 | 20 ~ 100 | < 2 | - Measurement Range (°C)
+--------+------------------------+------------------------+ - Measurement Error (°C)
| 0 | -10 ~ 80 | < 1 | * - -2
+--------+------------------------+------------------------+ - 50 ~ 125
| 1 | -30 ~ 50 | < 2 | - < 3
+--------+------------------------+------------------------+ * - -1
| 2 | -40 ~ 20 | < 3 | - 20 ~ 100
+--------+------------------------+------------------------+ - < 2
* - 0
- -10 ~ 80
- < 1
* - 1
- -30 ~ 50
- < 2
* - 2
- -40 ~ 20
- < 3
Driver Usage Driver Usage
------------ ------------
1. Initialize the temperature sensor by calling the function :cpp:func:`temp_sensor_set_config` and pass to it a :cpp:type:`temp_sensor_config_t` structure. The :cpp:type:`temp_sensor_config_t` structure should contain all the required parameters. See the example below. 1. Initialize the temperature sensor by calling the function :cpp:func:`temp_sensor_set_config` and pass to it a :cpp:type:`temp_sensor_config_t` structure. The :cpp:type:`temp_sensor_config_t` structure should contain all the required parameters. See the example below.
.. code-block:: c .. code-block:: c
temp_sensor_config_t temp_sensor = { temp_sensor_config_t temp_sensor = {
.dac_offset = TSENS_DAC_L2, .dac_offset = TSENS_DAC_L2,
.clk_div = 6, .clk_div = 6,
}; };
temp_sensor_set_config(temp_sensor); 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. 1. Start the temperature sensor by calling :cpp:func:`temp_sensor_start`, and then the sensor will start to measure the temperature.
3. To get the current temperature, take the example below as a reference, the value you get is in Celsius. 2. To get the current temperature, you can take the example below as a reference, and the temperatures you get are in Celsius.
.. code-block:: c .. code-block:: c
float tsens_out; float tsens_out;
temp_sensor_read_celsius(&tsens_out); temp_sensor_read_celsius(&tsens_out);
4. To stop the temperature sensor, please call :cpp:func:'temp_sensor_stop'. 1. To stop the temperature sensor, please call :cpp:func:`temp_sensor_stop`.
.. note:: .. 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). To realize dynamic reconfiguration, you need to stop the sensor first with :cpp:func:`temp_sensor_stop`, then set the new configuration with :cpp:func:`temp_sensor_set_config`, and then re-start the sensor with :cpp:func:`temp_sensor_start`.
Application Example Application Example
------------------- -------------------
Temperature sensor reading example: :example:`peripherals/temp_sensor`. For examples of the temperature sensor, please refer to :example:`peripherals/temp_sensor`.
API Reference - Normal Temp Sensor API Reference - Normal Temp Sensor
---------------------------------- ----------------------------------