Labels

Wednesday, 23 September 2026

ESP-IDF

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.




What is an ESP32?

ESP32 is a 32-bit processor from Espressif Systems with wifi and bluetooth connectivity.  It is a successor to ESP8266 (32-bit cpu and wifi) which became extremely popular with the make community because of its low price and wifi connectivity.  The Arduino IDE incorporated support for ESP8266 and ESP32 which gave hobbyists a simplified approach to build applications for the system.

The first ESP32 was first released in Sepember 2016 so the reange is now ten years old.  There are now two principal designs "S" and "C" based on Xtensa and RISC-V architecture respectively.


ESP32-S3 is based on dual core Xtensa LX7 processors.  Xtensa is marketed by Cadence Systems in San Jose, California.  These processors  can be customised to provide a specific set of functions which the manufacturer requires.  It looks like you can use an IDE to design your processor and it is manufactured based on the results.

ESP32-S3 is a SoC (System on a chip) with 240MHz dul Xtena LX7 CPU, 512KB SRAM (Static RAM), 384KB ROM, 16KB RTC RAM (Very Fast RAM), 8MB PSRAM (Pseudo-static slow RAM), 45 GPIO pins, 3 x UART.  Internal ROM is used internally for wifi drivers, RTOS etc.
The SoC is often combined with extra components in a module board such as ESP-WROOM-32. Mine is an ESP32-S3-N16R8 which has 16MB flash ROM as well as 8MB PSRAM.  The module is a square silver SMD component with an antenna.
The module is mounted on a development board with USB-C ports, 40 pins, boot/reset buttons and an RGB LED.  Mine doesn't have a name but there are some well-known ones: ESP32-DevKitC (Espressif), LolinD32 (Wemos), NodeMCU-32S (Ai-Thinker).

I found some interesting articles which provide more illumination on circuitschools and JLCPCB

I have previously blogged about the ESP32-C3 RISC-V processor. This is important as Espressif have announced they aim to focus on RISC-V in the future which implies that their RISC-V  cores will eventually be as powerful as Xtensa cores.



ESP32 uses the RTOS Real-Time Operating System internally to control hardware.  Programmers can use RTOS functions for time-sensitive operations.  Programming is carried out using ESP-IDF, Arduino or PlatformIO IDEs. Programming can be carried out in C, C++ or micropython.




Monday, 7 September 2026

ESP32C3

Intro

ESP32 processors first became available in September 2016 and I first used them in 2019.  The last ones I purchased in 2023 for my LilyGo T-Display buttons which have been well used since then.

ESP-C3-01M-Kit


My interest was re-kindled when I noticed that the ESP32-C3 range runs on Risc-V.  I  purchased a couple of NodeMCU-Series ESP-C3-01m-Kit but they didn't appear to be totally compatible with the Arduino environment and I didn't progress far with them.  I did subsequently try configuring with ESP-IDF which worked better.




ESP32-C3 Super-Mini

Instead I bought some ESP32 C3 Super mini development boards which seem a lot more compatible with Arduino.


Shellminator


I saw a Hackaday article talking about shell/terminal programs which can be quickly implemented.

After a quick Google I decided to try Shellminator on my ESP32-C3.  Breezybox looks even better but requires a more powerful ESP32-S3 system.


I installed the Shellminator library in Arduino IDE and copied the first example program.

The program works fine and gives me a simple shell.  You can then code applications which make use of the shell.  This is a brilliant start for me and encouraged me to purchase an ESP32-S3 for Breezybox.


Assembly Language

It is good to see that a ESP32 Risc-V processor can be used just like an ARM processor.  At present they are somewhat less powerful, but I am pleased and applaud their progress.  Of course I really ought to try out the assembly language.  It is possible to use inline assembly in the Arduino IDE and it appears possible to include separate assembly modules.  However it looks to be rather unreliable/undocumented/error-prone.

The correct answer is to use the official ESP IDE.  ESP-IDF (Espressif IoT Development Framework) is easy to install.  I use it with Windows.  An icon is provided to invoke the command line environment in a Windows shell.  You use python "idf.py" commands to build, flash and monitor programs on an ESP32.   I will talk about ESP-IDF more in another post.


Luckily for me I found an excellent simple tutorial by Prof Smith at York (US) University.
ESP-IDF uses a package called CMake to create a set of build files for you program, taking into account ESP32 variant, compiler, platform you are using.  To use it you set up a structure of files.  You describe what you are building in the two CMakeLists.txt files.

In this simple example we have a C program defines some variables and prints a result.
Variables are passed in RISC-V registers a0 and a1 into the assembler routine, sub3.s.  The code stores the subtraction result in a0 and returns to C.  In C, a0 is the result "r" which can then be printed out.

Although this is a trivial example it gives us the mechanism to write assembler.  Of course, any usage of the processors GPIO pins or other capabilities requires an understanding of hardware, libraries, structures etc.
It is usual to only write the parts that you want/need to in assembler so the tricky parts can be done in C at first.

Outro

It is good to have an easy entry to RISC-V assembler programming using ESP-IDF.