Getting Started with ESP32 ESP-IDF (part 3)

In Part 2 of Getting Started with ESP32 ESP-IDF, we prepared the ESP32 toolchain and set up our Development Environment for ESP32 within Ubuntu 14.04.

In this article, we download and configure the ESP32 ESP-IDF from Espressif GitHub page. We then compile a sample blinking LED project and generate the appropriate BIN files for ESP32.

Download ESP32 ESP-IDF from GitHub

We will directly clone the Espressif ESP32 ESP-IDF from Espressif GitHub to our ESP32 development environment.

In this article, we will simply create a folder called iotbits_esp32 on the desktop, where we will clone the contents of ESP-IDF. You could place this wherever you find convenient. However, stick with our steps if you are not very familiar with Linux.

Here are the steps that are to be followed, in a new command window:

  • Create a folder called iotbits_esp32 on the Desktop manually or by using command terminal:
    mkdir ~/Desktop/iotbits_esp32
  • Change to iotbits_esp32 as the current directory:
    cd ~/Desktop/iotbits_esp32
  • Clone the ESP-IDF GitHub repository to this directory. This step is VERY IMPORTANT and must be done with this command only:
    git clone --recursive https://github.com/espressif/esp-idf.git
  • Next, define IDF_PATH environment variable based on the location of esp_idf folder cloned from GitHub. Note that this step must be performed in EVERY terminal session. If you want this to be permanent, please make sure the IDF_PATH is set in bashrc as we did for the toolchain.
    Add IDF path for current session as follows:
    export IDF_PATH=~/Desktop/iotbits_esp32/esp-idf
  • Your copy of ESP32 ESP-IDF is now configured for working properly!

Compile blinking LED example

In this section, we will follow the steps necessary to compile the blinking LED example provided in the ESP-IDF.

To compile the blinking LED example project, proceed as follows:

  • Make sure that the parameter IDF_PATH is defined (as instructed in the section above). You may check if IDF_PATH is defined correctly by using command:
    echo $IDF_PATH
  • Switch to the example project directory in iotbits_esp32 folder (02_blink in this case):
    cd $IDF_PATH/examples/02_blink
  • Now run the following command to bring up the configuration menu, which lets you set parameters such as flash related parameters and other important values that define your ESP32 hardware:
    make menuconfig
    You should see a configuration window like this:
    menuconfig-in-esp32-esp-idf-esp32-blinking-led-project
    You may leave out all the parameters at their respective defaults. However, if you do change anything, make sure that in option Serial flasher config, spi mode is DIO and spi flash speed is 40MHz. This is necessary for the current ESP-IDF version to work stably across most configurations!
  • In menu Example Configuration, the GPIO to blink LED on is set as GPIO5 (default).
  • Hit to save the configuration in the default location as follows:
    esp32-blinking-led-example-idf-menuconfig-options
  • Now that the configuration is done, it is time to actually generate the BIN files from the source code!
    To build the sources of ESP32 LED blinking program, use command:
    make
  • You should see an output like this, with no errors, which indicates that the solution was successfully built and the BIN files were generated in the output folder.
    esp32-blinking-led-example-bin-generated-compile-success

Congratulations! You just generated the BIN files which need to be downloaded to ESP32 flash memory for the blinking LED code to work!

Download program to ESP32!

The BIN files needed to make your program run were created above. To run the program on the ESP32 development board, here is how you can proceed:

Downloading program to ESP32 using Flash Download Tool

If you have something to talk about, feel free to leave your comments below! Also, scroll to the bottom of the page and SUBSCRIBE to stay updated with more awesome articles!

Ad:

3 thoughts on “Getting Started with ESP32 ESP-IDF (part 3)

  1. Pingback: New ESP32 Development Board - what is new this time?

  2. Pingback: ESP32 Demo Board from Espressif Systems - first impressions!

  3. Pingback: Nano32 - New ESP32 Development Board to be launched

Leave a Reply