mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
da471dfcd1
Updated main examples README to add missing examples folders and Getting Started links Updated wifi/fastscan example README Updated wifi examples README Updated wifi main examples README Added instructions and removed obviousness from examples README Updates on example README in peripherals, system and wifi Updates on example README in peripherals and added wave form pictures on wave_gen example Updates and review on example README Revision on unit style convention Added the getting started link for each supported version Readme review and recommended enhancements Added the default note on the wave form option info Added the ESP32-C3 support information on the temperature sensor example README Added Getting Started information for ESP32-S2 and ESP32-C3 Issue fixed on the supported target on README Resolved merge conflict |
||
---|---|---|
.. | ||
main | ||
CMakeLists.txt | ||
example_test.py | ||
Makefile | ||
README.md |
Example: GPIO
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This test code shows how to configure GPIO and how to use it with interruption.
GPIO functions:
GPIO | Direction | Configuration |
---|---|---|
GPIO18 | output | |
GPIO19 | output | |
GPIO4 | input | pulled up, interrupt from rising edge and falling edge |
GPIO5 | input | pulled up, interrupt from rising edge |
Test:
- Connect GPIO18 with GPIO4
- Connect GPIO19 with GPIO5
- Generate pulses on GPIO18/19, that triggers interrupt on GPIO4/5
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/ESP32-S2/ESP32-C3 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
- A USB cable for Power supply and programming
- Some jumper wires to connect GPIOs.
Configure the project
Build and Flash
Build the project and flash it to the board, then run the monitor tool to view the 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 all the steps to configure and use the ESP-IDF to build projects.
- ESP-IDF Getting Started Guide on ESP32
- ESP-IDF Getting Started Guide on ESP32-S2
- ESP-IDF Getting Started Guide on ESP32-C3
Example Output
As you run the example, you will see the following log:
I (317) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (327) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (337) gpio: GPIO[4]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1
I (347) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1
Minimum free heap size: 289892 bytes
cnt: 0
cnt: 1
cnt: 2
cnt: 3
cnt: 4
cnt: 5
cnt: 6
cnt: 7
cnt: 8
cnt: 9
cnt: 10
...
Troubleshooting
For any technical queries, please open an issue on GitHub. We will get back to you soon.