Abstract
Households in Iraq face rotating grid outages and depend on capacity-limited neighbourhood diesel generators, while rooftop photovoltaic (PV)–battery systems are usually operated by fixed inverter rules that ignore the outage schedule. This paper designs an Internet-of-Things (IoT) energy management system for a PV–battery–grid–generator home. It comprises four ESP32 nodes, an MQTT network and an edge gateway that runs an outage-aware model-predictive controller (MPC), formulated as a linear programme and executed through the time-of-use registers of Deye/Sunsynk hybrid inverters.
The system was evaluated by a full-year hourly simulation for a Baghdad house driven by 2023 irradiance and temperature data, comparing six strategies over three random realisations of demand and outages. A conventional self-use rule left 6.4% of the demand unserved, whereas an outage-aware rule and the proposed IoT-MPC served practically all demand. Relative to the rule, the IoT-MPC reduced grid imports by 23.6%, PV curtailment by 19.7% and battery cycling by 17.9%, and raised self-sufficiency from 45.2% to 52.7%; each optimisation took 4.8 ms. A 10 kWh battery allowed the generator subscription to be halved, lowering the annual energy cost by about 40%. Outage-aware predictive control therefore delivers equal reliability with markedly lower grid use and battery wear.
Keywords
home energy management Internet of Things model predictive control photovoltaic battery storage intermittent grid ESP32 MQTT IraqReferences
- International Energy Agency, Iraq’s Energy Sector: A Roadmap to a Brighter Future, Paris: IEA, 2019.
- 964media, “Electricity cuts worsen across Iraq as summer heat arrives,” 2025. [Online]. Available: https://en.964media.com/47717/.
- Shafaq News, “Fuel allocation and rising ampere prices: Iraq grapples with chronic summer power shortages,” June 2023. [Online]. Available: https://shafaq.com/en/Report/Fuel-allocation-and-rising-ampere-prices-Iraq-grapples-with-chronic-summer-power-shortages.
- Iraq Business News, “No change to Iraq’s subsidized electricity prices,” 10 December 2025. [Online]. Available: https://www.iraq-businessnews.com/2025/12/10/no-change-to-iraqs-subsidized-electricity-prices/.
- H. A. Kazem and M. T. Chaichan, “Status and future prospects of renewable energy in Iraq,” Renewable and Sustainable Energy Reviews, vol. 16, no. 8, pp. 6007–6032, 2012.
- K. A. Tahir, J. Nieto, C. Díaz-López, and J. Ordóñez, “From diesel reliance to sustainable power in Iraq: Optimized hybrid microgrid solutions,” Renewable Energy, vol. 238, Art. no. 121905, 2025, doi: 10.1016/j.renene.2024.121905.
- B. Zhou, W. Li, K. W. Chan, Y. Cao, Y. Kuang, X. Liu, and X. Wang, “Smart home energy management systems: Concept, configurations, and scheduling strategies,” Renewable and Sustainable Energy Reviews, vol. 61, pp. 30–40, 2016.
- H. Shareef, M. S. Ahmed, A. Mohamed, and E. Al Hassan, “Review on home energy management system considering demand responses, smart technologies, and intelligent controllers,” IEEE Access, vol. 6, pp. 24498–24509, 2018.
- M. Pipattanasomporn, M. Kuzlu, and S. Rahman, “An algorithm for intelligent home energy management and demand response analysis,” IEEE Transactions on Smart Grid, vol. 3, no. 4, pp. 2166–2173, 2012.
- A. Parisio, E. Rikos, and L. Glielmo, “A model predictive control approach to microgrid operation optimization,” IEEE Transactions on Control Systems Technology, vol. 22, no. 5, pp. 1813–1827, 2014.
- D. Mariano-Hernández, L. Hernández-Callejo, A. Zorita-Lamadrid, O. Duque-Pérez, and F. Santos García, “A review of strategies for building energy management system: Model predictive control, demand side management, optimization, and fault detect & diagnosis,” Journal of Building Engineering, vol. 33, Art. no. 101692, 2021.
- A. R. Al-Ali, I. A. Zualkernan, M. Rashid, R. Gupta, and M. Alikarar, “A smart home energy management system using IoT and big data analytics approach,” IEEE Transactions on Consumer Electronics, vol. 63, no. 4, pp. 426–434, 2017.
- R. Luthander, J. Widén, D. Nilsson, and J. Palm, “Photovoltaic self-consumption in buildings: A review,” Applied Energy, vol. 142, pp. 80–94, 2015.
- H. A. Mutar, I. J. Mohammed, and I. R. N. ALRubeei, “AI for solar PV forecasting, MPPT, and energy management: A comprehensive review,” International Journal of Computational and Electronic Aspects in Engineering, vol. 7, no. 1, pp. 100–114, 2026, doi: 10.26706/ijceae.7.1.20260311.
- A. A. Hadi, “The impact of artificial neural network (ANN) on the solar energy cells: A review,” International Journal of Computational and Electronic Aspects in Engineering, vol. 5, no. 1, pp. 30–41, 2024, doi: 10.26706/ijceae.5.1.20240505.
- M. Kadhim, “Improving power quality with active filtering and energy storage technologies in grid-connected hybrid solar-wind renewable energy systems,” International Journal of Computational and Electronic Aspects in Engineering, vol. 7, no. 2, pp. 291–304, 2026, doi: 10.26706/ijceae.7.2.20260317.
- Q. Huangfu and J. A. J. Hall, “Parallelizing the dual revised simplex method,” Mathematical Programming Computation, vol. 10, no. 1, pp. 119–142, 2018.
- OASIS, MQTT Version 3.1.1, OASIS Standard, 2014.
- I. A. Ameen and M. A. Al-Sheikh, “Wireless sensor networks for smart gardening: ESP-NOW and Blynk IoT integration for water and energy optimization,” International Journal of Computational and Electronic Aspects in Engineering, vol. 5, no. 3, pp. 101–115, 2024, doi: 10.26706/ijceae.5.3.20240804.
- O. A. Abdaumran, “IoT-enabled real-time fault monitoring in overhead power lines using ESP32 and Arduino integrated development,” International Journal of Computational and Electronic Aspects in Engineering, vol. 6, no. 3, pp. 190–201, 2025, doi: 10.26706/ijceae.6.3.20250610.
- S. Waghe, U. Kuradkar, S. Prajapati, and R. Mohane, “Detecting and reducing phantom power: A human-centric IoT approach,” International Journal of Computational and Electronic Aspects in Engineering, vol. 7, no. 3, pp. 76–83, 2026, doi: 10.26706/ijceae.7.3.20260711.
- A. W. Talab, “Improving communication protocols based on crucial data transmission security for IoT techniques,” International Journal of Computational and Electronic Aspects in Engineering, vol. 6, no. 1, pp. 1–11, 2025, doi: 10.26706/ijceae.6.1.20250203.
- S. Q. Ameen, R. G. S. Alsulta, Z. S. Hussain, and Z. T. Abdul-Rahmman, “A hybrid RSA–ElGamal framework for secure end-to-end communications in resource-constrained IoT networks,” International Journal of Computational and Electronic Aspects in Engineering, vol. 7, no. 2, pp. 140–153, 2026, doi: 10.26706/ijceae.7.2.20260303.
- J. Kellerman, “sunsynk: Deye/Sunsynk hybrid inverter Modbus library and register definitions,” open-source software (Apache-2.0), GitHub, 2026. [Online]. Available: https://github.com/kellerza/sunsynk.
- P. Zippenfenig, “Open-Meteo.com Weather API,” Zenodo, 2023, doi: 10.5281/zenodo.7970649.
- H. Hersbach et al., “The ERA5 global reanalysis,” Quarterly Journal of the Royal Meteorological Society, vol. 146, no. 730, pp. 1999–2049, 2020.
- D. G. Erbs, S. A. Klein, and J. A. Duffie, “Estimation of the diffuse radiation fraction for hourly, daily and monthly-average global radiation,” Solar Energy, vol. 28, no. 4, pp. 293–302, 1982.
- J. A. Duffie and W. A. Beckman, Solar Engineering of Thermal Processes, 4th ed. Hoboken, NJ: Wiley, 2013.
- P. Virtanen et al., “SciPy 1.0: Fundamental algorithms for scientific computing in Python,” Nature Methods, vol. 17, pp. 261–272, 2020.