2022-07-12 22:41:36 -04:00
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
2022-06-14 02:50:35 -04:00
| ----------------- | -------- | -------- | -------- | -------- |
2020-06-28 04:40:49 -04:00
2021-02-05 12:49:28 -05:00
# Temperature Sensor Example
2019-06-20 04:13:47 -04:00
2022-06-14 02:50:35 -04:00
The ESP32-S2/C3/S3/C2 has a built-in temperature sensor. The temperature sensor module contains an 8-bit Sigma-Delta ADC and a temperature offset DAC.
2019-06-20 04:13:47 -04:00
2022-04-24 06:14:17 -04:00
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.
2019-06-20 04:13:47 -04:00
2020-01-09 02:39:12 -05:00
| 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 |
2019-06-20 04:13:47 -04:00
2021-02-05 12:49:28 -05:00
## 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
2022-06-14 02:50:35 -04:00
* A development board with ESP32-S2/C3/S3/C2 SoC (e.g., ESP32-S2-Saola-1, ESP32-S2-DevKitM-1, ESP32-C3-DevKitM-1, ESP32-S3-WROOM-1, etc.)
2021-02-05 12:49:28 -05:00
* 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 ](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html ) for full steps to configure and use ESP-IDF to build projects.
## Example Output
2019-06-20 04:13:47 -04:00
```
2022-04-24 06:14:17 -04:00
I (0) cpu_start: Starting scheduler on APP CPU.
I (303) example: Install temperature sensor, expected temp ranger range: 10~50 ℃
I (303) temperature_sensor: Range [-10°C ~ 80°C], error < 1 ° C
I (313) example: Enable temperature sensor
I (323) example: Read temperature
I (323) example: Temperature value 26.06 ℃
I (1323) example: Temperature value 26.06 ℃
I (2323) example: Temperature value 26.06 ℃
I (3323) example: Temperature value 26.06 ℃
I (4323) example: Temperature value 26.06 ℃
I (5323) example: Temperature value 26.49 ℃
2022-03-04 05:04:20 -05:00
2021-02-05 12:49:28 -05:00
```
## Troubleshooting
For any technical queries, please open an [issue ](https://github.com/espressif/esp-idf/issues ) on GitHub. We will get back to you soon.