A Modular, Power-Aware Firmware System with CLI Dashboard, Logging Framework, and Sensor Abstraction
Target MCU: STM32 Nucleo-F446RE
Toolchain: STM32CubeIDE / arm-none-eabi-gcc
UART Interface: ST-LINK VCP (typically USART2 @ 115200)
The STM32 Smart Sensor Hub is a professionally structured embedded firmware project built to demonstrate modern firmware engineering practices:
- Modular layered architecture
- Cooperative task scheduler
- Runtime-configurable structured logging framework
- Interactive UART CLI (dashboard-style)
- Power management system
- Sensor abstraction (simulated sensor now, real sensors later)
- Dynamic sensor sampling period that adapts to the current power mode
- GitHub Actions CI (compile-only)
- Full documentation
- Clean, maintainable C code with Doxygen-ready comments
This repository is structured like a real production firmware codebase.
stm32-smart-sensor-hub/
├── Core/ # Cube-generated startup, HAL, clock config
├── Drivers/ # HAL drivers
├── app/ # Application entry, task manager, main loop
├── common/ # Logging framework, CLI, utilities
├── sensors/ # Sensor abstraction + simulated sensor
├── power/ # Power manager module
├── docs/ # Documentation for all phases
└── .github/workflows/ # GitHub Actions CI
| Layer | Purpose |
|---|---|
| Core/ | System startup, HAL initialization, ISR handlers |
| app/ | Main application logic + cooperative task scheduler |
| common/ | Logging subsystem, CLI interpreter, helpers |
| sensors/ | Sensor interface API + simulated sensor backend |
| power/ | Power mode manager (Active/Idle/Sleep/Stop) |
| docs/ | Architecture docs, release notes |
| .github/ | CI pipeline (ARM GCC build verification) |
Tasks include:
HeartbeatSensorSamplePowerManagerCLI
Each task has its own period and logs its execution timing.
Log format:
[00123456 ms][INF][../app/app_main.c:152][App_TaskSensorSample] Value=23.1 C
Supports:
- DEBUG / INFO / WARN / ERROR
- Runtime filter control
- CLI-controlled pause/resume
- Automatic CLI prompt redraw after each log line
Example commands:
help
log pause
log resume
log info
log debug
pmode idle
status
Features:
- Non-blocking input
- Backspace support
- Dashboard-style, always-visible prompt
- Logs never overwrite the CLI command entry line
typedef struct {
bool (*init)(void);
bool (*read)(SensorData_t *out);
} SensorIF_t;Currently uses a simulated temperature sensor (sensor_sim_temp.c/.h)
plugged into this interface.
Later you can plug in:
- I²C sensor
- SPI sensor
- ADC sensor
- Additional simulated/virtual sensors for testing
Power modes:
POWER_MODE_ACTIVEPOWER_MODE_IDLEPOWER_MODE_SLEEPPOWER_MODE_STOP
The SensorSample task period automatically adapts to the current power mode:
#define SENSOR_PERIOD_ACTIVE_MS (1000U) // 1 second in ACTIVE mode
#define SENSOR_PERIOD_IDLE_MS (5000U) // 5 seconds in IDLE mode
#define SENSOR_PERIOD_SLEEP_MS (30000U) // 30 seconds in SLEEP mode
#define SENSOR_PERIOD_STOP_MS (0U) // 0 => no sampling in STOP- In STOP mode, sensor sampling is completely disabled.
- The CLI
statuscommand reports the effective sensor sample period.
This models how a real low-power system would adapt workload based on its power budget.
- Installs ARM GCC
- Builds firmware on Ubuntu
- Verifies compilation on every push & PR
- Open the project in STM32CubeIDE.
- Build the project (Debug or Release).
- Flash the firmware to the Nucleo-F446RE.
- Open a serial monitor at 115200 baud, 8N1.
- Reset the board and look for the CLI banner.
- Type
helpto see available commands.
Smart Sensor Hub CLI ready.
Type 'help' for commands.
> log info
[00001234 ms][INF][../app/app_main.c:129][App_TaskHeartbeat] Heartbeat task toggled LED
[00002234 ms][INF][../app/app_main.c:152][App_TaskSensorSample] SensorSample: value=23.10 C, timestamp=2234 ms
> pmode sleep
Requested power mode change: sleep
> status
Status:
Task logging: ENABLED
LogLevel: 1 (0=DEBUG,1=INFO,2=WARN,3=ERROR)
PowerMode: 2 (0=ACTIVE,1=IDLE,2=SLEEP,3=STOP)
Sensor sample period: 30000 ms
Included in /docs:
- README.md (this file)
- ARCHITECTURE.md (layered design)
- RELEASE_NOTES.md (per-phase changes)
- CLI_COMMANDS.md (detailed CLI behavior and examples)
All are updated at each project phase.
Includes:
- CLI dashboard
- Logging framework enhancements
- Power Manager foundation
- Task Manager improvements
- Sensor abstraction and simulated sensor
- Dynamic sensor sampling based on power mode (ACTIVE/IDLE/SLEEP/STOP)
- GitHub workflow
- Full documentation
- Phase 5 → Real I²C sensor integration
- Phase 6 → Real STM32 low-power mode entry/wakeup
- Phase 7 → Event/state machine on top of tasks
- Phase 8 → Flash/SD logging or host-side tooling
- Phase 9 → BLE or USB link to external dashboard
- Phase 10 → Remote telemetry / visualization
This project demonstrates:
- Embedded architecture & modular design
- Reusable driver and sensor abstraction
- Task scheduling and power management
- Power-aware behavior (dynamic sensor sampling vs power mode)
- CLI protocol handling and UX considerations
- Logging frameworks with runtime control
- CI/CD discipline for embedded firmware
Ideal to showcase for Embedded/Firmware Engineer roles.
MIT