How To Get Started — ESP_IDF_Series Episode #00

J3
Jungletronics
9 min readJun 1, 2020

--

Note

This tutorial uses the Legacy GNU Make Build System and MSYS2 Unix compatibility environment to build projects of ESP-IDF. This is no longer required, ESP-IDF can be used from the Windows Command Prompt.

Edited [main, 2024]: ESP-IDF v5.0 no longer supports GNU make-based projects. Please follow the build system guide for migration.

For a new one build system, using CMake + Ninja, please use this post:)

Fig 1. From https://my-esp-idf.readthedocs.io/en/latest/get-started/index.html — As you can see we will need ESP-IDF framework installed on our PC, a Toolchain, a Project and finally build it and upload it with make utility prog into our WiFi LoRa 32 (v2) — Please, read more :)

Let’s get it on!

Radio operates like this: you send signals here, they receive them there.

Sending data over long distances is like magic.

Most WiFi, Bluetooth, Zigbee, and other wireless radios chipsets use 2.4GHz, which is great for high-speed transfers.

If you aren’t so concerned about streaming a video, you can use a lower license-free frequency such as 433 or 900 MHz. You can’t send data as fast but you can send data a lot farther. And here is where LoRa Radios shine up!

LoRa radios can operate at a frequency of 33 MHz, 868 MHz (Europe), 915 MHz (Australia and South/North America), and 923 MHz (Asia).

Fig 2. Lora Wireless Soil Moisture Temperature Sensor Smart agriculture — Precision Agriculture Application LoRa® Video Library and DEVELOPER PORTAL and What Can I Do With LoRa?

The LoRa radios are exciting and more powerful but also a bit more expensive($20 — $30) compared to The RFM69’s. But not so much like Zigbee ($60-$100).

LoRa packet radios can easily go 2 Km line of sight using simple wire antennas, or up to 20Km with directional antennas and settings tweaking.

This is WiFi LoRa 32 (v2):

Fig 3. WiFi LoRa 32 (v2) is a classic IoT dev-board designed & produced by Heltec Automation(TM), it’s a highly integrated product based on ESP32 + SX127x, it has Wi-Fi, BLE, LoRa functions, also Li-Po battery management system, 0.96″ OLED are also included. It’s my choice :)

This is the 900 MHz radio version, which can be used for either 868MHz or 915MHz transmission/reception — the exact radio frequency is determined when you load the software since it can be tuned around dynamically.

The quickest way to start development with ESP-IDF is by installing a prebuilt toolchain.

Here is a step-by-step procedure for Windows users:

01#Step — Download the Windows all-in-one toolchain & MSYS2 zip file from dl.espressif.com (about 710 MB — it takes five minutes @ 50MB internet):

Fig 4. After decompaction, the size of the msys32 folder is 1.3GB!

02#StepUnzip it in your C:/ driver directory and files will end up in the 👆MSYS32👆 directory;

Fig 5. Drag it to C:/ Drive

03#Step — Open an MSYS2 MINGW32 terminal window by running this app: C:\msys32\mingw32.exe

This is a bash shell.

04#Step — Inside the shell, Make a directory named esp, like this:

05#Step — Now access this folder:

06#Step —Now get SDK-IDF version 3.3.2, type:

Fig 6. Here is the whole process until here :)

This process will take ~20' and it’ll cloning important API component, like:

Fig 7. This is the final size of the msys32 folder, after the whole process. Roughly 2.70GB!

07#Step Setup Path to IDF_PATH — Create a new script file in C:/msys32/etc/profile.d/ directory. Name it export_idf_path.sh;

The toolchain programs access ESP-IDF using an environment variable. This variable should be set up on your PC, otherwise, projects will not build. To set up it permanently by defining IDF_PATH in the user profile.

The user profile scripts are contained in C:/msys32/etc/profile.d/ directory. They are executed every time you open an MSYS2 window. Let’s do that:

08#Step — Add the export command to the script file, e.g.:

At C:/msys32/etc/profile.d/ directory, type:

Then paste:

As an example, this is my path:

And finally, type:

and you are #GOODTOGO:)\o/

Here are some tips to help you out:

Fig 8. Here is a helper graph to help you out, just set this shell at C:/msys32/etc/profile.d/ directory

