Skip to main content

ESP-IDF Basics - Assign. 1.1

·3 mins·
Table of Contents

Step 0: Install ESP-IDF Extension for VSCode
#

In this workshop, we’ll be using VSCode extension. If you didn’t install it yet, please follow these instructions.

To install ESP-IDF itself, there are two ways:

  1. Through the extension configuration
  2. Using the ESP-IDF installation manager

The second will soon become the standard way to manage ESP-IDF.

Step 1: Create and test a project from an example
#

In this section, we will:

  1. Create a new project from an example
  2. Build the project
  3. Flash and monitor

Please note that most commands in VSCode are executed through the Command Palette, which you can open by pressing Ctrl+Shift+P (or Cmd+Shift+P)

In this guide, commands to enter in the Command Palette are marked with the symbol >. Usually it is sufficient to type a few character of the command, then a dropdown menu will help you find the right one.

Create a new project from an example
#

  1. Open VSCode
  2. > ESP-IDF: Show Example Project
  3. (If asked) Choose the ESP-IDF version
  4. Click on get_startedhello_world
  5. Click on the button Select Location for Creating hello_world Example in the new tab.
Fig.1 - Create new project tab

Fig.1 - Create new project tab

A new window will open with the following file structure:

Fig.2 - hello_world example files

Fig.2 - hello_world example files

For now, you can ignore .vscode, .devcontainer, and build folder. You will work on the hello_world_main.c file.

Build the project
#

To compile (build) your project, you first need to tell the compiler which core (called target) you are using. You can do it through the IDE as follows:

  • > ESP-IDF: Set Espressif Device Target
  • In the dropdown menu, choose esp32c3ESP32-C3 chip (via builtin USB-JTAG)

Now you’re ready to compile your project:

  • > ESP-IDF: Build Your Project You can also click on the small 🔧 icon located in the bottom bar

A terminal tab will open at the bottom of your IDE and show the successful compilation and size of the compiled binary.

Fig.3 - Compilation result

Fig.3 - Compilation result

If you have problems that are hard to debug, it is useful to do a full clean of your project by using the command > ESP-IDF: Full clean project.

Flash and monitor
#

To see the firmware running, you need to store it on the device (flash) and then you need to read the output it emits on the serial port (monitor).

  • Connect the board to your workstation
  • Check that the device is recognized
  • Note the name assigned to the Espressif device
    • On Windows, it starts with COM
    • On Linux/macOS, it starts with tty or ttyUSB

If you’re having trouble, check the Establish Serial Connection with ESP32 Guide.

Now you can flash and monitor your device.

  • > ESP-IDF: Build, Flash and Start a Monitor on Your Device

In the terminal, you should now see the Hello World! string and the countdown before the reset.

Step 2: Change the output text
#

Identify the output string and change it to Hello LED.

Conclusion
#

You can now create a new project and flash it on the board. In the next assignment, we’ll consolidate this process.

Next step
#

Next assignment → Assignment 1.2

Related

ESP-IDF Basics - Assign. 1.2
1 min
ESP-IDF Basics - Assign. 2.1
7 mins
ESP-IDF Basics - Assign. 2.3 (Optional)
1 min