Elektor ESP32 Energy Meter
A detailed exploration of the development, design, and integration of a smart energy meter powered by the ESP32 microcontroller.
Introduction
This document outlines the journey of creating a reliable, user-friendly energy meter using the Espressif ESP32 microcontroller. It emphasizes real-time power consumption monitoring and safety, detailing the initial steps, design considerations, and subsequent enhancements.
Project Overview
The project aims to develop an energy meter that accurately measures power consumption in real-time, providing users with insights for more efficient energy use. The design focuses on affordability, user-friendliness, and integration with smart home systems.
Design and Requirements
Key design goals include real-time single-phase power monitoring using current transformers (CTs), affordability, and a compact form factor suitable for circuit breaker boxes. The selection of the ESP32 microcontroller and the ATM90E32AS energy metering IC was driven by these requirements, offering a balance of cost-effectiveness, performance, and extensive community support.
Microcontroller Selection: ESP32
The ESP32 microcontroller was chosen for its ease of integration, cost-effectiveness, compatibility with various sensors, and strong community support. Its capabilities are well-suited for the demands of this energy monitoring project.
Metering IC Integration: ATM90E32AS
The ATM90E32AS IC from Microchip serves as the core energy measurement component. Its integration with the ESP32 microcontroller was guided by the manufacturer's application notes, ensuring seamless communication and accurate data acquisition.
Schematic Design and Electrical Safety
The schematic design prioritizes safety, incorporating meticulous attention to mains AC voltage handling and adherence to established safety standards. Specialized components like Metal Oxide Varistors (MOVs) and fuses are included for transient voltage suppression and overcurrent protection, respectively.
Circuit Isolation
To ensure safety, galvanic isolation is implemented between the AC mains and the ESP32 microcontroller. The ADuM3151 SPIsolator is used to transfer digital signals across an isolation barrier, protecting the system from high-voltage transients.
Power Supply Optimization
The energy meter is powered by efficient buck switching regulators, such as the AP63203WU-7, which offer improved efficiency, lower cost, and smaller size compared to previous solutions. The system can be powered via a 12 VDC input or directly from the AC mains.
Interactive and Modular Features
The project incorporates features like LEDs for energy pulse outputs, jumpers for power mode selection, and modular connectors (e.g., Qwiic) for expandability. The ESP32-S3's USB connectivity facilitates easy programming and debugging.
PCB Layout and Manufacturing
The PCB layout has been optimized for compactness and ease of soldering. Strategic placement of components, including voltage and current sampling connections, and headers for external microcontrollers, enhances modularity and accessibility.
Firmware Development and Integration
The firmware is developed to connect the ESP32 to a Wi-Fi network and utilize MQTT for communication, enabling real-time energy monitoring. The project utilizes the ATM90E32 Arduino Library and the MQTTPubSubClient library for communication.
ESPHome and Home Assistant Integration
The ESP32 Energy Meter can be integrated with Home Assistant using ESPHome firmware. This allows for real-time data visualization, creation of custom dashboards, and automation of actions based on energy data. The process involves configuring the ESPHome dashboard, flashing the firmware, and setting up MQTT integration within Home Assistant.
Calibration and Testing
Calibration of the energy meter is crucial for accurate readings. This involves adjusting gain settings for voltage and current measurements using a multimeter and updating the ESPHome YAML configuration file. The setup includes testing with a variable load to ensure accurate performance.
Breaker Box Installation
Installation within a circuit breaker box requires careful attention to safety. It is recommended to turn off all power before installation and to have the work carried out by a qualified electrician. Proper selection of the circuit and correct orientation of current transformers are essential for safe and accurate operation.
Development and Prospects
Ongoing development aims to expand the ESP32 Energy Meter's capabilities with advanced features such as detailed energy analytics and AI/ML functionalities for predicting energy usage patterns. Community involvement is encouraged to contribute to the project's advancement.
About the Author
Saad Imtiaz, Senior Engineer at Elektor, brings extensive experience in embedded systems, mechatronics, and product development. His expertise spans various industries, including aviation and technology startups.