But there is a much, much easier method:

Simply in your Windows Explorer directory C:\mysys32\etc\profile.d copy & paste another file as a template, rename it to export_idf_path.sh and open it at Notepad++ app, edit it, and paste this:

And save it:

Fig 9. Here is the shell file just created in this step. (please, change to your profile username:)

And You are #GOODTOGOTOO:)\o/

09#Step — Now to test the environment, close the MSYS2 MINGW32 terminal shell, and open it again (I reinitiate my machine, just in case;)

Now type:

Fig 10. The path previously entered in the script file should be printed out.

10# Step Install the Required Python Packages;

Python packages required by ESP-IDF are located in the $IDF_PATH/requirements.txt file. You can install them in this Linux env by running:

Fig 11. all python 3.8 libs are already satisfied, I already installed Python 3 previously in my machine \o/

If your system complains about updating pip, type:/

Then, run again:

Start a Project

Now you are ready to prepare your application for ESP32. To start off quickly, we will use a get-started/hello_world project from the examples directory in IDF.

Copy get-started/hello_world to ~/esp the directory:

You can also find a range of example projects under the examples directory in ESP-IDF. These example project directories can be copied in the same way as presented above, to begin your own projects.

Connect

You are almost there. To be able to proceed further, connect the ESP32 board to the PC, check under what serial port the board is visible, and verify if serial communication works. If you are not sure how to do it, check the instructions in section Establish Serial Connection with ESP32. Note the port number, as it will be required in the next step.

Configure

Being in a terminal window, go to the directory of hello_world the application by typing cd ~/esp/hello_world. Then start project configuration utility menuconfig:

If previous steps have been done correctly, the following menu will be displayed:

Fig 12. Project configuration — Home window

In the menu, navigate to Serial flasher config > Default serial port to configure the serial port (mine is COM10), where the project will be loaded to. Confirm the selection by pressing enter, save the configuration by selecting<Save> and then exit the application by selecting <Exit>.

Output

Now go to your sys_config.h file at C:\msys32\home\giljr\esp\esp-idf\examples\get-started\hello_world and modify these entries:

Save the project, now type:

Fig 13. Click on solve compatibility problem in my win 10 and Flashing the IC o/ It takes 10 minutes to end up :/

What happens here is that the HelloWorld program simply reset your device via software…nothing fancy, right?

Now If you got here, congratulations!

Your ESP-IDF IS READY FOR YOUR PROJECTS!

That’s all for now, In the next episode let’s talk about ESP-IDF and Semtech’s LoRa radio ;)

See you soon!

Bye!

Notes

Related Post

Related Post

00#Episode — ESP_IDF_Series — ESP-IDF Programming Guide + WiFi LoRa 32 (v2) — How To Get Started (this one:)

01#Episode — ESP_IDF_Series — LoRa LPWAN — Long Range Low Power Wide Area Network — LoRa was developed by Semtech, founder LoRa Alliance

02#Episode — ESP_IDF_Series — ESP-IDF Programming Guide + WiFi LoRa 32 (v2) + idf.py utility — How To Really Get Started

03#Episode — ESP_IDF_Series — ESP32-IDF — HelloWorld Get Started — How To Get Started

05 #Episode FreeRTOS — A Real Real-Time TV Transmissions — Fundamental Understanding about FreeRTOS Apps — IoT

Credits & References

Microgênios — Treinamento em Sistemas Embarcados — Microchip Regional Partner certified Training Courses a Simplício-owned enterprise

https://my-esp-idf.readthedocs.io/en/latest/get-started/index.html

Troubleshooting — Driver Bridge

If the driver is installed previously, a COM port will be allotted as soon as you plug your ESP32 kit (mine is WiFi LoRa 32 V2). Otherwise, download the silicon labs cp2102 driver from here & install it with this utility Program CH341SER.EXE on your PC. Everything will be allright o/

Fig 12 . This is the driver: Silicon Labs CP210x USB to UART Bridge \o/

If it didn’t help, please access this page: Establish Serial Connection with ESP32.

Edited @ Dez/2020 — downloads updates, text complementation, minor typos corrections:)

--

--

J3
Jungletronics

Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Ruby, Rails, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!