2018-06-29 04:39:03 -04:00
# ADC2 Example
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
(See the README.md file in the upper level 'examples' directory for more information about examples.)
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
In this example, we use ADC2 to measure the output of DAC.
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
## How to use example
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
### Hardware Required
2017-09-13 06:33:05 -04:00
2019-07-19 09:20:16 -04:00
#### ESP32 platform
2018-06-29 04:39:03 -04:00
* A development board with ESP32 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
* A USB cable for power supply and programming
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
We use ADC1_CHANNEL_7 (GPIO27) and DAC_CHANNEL_1 (GPIO25) by default, you need to short the two GPIOs (if you have changed the ADC2 and DAC channel, please refer to Chapter 4.11 of the `ESP32 Technical Reference Manual` to get the pin number).
2017-09-13 06:33:05 -04:00
2019-07-19 09:20:16 -04:00
#### ESP32-S2 platform
* A development board with ESP32S2BETA SoC
* A USB cable for power supply and programming
We use ADC1_CHANNEL_7 (GPIO18) and DAC_CHANNEL_1 (GPIO17) by default, you need to short the two GPIOs (if you have changed the ADC2 and DAC channel, please refer to the `ESP32S2 Technical Reference Manual` to get the pin number).
2018-06-29 04:39:03 -04:00
### Configure the project
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
```
2019-08-01 23:31:20 -04:00
idf.py menuconfig
2018-06-29 04:39:03 -04:00
```
* Set ADC2 and DAC channel in "Example Configuration"
2017-09-13 06:33:05 -04:00
2018-06-29 04:39:03 -04:00
### Build and Flash
Build the project and flash it to the board, then run monitor tool to view serial output:
```
2019-08-01 23:31:20 -04:00
idf.py -p PORT flash monitor
2018-06-29 04:39:03 -04:00
```
(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
Running this example, you will see the following log output on the serial monitor:
2019-07-19 09:20:16 -04:00
### ESP32 platform
2018-06-29 04:39:03 -04:00
```
ADC channel 7 @ GPIO 27, DAC channel 1 @ GPIO 25.
adc2_init...
start conversion.
1: 150
2: 203
3: 250
4: 300
5: 351
6: 400
7: 441
8: 491
9: 547
10: 595
...
```
2019-07-19 09:20:16 -04:00
#### ESP32-S2 platform
```
ADC channel 7 @ GPIO 18, DAC channel 1 @ GPIO 17.
adc2_init...
start conversion.
1: 150
2: 203
3: 250
4: 300
5: 351
6: 400
7: 441
8: 491
9: 547
10: 595
...
```
2018-06-29 04:39:03 -04:00
## Troubleshooting
* program upload failure
2019-08-01 23:31:20 -04:00
* Hardware connection is not correct: run `idf.py -p PORT monitor` , and reboot your board to see if there are any output logs.
2018-06-29 04:39:03 -04:00
* The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again.
For any technical queries, please open an [issue ](https://github.com/espressif/esp-idf/issues ) on GitHub. We will get back to you soon.