|
1 | 1 | # ESP-IDF examples
|
2 | 2 |
|
3 |
| -ESP-IDF is Espressif's official [IoT Development Framework](https://www.espressif.com/en/products/sdks/esp-idf) for the ESP32, ESP32-S, ESP32-C and ESP32-H series of SoCs. It provides a self-sufficient Software Development Kit (SDK) for any generic application development on these platforms, using programming languages such as C and C++. |
| 3 | +## Installation ESP-IDF with VS Code |
4 | 4 |
|
5 |
| -## Use with VS Code |
| 5 | +*ESP-IDF is Espressif's official [IoT Development Framework](https://www.espressif.com/en/products/sdks/esp-idf) for the ESP32, ESP32-S, ESP32-C and ESP32-H series of SoCs. It provides a self-sufficient Software Development Kit (SDK) for any generic application development on these platforms, using programming languages such as C and C++.* |
6 | 6 |
|
7 |
| -* [How to integrate ESP-IDF with VS Code for Windows](https://esp32tutorials.com/install-esp32-esp-idf-windows-integrate-vs-code/) |
| 7 | + |
8 | 8 |
|
9 |
| -* [Installation on Linux and Windows](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md) |
| 9 | +1. Follow these instructions: [Installation on Linux and Windows](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md) and install `Espressif IDF` extension. |
10 | 10 |
|
11 |
| -* See how to [build your first project](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#build-your-first-project) from the commannd line on Windows, Linux, or macOS. |
| 11 | +2. It is recommended to start by an example project. See how to [create, build, and run your first project](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/basic_use.md) |
12 | 12 |
|
13 |
| -* Description of all ESP-IDF development tools can be found [here](https://blog.espressif.com/esp-idf-development-tools-guide-part-i-89af441585b). |
| 13 | + > **NOTE:** Please note that all available commands are accessible in VS Code in menu **View > Command Palette...** or by `Ctrl+Shift+P` shortcut, followed by a command `ESP-IDF: ` |
| 14 | + > |
| 15 | + > Command | Description |
| 16 | + > :-- | :-- |
| 17 | + > `F1` or `Ctrl+Shift+P` | Command Palette where all commands are found |
| 18 | + > `ESP-IDF: Show Examples Projects` | List of available projects |
| 19 | + > `ESP-IDF: New project` | Create a new project via Command Palette |
| 20 | + > `ESP-IDF: Set Espressif device target` | Select your Espressif target (esp32, esp32s2, etc.) |
| 21 | + > `ESP-IDF: Build your project` | Build the project |
| 22 | + > `ESP-IDF: Build, Flash, and start a monitor on your device` | Combine build, flash and serial monitor in a single command |
| 23 | + > | |
| 24 | + > `ESP-IDF: Open ESP-IDF Terminal` | Open ESP-IDF Terminal where you can use `idf.py` command-line tool |
| 25 | + > `idf.py create-project NAME` | Create a new project titled `NAME` in ESP-IDF Terminal |
| 26 | + > `idf.py menuconfig` | Open project configuration |
| 27 | + > `idf.py build` | Build the project |
| 28 | + > `idf.py flash monitor` | Flashing esp-idf project and open serial monitor |
| 29 | + > `Ctrl+]` or `Ctrl+)` | Exit the monitor |
| 30 | + > |
| 31 | + > Other common [shortcuts in VS Code](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf). |
14 | 32 |
|
15 |
| -### Useful commands in VS Code |
| 33 | +## Installation with PlatformIO |
16 | 34 |
|
17 |
| -Command | Description |
18 |
| -:-- | :-- |
19 |
| -`F1` | Command Palette where all commands are found |
20 |
| -`F1` `ESP-IDF: New project` | Create a new project via Command Palette |
21 |
| -`F1` `ESP-IDF: Open ESP-IDF Terminal` | Open ESP-IDF Terminal where you can use `idf.py` command-line tool |
22 |
| -`Ctrl+E T` | Another way how to open ESP-IDF Terminal |
23 |
| -`idf.py create-project NAME` | Create a new project titled `NAME` |
24 |
| -`idf.py menuconfig` | Open project configuration |
25 |
| -`idf.py build` | Build the project |
26 |
| -`idf.py flash monitor` | Flashing esp-idf project and open serial monitor |
27 |
| -`Ctrl+]`, `Ctrl+)` | Exit the monitor |
| 35 | +*[PlatformIO](https://platformio.org/) is a cross-platform build system that can be used to develop software platforms for Arduino, ESP32, PIC32, and AVR. PlatformIO can be used with VS Code to provide a powerful set of tools [to assist you in development](https://dronebotworkshop.com/platformio/).* |
28 | 36 |
|
29 |
| -## Use with PlatformIO |
| 37 | + |
30 | 38 |
|
31 |
| -* [How to install and use ESP32 ESP-IDF in PlatformIO](docs/README-platformio.md) |
| 39 | +1. Download and install [Visual Studio Code](https://code.visualstudio.com/) source code editor. |
32 | 40 |
|
33 |
| -### PlatformIO examples |
| 41 | +2. Run Visual Studio Code application: |
| 42 | + 1. Open up the extensions viewer in menu **View > Extensions Ctrl+Shift+X**. |
| 43 | + 2. Type `platformio` into the search bar. |
| 44 | + 3. Press **Install** button on the result `PlatformIO IDE`. It may take a few minutes depending on your connection speed. Do not close any window and do not open other folders until the installing process is completed. |
34 | 45 |
|
35 |
| -* [Basic template with GPIO](examples/gpio) |
36 |
| -* [Logging methods](examples/log_methods) |
37 |
| -* [Tasks](examples/tasks) |
38 |
| -* [I2C scan](examples/i2c_scan) |
39 |
| -* [I2C DHT12 sensor](examples/i2c_sensor) |
40 |
| -* [Wi-Fi APs scan](examples/wifi_scan) |
41 |
| -* [Wi-Fi GET requests to HTTP](examples/wifi_get_requests) |
42 |
| -* [Wi-Fi & DHT12 & ThingSpeak](examples/wifi_thingspeak) |
| 46 | +  |
43 | 47 |
|
44 |
| -**TODO:** |
| 48 | + 4. After that, restart the Visual Studio Code application. |
45 | 49 |
|
46 |
| -* [ ] Timer(s), PWM |
47 |
| -* [ ] SPI |
48 |
| -* [ ] Bluetooth |
49 |
| -* [ ] Wi-Fi GET requests to HTTPs |
50 |
| -* [ ] Wi-Fi & AWS |
51 |
| -* [ ] ADC, DAC |
52 |
| -* [ ] CAN |
53 |
| -* [ ] IR |
54 |
| -* [ ] SHA |
| 50 | +3. Create a new project: |
| 51 | + 1. Click on the PlatformIO icon in the left-hand margin. |
| 52 | + 2. In menu **PIO Home** select **Open**. |
| 53 | + 3. Click to **New Project** button. |
| 54 | + |
| 55 | +  |
| 56 | + |
| 57 | + 4. In project wizard, type `gpio` as project name. |
| 58 | + 5. Select ESP32 board you have. |
| 59 | + 6. Change framework to `Espressif IoT Development Framework` and select location to your working folder. |
| 60 | + 7. Click on the **Finish** button. The creation of first project may takes a few minutes and internet connection to download the needed libraries and frameworks is mandatory. |
| 61 | + |
| 62 | +  |
| 63 | + |
| 64 | +4. Code the application: |
| 65 | + 1. Copy/paste the [basic template](https://raw.githubusercontent.com/tomas-fryza/esp-idf/main/examples-platformio/gpio/src/main.c) to your `GPIO > src > main.c` file. |
| 66 | + 2. Add the following settings to `platformio.ini` project configuration file. |
| 67 | + |
| 68 | + ```bash |
| 69 | + monitor_speed = 115200 |
| 70 | + |
| 71 | + # DTR & RTS settings of the serial monitor must be OFF |
| 72 | + monitor_rts = 0 |
| 73 | + monitor_dtr = 0 |
| 74 | + |
| 75 | + # Enable ANSI color codes in serial monitor |
| 76 | + monitor_raw = yes |
| 77 | + ``` |
| 78 | + |
| 79 | + 3. Connect your ESP32 board to USB port. |
| 80 | + |
| 81 | + 4. Compile and upload the code. The handy shortcuts for building and uploading the code is available on the blue footer taskbar. Hover over the icon to get its functionality. First, compile (build) the project and then upload it to ESP32 board. Open the Serial monitor. (At some platforms you have to press on-board reset button.) |
| 82 | + |
| 83 | +  |
| 84 | + |
| 85 | +## Examples |
| 86 | + |
| 87 | +### Espressif |
| 88 | + |
| 89 | +* [Hello world](examples-espressif/hello) |
| 90 | + |
| 91 | +### PlatformIO |
| 92 | + |
| 93 | +* [Basic template with GPIO](examples-platformio/gpio) |
| 94 | +* [Logging methods](examples-platformio/log_methods) |
| 95 | +* [Tasks](examples-platformio/tasks) |
| 96 | +* [I2C scan](examples-platformio/i2c_scan) |
| 97 | +* [I2C DHT12 sensor](examples-platformio/i2c_sensor) |
| 98 | +* [Wi-Fi APs scan](examples-platformio/wifi_scan) |
| 99 | +* [Wi-Fi GET requests to HTTP](examples-platformio/wifi_get_requests) |
| 100 | +* [Wi-Fi & DHT12 & ThingSpeak](examples-platformio/wifi_thingspeak) |
| 101 | + |
| 102 | +### Tested on |
| 103 | + |
| 104 | +| **Version** | **Result (yyyy-mm-dd)** | **Note** | |
| 105 | +| :------------------------- | :---------------------: | :---------- | |
| 106 | +| Linux Mint 21.2 (Victoria) | OK (2024-01-06) | Laptop | |
| 107 | +| Windows 10 | OK (2022-11-18) | HomeOffice | |
| 108 | +| Linux Mint 20.3 (Una) | OK (2022-11-01) | Laptop | |
| 109 | + |
| 110 | +```bash |
| 111 | +# FYI: How to check OS version in Linux |
| 112 | +cat /etc/os-release |
| 113 | +
|
| 114 | +# Or by Neofetch |
| 115 | +neofetch |
| 116 | +``` |
55 | 117 |
|
56 | 118 | ## Useful information
|
57 | 119 |
|
|
0 commit comments