After having introduced, in the previous post, the ESP32 chip and the official development board by Espressif, today I’m going to show you how to install and use the official development environment.
The official development framework for the ESP32 chip is published by Expressif on Github, with an opensource license (Apache 2.0) and named Espressif IoT Development Framework (shortly idf).
To be able to use it under Windows, you need some GNU commands and toolchains (make, bash…). Espressif chose to offer a pre-configured version of MSYS2 that includes everything is required.
Download the ZIP archive from the Espressif website and unzip it in the root of your C drive; MSYS2 will be installed in the C:\msys32 subfolder:
Double-click on minigw32.exe to run a bash shell:
We can now clone the idf Github repository to have a local copy of it. First we must choose a folder where it will be copied; to keep it simple let’s use the user’s home folder.
Move into that folder and run the clone command:
$ cd $ git clone --recursive https://github.com/espressif/esp-idf.git
After the process is completed, the development framework is available in the esp32-idf subfolder:
To use if when compiling your projects, you have to export the path as an environment variable (IDF-PATH):
$ export IDF_PATH=~/esp-idf
Let’s connect the board!
You’re now ready to connect the development board to your computer.
If you already have the correct drivers, once connected it will appear as a new serial port:
On the contrary, the needed drivers are available on the Silicon Labs official website.
As usual when learning a new language or framework, let’s start with a simple program that displays (using the serial-usb connection) the sentence Hello world.
The framework is distributed with some examples, among them you can find the 01_hello_world program. To compile it, move to its folder and run the make command:
$ cd $ cd esp-idf/examples/01_hello_world/ $ make
A configuration menu will be displayed: we’ll talk more about it in a next post. Now you only need to tell the flasher which is the serial port your board is connected to.
Choose Serial flasher config, then /dev/ttyUSB0 (the default port):
Type the name of your serial port (as identified above), then confirm with Ok, Save and Exit:
When the compile process is complete, you can upload the program on the board with the following command:
If you now use a terminal emulator to connect to the serial port with the correct speed (115200 baud) you should see the program output:
(the program prints the sentence “Hello world!”, counts 10 seconds and then restart the chip…)