1. Introduction
Since 2020, the deployment of distributed photovoltaic systems in Europe has grown by more than 40% annually [
10], driving campus-scale and community microgrids into configurations that conventional SCADA systems were never designed to monitor. A microgrid combining PV arrays, small wind turbines, battery storage, and time-varying building loads generates heterogeneous telemetry, power flows, voltages, frequencies, state of charge, and weather conditions at sub-minute intervals. Tracking these measurements in real time is a solved problem for a single metering point. Tracking them across a dozen assets while simultaneously determining where energy is lost between the panel and the common connection point, contamination, cable resistance, inverter conversion, transformer core magnetization doesn't happen. That is the monitoring gap this paper addresses.
Digital twin technology has emerged as a candidate solution. A digital twin, in the energy context, is a virtual replica of a physical system synchronized through IoT communication, enabling monitoring, simulation, and decision support without interrupting the physical asset [
1,
3]. Digital twin for microgrids have attracted considerable attention in recent years. Although, there are six review papers and articles written between 2024 and 2025 on digital twin applications for smart grids and renewable energy systems [
1,
3,
4,
5,
6], and two other have addressed specific topologies of microgrids [
2,
7]. Despite the numerous surveys on the topic, the field is very poor in terms of actual, deployable implementations. Out of 112 papers on digital twins for smart energy published by Aghazadeh Ardebili et al. [
5] in , 107 of them are based on the conceptual design of digital twins or simulation results without any runnable code, IoT communication layers, or a step-by-step guide for their real-world deployments.
Current solutions only cover fragments of the required capabilities. OpenEMS [
29] provides energy flow calculations in a Java OSGi bundle structure and thus serves as a good base. However, it lacks an MQTT communication layer and also a physics-based loss model. VOLTTRON [
31], provided by Pacific Northwest National Laboratory, is an agent-based architecture that provides a communication framework using its own protocol. However, it is focused on building-connected applications and not for microgrid-related use cases. Eclipse Ditto [
32] is a generic solution for digital twins and is well-engineered. It supports MQTT messaging and comes with a REST API to manage the state of a digital twin. But, comes without energy equations, microgrid-specific topic hierarchies and without a dashboard. ThingsBoard [
33] is an open-source software for data collection from IoT devices using MQTT protocol, and creation of configurable interactive web dashboards. However, the community edition is limited in aspect of connected devices, and there is no physics simulation engine built-in. For microgrid simulation using reinforcement learning, we found pymgrid [
11], a Python open-source software library for research simulation of microgrid. While it has capabilities for microgrid simulation, it outputs arrays of numerical values and lacks functions for deployment and real-time monitoring of time-series data from various IoT devices and sensors. Another relevant numerical calculation library is pvlib [
12] which computes PV energy losses with high fidelity using validated models including the CEC inverter curves [
15] and NOCT cell temperature estimates, but it is a calculation library, not a monitoring platform. For example, Hamid et al. [
14] built a MATLAB-based digital twin of a large PV plant with high accuracy (prediction accuracy of 99.77%) in a controlled environment, while it is proprietary framework that cannot be freely distributed or even containerized. Sivaneasan et al. [
2] came closest, their Cognitive DT for a Singapore microgrid achieved 0.24% cost deviation in a real-world deployment, but it uses proprietary components, focuses on optimization rather than monitoring, and does not publish itemized loss telemetry. Izquierdo Monge et al. [
28] built an open-source monitoring and alarm system for microgrids, but it lacks physics-based loss models and does not report MQTT performance benchmarks. And the most recent MQTT performance study for microgrid communication Kondoro et al. [
8] is now five years old and tested simpler payloads on different hardware.
In our previous work [
30], we presented a web-based hybrid optimization platform for real-time microgrid energy management at SoftCOM 2025. That system demonstrated the viability of combining genetic algorithm and reinforcement learning optimizers with LSTM-based load forecasting for battery dispatch scheduling. But it was built on Flask (synchronous), had no IoT communication layer, no physics-based loss models, and no containerized deployment, precisely the limitations that motivated the present study.
The gaps in existing approaches fall into four distinct categories: (a) reliance on proprietary tools that prevent reproducibility, (b) absence of physics-based energy loss models that quantify where generation is lost between source and load, (c) lack of real-time IoT communication layers with structured topic hierarchies and published latency analysis, and (d) no reproducible performance benchmarks against which alternative implementations can be compared. In light of these gaps, this paper makes the following four contributions:
1. An end-to-end open-source digital twin architecture comprising twelve Docker services: simulator, MQTT broker, data-ingestion subscriber, API gateway, time-series database, in-memory cache, frontend dashboard, reverse proxy, and four supporting services deployable via a single `docker compose up -d` command under the MIT license.
2. A physics-based microgrid simulator implementing nine distinct energy loss mechanisms applied sequentially at 5-second resolution: PV soiling (Kimber linear model [
16]), module mismatch, DC cable I²R losses, CEC inverter efficiency curves [
15], AC distribution cable losses, transformer iron-copper losses, battery self-discharge, BMS parasitic draw, and wind mechanical losses, each published as itemized MQTT telemetry per simulation step.
3. A hierarchical MQTT topic architecture with QoS 1 at-least-once delivery, six topic patterns carrying per-asset measurements including full loss breakdowns, and a dual-write ingestion pipeline that routes messages simultaneously to TimescaleDB hypertables for historical storage and to Valkey pub/sub channels for sub-second WebSocket delivery to the dashboard.
4. Reproducible performance benchmarks from a one-hour automated test demonstrating P50 end-to-end latency of 27.2 ms, P99 of 48.3 ms, 100% message delivery reliability across 5,840 messages, and a per-topic latency analysis revealing the serialization-order effect inherent in sequential MQTT publishing, the first such benchmark for a microgrid digital twin framework since Kondoro et al. [
8] in 2021.
The remainder of this paper is organized as follows.
Section 2 describes the system architecture, simulator, MQTT, data pipeline, web interface and deployment.
Section 3 presents the experimental results like latency, throughput, reliability, loss model validation, and platform comparison. In section 4 we discuss key findings, Industry 5.0 alignment, and limitations.
Section 5 concludes with specific future research directions.