Skip to content
Awais Asghar.
Embedded & IoT2025

FreeRTOS Smart Energy Monitor

STM32F746 tasks compute Vrms, Irms and kWh; an ESP32 pushes it to a cloud dashboard.

A real-time energy monitoring and billing system. Independent FreeRTOS tasks on an STM32F746 handle sensor acquisition from ZMPT101B and ACS712 modules, RMS calculation with DC-offset removal, power and energy computation, and a local display. Processed data goes over UART to an ESP32 that uploads to Firebase for remote monitoring.

FreeRTOS Smart Energy Monitor thumbnail

README · rendered from GitHub

FreeRTOS-Based Smart Energy Monitor using STM32

Status Platform MCU RTOS Cloud Language Lisence

Project Overview

This project implements a real-time smart energy monitoring and billing system using the STM32F746 microcontroller and ESP32. The system measures voltage and current, computes RMS values, calculates power and energy consumption, and uploads live data to the Firebase cloud using WiFi. The design follows a FreeRTOS-based multi-task architecture, ensuring deterministic operation and clean separation of responsibilities.

Image Image Image Image

Key Features

  • Real-time voltage and current measurement
  • RMS calculation with DC offset removal
  • Power and energy (kWh) computation
  • Cloud-based monitoring using Firebase
  • FreeRTOS-based multi-threaded design
  • UART communication between STM32 and ESP32

System Architecture

  • Voltage Sensor (ZMPT101B) → STM32 ADC
  • Current Sensor (ACS712 / INA219) → STM32 ADC
  • STM32F746 → Signal processing + RMS calculation (FreeRTOS)
  • ESP32 → WiFi + Firebase cloud upload
  • UART → Communication between STM32 and ESP32
Image Image

Tools and Technologies

  • STM32F746
  • FreeRTOS
  • STM32CubeIDE
  • IAR Embedded Workbench
  • ESP32
  • Arduino IDE
  • Firebase Realtime Database
  • UART Communication
  • C / C++
Image

Core Implementation

Image

FreeRTOS Task Design

STM32 (RTOS-based)

  • ADC Sampling Task (High Priority)
  • RMS & Signal Processing
  • UART Transmission Task

ESP32 (Dual-Core FreeRTOS)

  • UART Receive Task
  • Cloud Upload Task
  • Serial Debug Task

Mutexes are used to protect shared data across tasks.

Image Image Image

Hardware Implementation

Image

Results

  • Stable RMS voltage and current measurement
  • Accurate power and energy computation
  • Live cloud updates every 5 seconds
  • Robust real-time performance using FreeRTOS
Image Image Image

Applications

  • Smart home energy monitoring
  • Industrial power usage tracking
  • Smart metering systems
  • Energy consumption analysis
Image

Demo Video

https://github.com/user-attachments/assets/38ebc3f2-3e4e-472e-ad77-98723180af24

Team Members

  • Awais Asghar
  • Muhammad Haris
  • Saad Farooq
  • Aneeqa Ur Rehman
Image Image Image Image Image Image Image

References

  • STM32F746 Reference Manual
  • ESP32 Technical Reference
  • Firebase Realtime Database Documentation
  • FreeRTOS Official Documentation
Image

License

This project is intended for academic and educational use.

More in Embedded

Related projects

See all
  • Embedded2024

    Crowd-Sourced AQI Monitor

    Six sensors, Bluetooth to a phone app, and AQI within 1% of the US Embassy station.

    • Arduino UNO
    • C/C++
    • PMS5003
    • MQ-series
  • Embedded2024

    Fully Automated Egg Incubator

    ATmega328P climate control and egg turning that hatched every pigeon egg in 18 days.

    • ATmega328P
    • Arduino IDE
    • Atmel Studio
    • Proteus
  • Embedded2024

    Smart Health Tracking System

    ECG, SpO₂, heart rate, temperature and fall detection on one wearable node.

    • Arduino UNO
    • C/C++
    • AD8232
    • MAX30100