Skip to content

Commit 7c97f31

Browse files
committed
Instructions for Espressif-IDF and PlatformIO updated
1 parent a8ccf4e commit 7c97f31

File tree

117 files changed

+2472
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2472
-102
lines changed

README.md

+101-39
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,119 @@
11
# ESP-IDF examples
22

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
44

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++.*
66

7-
* [How to integrate ESP-IDF with VS Code for Windows](https://esp32tutorials.com/install-esp32-esp-idf-windows-integrate-vs-code/)
7+
![logo-espressif-idf](images/logo_espressif-idf.png)
88

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.
1010

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)
1212

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).
1432
15-
### Useful commands in VS Code
33+
## Installation with PlatformIO
1634

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/).*
2836

29-
## Use with PlatformIO
37+
![logo-platformio](images/logo_platformio.png)
3038

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.
3240

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.
3445

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+
![Install PlatformIO IDE](images/platformio_install.png)
4347

44-
**TODO:**
48+
4. After that, restart the Visual Studio Code application.
4549

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+
![Create a new project](images/platformio_new_project.png)
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+
![Create a new project](images/platformio_project_name.png)
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+
![Control icons](images/platformio_footer2.png)
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+
```
55117

56118
## Useful information
57119

docs/README-platformio.md

-63
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM espressif/idf
2+
3+
ARG DEBIAN_FRONTEND=nointeractive
4+
ARG CONTAINER_USER=esp
5+
ARG USER_UID=1000
6+
ARG USER_GID=$USER_UID
7+
8+
RUN apt-get update \
9+
&& apt install -y -q \
10+
cmake \
11+
git \
12+
hwdata \
13+
libglib2.0-0 \
14+
libnuma1 \
15+
libpixman-1-0 \
16+
linux-tools-virtual \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
RUN update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20
20+
21+
# QEMU
22+
ENV QEMU_REL=esp-develop-20220919
23+
ENV QEMU_SHA256=f6565d3f0d1e463a63a7f81aec94cce62df662bd42fc7606de4b4418ed55f870
24+
ENV QEMU_DIST=qemu-${QEMU_REL}.tar.bz2
25+
ENV QEMU_URL=https://github.com/espressif/qemu/releases/download/${QEMU_REL}/${QEMU_DIST}
26+
27+
ENV LC_ALL=C.UTF-8
28+
ENV LANG=C.UTF-8
29+
30+
RUN wget --no-verbose ${QEMU_URL} \
31+
&& echo "${QEMU_SHA256} *${QEMU_DIST}" | sha256sum --check --strict - \
32+
&& tar -xf $QEMU_DIST -C /opt \
33+
&& rm ${QEMU_DIST}
34+
35+
ENV PATH=/opt/qemu/bin:${PATH}
36+
37+
RUN groupadd --gid $USER_GID $CONTAINER_USER \
38+
&& adduser --uid $USER_UID --gid $USER_GID --disabled-password --gecos "" ${CONTAINER_USER} \
39+
&& usermod -a -G dialout $CONTAINER_USER
40+
USER ${CONTAINER_USER}
41+
ENV USER=${CONTAINER_USER}
42+
WORKDIR /home/${CONTAINER_USER}
43+
44+
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
45+
46+
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
47+
48+
CMD ["/bin/bash", "-c"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/ubuntu
3+
{
4+
"name": "ESP-IDF QEMU",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
// Add the IDs of extensions you want installed when the container is created
9+
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
10+
/* the path of workspace folder to be opened after container is running
11+
*/
12+
"workspaceFolder": "${localWorkspaceFolder}",
13+
"mounts": [
14+
"source=extensionCache,target=/root/.vscode-server/extensions,type=volume"
15+
],
16+
"customizations": {
17+
"vscode": {
18+
"settings": {
19+
"terminal.integrated.defaultProfile.linux": "bash",
20+
"idf.espIdfPath": "/opt/esp/idf",
21+
"idf.customExtraPaths": "",
22+
"idf.pythonBinPath": "/opt/esp/python_env/idf5.1_py3.8_env/bin/python",
23+
"idf.toolsPath": "/opt/esp",
24+
"idf.gitPath": "/usr/bin/git"
25+
},
26+
"extensions": [
27+
"ms-vscode.cpptools",
28+
"espressif.esp-idf-extension"
29+
],
30+
},
31+
"codespaces": {
32+
"settings": {
33+
"terminal.integrated.defaultProfile.linux": "bash",
34+
"idf.espIdfPath": "/opt/esp/idf",
35+
"idf.customExtraPaths": "",
36+
"idf.pythonBinPath": "/opt/esp/python_env/idf5.1_py3.8_env/bin/python",
37+
"idf.toolsPath": "/opt/esp",
38+
"idf.gitPath": "/usr/bin/git"
39+
},
40+
"extensions": [
41+
"ms-vscode.cpptools",
42+
"espressif.esp-idf-extension"
43+
],
44+
}
45+
},
46+
"runArgs": ["--privileged"]
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "ESP-IDF",
5+
"compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc",
6+
"includePath": [
7+
"${config:idf.espIdfPath}/components/**",
8+
"${config:idf.espIdfPathWin}/components/**",
9+
"${config:idf.espAdfPath}/components/**",
10+
"${config:idf.espAdfPathWin}/components/**",
11+
"${workspaceFolder}/**"
12+
],
13+
"browse": {
14+
"path": [
15+
"${config:idf.espIdfPath}/components",
16+
"${config:idf.espIdfPathWin}/components",
17+
"${config:idf.espAdfPath}/components/**",
18+
"${config:idf.espAdfPathWin}/components/**",
19+
"${workspaceFolder}"
20+
],
21+
"limitSymbolsToIncludedHeaders": false
22+
}
23+
}
24+
],
25+
"version": 4
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "espidf",
6+
"name": "Launch",
7+
"request": "launch"
8+
}
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"C_Cpp.intelliSenseEngine": "default",
3+
"idf.adapterTargetName": "esp32",
4+
"idf.openOcdConfigs": [
5+
"board/esp32-wrover-kit-3.3v.cfg"
6+
],
7+
"idf.port": "/dev/ttyACM0",
8+
"idf.flashType": "UART"
9+
}

0 commit comments

Comments
 (0)