esp-idf/examples/peripherals/temp_sensor
2022-03-04 18:13:35 +08:00
..
main Temperature_sensor: Create new temperature sensor API 2022-03-04 18:13:35 +08:00
CMakeLists.txt temp_sensor: add calibration for esp32c3 2021-02-23 10:48:17 +08:00
pytest_temp_sensor_example.py Temperature_sensor: Create new temperature sensor API 2022-03-04 18:13:35 +08:00
README.md Temperature_sensor: Create new temperature sensor API 2022-03-04 18:13:35 +08:00

Supported Targets ESP32-S2 ESP32-C3 ESP32-S3

Temperature Sensor Example

The ESP32-S2/C3/S3 has a built-in temperature sensor. The temperature sensor module contains an 8-bit Sigma-Delta ADC and a temperature offset DAC.

The conversion relationship is the first two columns of the table below. Among them, offset = 0(default) is the main measurement option, and other values are extended measurement options.

DAC level offset measure range(℃) measure error(℃)
0 -2 50 ~ 125 < 3
1 -1 20 ~ 100 < 2
2 0 -10 ~ 80 < 1
3 1 -30 ~ 50 < 2
4 2 -40 ~ 20 < 3

How to use example

Before project configuration and build, be sure to set the correct chip target using idf.py set-target <chip_name>.

Hardware Required

  • A development board with ESP32-S2/C3/S3 SoC (e.g., ESP32-S2-Saola-1, ESP32-S2-DevKitM-1, ESP32-C3-DevKitM-1, ESP32-S3-WROOM-1, etc.)
  • A USB cable for power supply and programming

Build and Flash

Build the project and flash it to the board, then run monitor tool to view serial output:

Run idf.py -p PORT flash monitor to build, flash and monitor the project.

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

I (276) example: Initializing Temperature sensor
I (276) temperature_sensor: temperature range [-10°C ~ 80°C], error < 1°C
I (286) example: Temperature sensor started
I (1286) example: Temperature out celsius 21.64
I (2286) example: Temperature out celsius 21.64
I (3286) example: Temperature out celsius 21.64
I (4286) example: Temperature out celsius 22.08
I (5286) example: Temperature out celsius 22.08
I (6286) example: Temperature out celsius 22.08
I (7286) example: Temperature out celsius 22.08
I (8286) example: Temperature out celsius 22.08
I (9286) example: Temperature out celsius 22.08

Troubleshooting

For any technical queries, please open an issue on GitHub. We will get back to you soon.