Intro
ESP-IDF (IoT Development Framework) is the official IDE from Espressif Systems for their microprocessors including ESP32. As such it can be used to build and download images to ESP32 like the Arduino environment. Whereas Arduino (successfully) endevours to make programming as simple and painless as possible ESP-IDF enables the user to utilise all ESP32 functions. Even simple IDF programs can be challenging to develop but it is extremely useful in situations where Arduino IDE doesn't work properly for a particular application. Arduino uses a SETUP + LOOP configuration, whereas IDF uses function interrupts / callbacks to deal with inputs and other events.
Environment
I installed ESP-IDF v6.0.1 for Windows PC. Installation is very straightforward and it takes a few minutes to download and configure all the code. Clicking the resulting icon gives you a Powershell command line session. You then use a python script idf.py to confirm which chip is being used (set-target) compile (build), download (flash) and open an ESP32 serial terminal (monitor). The build process has many (automated) steps and creates a bootloader, executable image and any other required code.
Comprehensive documentation is provided by ESP and there is an excellent set of examples covering most (all?) available functionality.
Examples are vital as there is a very steep learning curve when learning how to control a range of hardware functions. Most functions (e.g. GPIO, I2C, wifi, web servers) can be implemented by taking one or more example programs and adapting them as required.
RNT Book
There is a bit more to IDF than I can learn by browsing the programming examples and I struggled with IDF attempting to make BreezyBox work on ESP32S3.On 25th August, whilst on holiday I received a circular from Rui Santos announcing a new book "Learn ESP-IDF with ESP32". Random Nerd Tutorials was setup a few years ago by Rui and his partner Sara. They have published many, many high quality Arduino ESP8266/ESP32 and RPi tutorials from which I have benefited greatly.
They obtain an income from ebook publications and ,although I have been keen to purchase, none has been quite appropriate before. This one seemed perfect and I jumped in to purchase it on the publication day.
Chapter 1 covers ESP-IDF installation in a Visual Studio (VSC) context and a few basic concepts. Chapter 2 covers GPIOs; digital outputs, digital inputs, analond inputs and button debouncing using interrupts. Although the descriptiona are light and superficial you end up with the ability to program many GPIO functions by adapting sample programs.
After Chapter 2 you have the flexibility to cover topics of specific interest: deep sleep, I2C, Wifi, BLE or ESP-NOW. Using wifi and web servers is my first interest, but I will also cover ESP-NOW which provides networking for ESP32 devices.
USAGE
Once you get used to it, ESP-IDF doesn't seem too difficult. Examples provided by Espressif look complicated because they are properly written, testing for errors for each hardware operation which makes them rather long. In comparison Arduino uses standard functions for many different board types so their functions are well known. For simple applications Arduino is certainly easier and quicker.
I expect to use ESP-IDF in a number of situations:
- Assembly language programming
- Whereever a software packages uses dependencies or specifies ESP-IDF install instructions
- If I need to use Callback functions.