temp_sensor.rst 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Temperature Sensor
  2. ===================
  3. .. only:: esp32s3
  4. .. warning::
  5. This feature is not supported in v4.4
  6. Overview
  7. --------
  8. 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.
  9. 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.
  10. +--------+------------------------+------------------------+
  11. | offset | measure range(Celsius) | measure error(Celsius) |
  12. +========+========================+========================+
  13. | -2 | 50 ~ 125 | < 3 |
  14. +--------+------------------------+------------------------+
  15. | -1 | 20 ~ 100 | < 2 |
  16. +--------+------------------------+------------------------+
  17. | 0 | -10 ~ 80 | < 1 |
  18. +--------+------------------------+------------------------+
  19. | 1 | -30 ~ 50 | < 2 |
  20. +--------+------------------------+------------------------+
  21. | 2 | -40 ~ 20 | < 3 |
  22. +--------+------------------------+------------------------+
  23. Driver Usage
  24. ------------
  25. 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.
  26. .. code-block:: c
  27. temp_sensor_config_t temp_sensor = {
  28. .dac_offset = TSENS_DAC_L2,
  29. .clk_div = 6,
  30. };
  31. temp_sensor_set_config(temp_sensor);
  32. 2. Start the temp_sensor by calling :cpp:func:'temp_sensor_start'. The temperature sensor will now measure the temperature.
  33. 3. To get the current temperature, take the example below as a reference, the value you get is in Celsius.
  34. .. code-block:: c
  35. float tsens_out;
  36. temp_sensor_read_celsius(&tsens_out);
  37. 4. To stop the temperature sensor, please call :cpp:func:'temp_sensor_stop'.
  38. .. note::
  39. 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).
  40. Application Example
  41. -------------------
  42. Temperature sensor reading example: :example:`peripherals/temp_sensor`.
  43. API Reference - Normal Temp Sensor
  44. ----------------------------------
  45. .. include-build-file:: inc/temp_sensor.inc