FreeRTOS for ESP32 & Robotics Firmware
Complete offline clones of the internet's premier FreeRTOS tutorials from RandomNerdTutorials, TeachMeMicro, and ControllersTech. Master concurrent tasks, dual-core affinity, mutexes, semaphores, and inter-task queues.
ESP32 Symmetric Multiprocessing (SMP) Architecture
Protocol CPU: Handles Wi-Fi 802.11 b/g/n, Bluetooth Low Energy (BLE), and system watchdog interrupts by default.
xTaskCreatePinnedToCore(..., 0);
Application CPU: Runs the default Arduino loop() task. Ideal for high-speed motor PID loops, sensor fusion, and kinematics.
xTaskCreatePinnedToCore(..., 1);
All 6 Cloned FreeRTOS Tutorials
1. Create Tasks & Dual Core
Learn how to create independent tasks, allocate stack bytes, set priority levels (0 to 24), and bind tasks to Core 0 or Core 1 with xTaskCreatePinnedToCore().
2. Binary & Counting Semaphores
Master task signaling, button ISR interrupts (xSemaphoreGiveFromISR), and resource counting pools so tasks wait without burning CPU cycles.
3. Inter-Task Queues
Pass complex sensor readings, structs, and command packets between multiple producer tasks and consumer tasks safely using thread-safe FIFO queues.
4. Mutex & Shared Resources
Protect shared hardware peripherals (I2C bus, SPI, UART/Serial, OLED displays) and shared memory variables from race conditions and priority inversion.
5. TeachMeMicro: Multitasking
In-depth explanation of FreeRTOS task lifecycle states (Ready, Running, Blocked, Suspended), non-blocking vTaskDelay(), and ESP32 hardware timer ticks.
6. ControllersTech: FreeRTOS Series
Foundational real-time operating system concepts: preemptive round-robin scheduling, cooperative scheduling, memory management heaps (Heap_1 to Heap_5).
FreeRTOS C++ Quick Reference Cheat Sheet
| Function / Macro | Purpose | Key Arguments |
|---|---|---|
| xTaskCreatePinnedToCore() | Spawn a task bound to Core 0 or Core 1 | (fn, name, stackBytes, param, priority, handle, coreId) |
| vTaskDelay(pdMS_TO_TICKS(ms)) | Yield CPU to other tasks for specified milliseconds | ticksToDelay |
| vTaskDelete(handle) | Terminate and free memory of a task (or NULL for self) | taskHandle |
| xQueueCreate() | Allocate a thread-safe message FIFO queue | (queueLength, itemSizeBytes) |
| xQueueSend() / xQueueReceive() | Push to and pop from inter-task queue | (queue, &item, ticksToWait) |
| xSemaphoreCreateMutex() | Create a mutex lock with priority inheritance | none |