Skip to content
All projects

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.

The NUCLEO-F103RB, BME680 sensor and ESP32 gateway wired together
The node on the bench — NUCLEO-F103RB, BME680, ESP32 gateway.
5
FreeRTOS tasks
36.3 KB
Flash — 27.7% of 128 KB
13.0 KB
SRAM — 65% of 20 KB
93+
Host-side unit tests
  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

FreeRTOS task and queue architecture diagram
Task graph, queues, and the notification paths between them.
Serial console output showing the telemetry line format
Telemetry stream and the health task's heap/stack report.
Chart of telemetry scheduling jitter measurements
Measured scheduling jitter across sampling periods.