
Install VSCode and the PlatformIO extension to develop ESP32 Arduino programs with FreeRTOS. Import examples, compile, upload to the ESP32, and move libraries between Arduino IDE and PlatformIO.
Explore basic multithreading on ESP32 with Arduino and FreeRTOS in VSCode PlatformIO, creating two concurrent tasks that blink an LED, simulate long-term work with delays, and monitor serial output.
Examine how FreeRTOS schedules three tasks by priority, showing that a higher-priority task can block lower-priority ones and how delays allow the lower-priority tasks to run.
Use mutexes to guard a shared counter in FreeRTOS by taking before access and giving after, blocking tasks when needed and preventing data races.
Explore how spin locks and critical sections offer fast, non-blocking synchronization for short code sections on multithreaded, multicore ESP32 FreeRTOS, replacing mutexes and reducing interrupt latency.
Learn to synchronize tasks in Arduino projects with semaphores and counting semaphores, and exchange data between tasks using queues.
Explore event flags and event groups in FreeRTOS on ESP32, using bit-based signaling to replace semaphores and queues, set and wait for multiple bits, and monitor the output.
Explore hardware interrupts in ESP32, showing how high-priority interrupts can preempt lower-priority tasks, and how to implement a timer interrupt and defer work to tasks across cores.
In this course I will tell about multithreaded arduino programming for ESP32. After completing it, you will learn how to combine the powerful functionality of arduino libraries with multithreaded programming for FreeRTOS.
In the first introductory lecture, I will introduce you to VSCode, which is well suited for developing arduino programs. We will install it and the PlatformIO extension, which allows to compile and debug programs for arduino. Next, we will download a simple arduino-wifiscan project provided by PlatformIO, and use its example to learn how to work with projects in VSCode. Next, we will transfer this project to the original Arduino IDE and run it. After that, we will open the sample project in the Arduino IDE and import it from VSCode.
In the next lecture, we will figure out how the arduino program for ESP32 works and find the main file for it. Next, we will write a simple multithreaded program with three threads.
In the third lecture, we will study in detail the work of this program and use examples to understand what the priorities of tasks affect.
In the next, fourth lecture, we will begin to study ways to synchronize between tasks and change a previously written program to synchronize two threads using a mutex.
In the fifth lecture, we will run one of the tasks on another processor core and use its example to get acquainted with critical sections and find out what spinlock is.
In the sixth lecture, I will show you how to synchronize tasks using semaphores. We will get acquainted with binary and counting semaphores. Than in this lecture we will study queues.
In the seventh lecture I will talk about flags and events.
In the eighth lecture, I will tell you how synchronization is performed between hardware interrupts and tasks. We will add an interrupt from the timer to the previously written program and use its example to consider the use of flags from the interrupt. Different processor cores will be used.
Next, several more examples of multi-threaded programming of ESP32 with arduino will be considered.