This project was developed as part of our BCA182 Embedded Systems Programming Laboratory, with the goal of building a real-time room monitoring system using an STM32 Blue Pill and FreeRTOS.
The project started with a simple idea: how can multiple sensors work together in a single embedded system while still responding to events in real time? Instead of handling everything inside one large loop, we designed the system around FreeRTOS tasks so that different parts of the system could operate independently.
The system monitors temperature, humidity, ambient light, and motion using a DHT22, LDR, and PIR sensor. The readings are collected by a dedicated SensorTask and shared with the other tasks through a FreeRTOS queue.
We also wanted the system to respond to user input. A rotary encoder allows the user to navigate between temperature, humidity, light, and motion readings. An SSD1306 OLED display shows the selected measurement together with the current activity state.
Motion detection is handled separately through a MotionTask. When motion is detected, the system becomes ACTIVE. If no motion is detected for the configured period, the system transitions to INACTIVE. This state is shared with the rest of the system using FreeRTOS task notifications and protected shared-state access.
For safety, we added a temperature alarm. If the temperature goes below 18°C or above 30°C, the AlarmTask activates the buzzer. The alarm is suppressed while the room is INACTIVE.
One of the main things we wanted to learn from this project was not just how to make the sensors work, but how to properly structure a real-time embedded application. We used multiple FreeRTOS tasks, task priorities, periodic scheduling with vTaskDelayUntil(), queues, mutexes, task notifications, critical sections, and a state machine.
Testing was also an important part of the project. We created 13 native unit tests covering temperature evaluation, display navigation, and system-state behavior. All 13 tests passed. We also performed static code analysis with PlatformIO and reviewed the system architecture and resource usage.
The project was developed using C/C++, STM32 HAL, FreeRTOS, PlatformIO, and Wokwi. The source code and documentation are available in the project's GitHub repository.
This project gave us practical experience in designing a multitasking embedded system and showed us how FreeRTOS can be used to turn several independent hardware functions into one coordinated real-time application.















Comments