Embedded / RTOS2026
RTOS Environmental Monitoring Node
Five-task FreeRTOS firmware on STM32F103 streaming telemetry to an MQTT gateway
- C
- FreeRTOS 11.1
- STM32F103RB
- BME680
- I²C
- DMA + IDLE
- CMake
- ESP32
- MQTT
- pytest
FreeRTOS firmware for an STM32 NUCLEO-F103RB that samples a BME680 over I²C, filters and scores the readings, and streams formatted telemetry over UART to an ESP32 that republishes it as MQTT. Built around explicit priority assignment, priority-inheritance locking, and a command interface that reconfigures the sampling period at runtime.

- 01
Five tasks with deliberate priorities
Sensor at priority 3, processing and comm at 2, logging and health at 1. The health task uses absolute wake times rather than relative delays so its 5-second cadence holds even when execution time varies.
- 02
Zero-interrupt UART reception
Circular DMA with IDLE-line framing means a burst of incoming bytes costs no interrupts at all — the line goes idle, one event fires, and the whole message is already in memory.
- 03
Priority inheritance on the I²C bus
The BME680 bus is guarded by a priority-inheritance mutex, and the button ISR uses direct task notifications instead of a semaphore, keeping the interrupt path short and the sensor task unblocked.
- 04
Runtime command interface
STATUS, SAMPLE_NOW, SET_PERIOD, GET_PERIOD and PING are accepted on either UART link, with responses returned on the originating link. The sampling period retunes from 100 ms to 60 s without stopping the application.
- 05
Hardware-free unit testing
processing.c, telemetry.c and cmd_parser.c contain no HAL or kernel calls, so they compile for the host and run 93+ tests under pytest via ctypes. Hardware tests then check round-trip latency and telemetry jitter separately.


