Building 3-Phase AC Power Meter with ESP8266

Building a 3-Phase AC Power Meter using ESP8266 and PZEM0040 v3
In this project, we will build a 3-phase AC power meter using the ESP8266 microcontroller and the PZEM0040 v3 AC power monitoring module. The S-MOTA firmware will be used to program the device.
Specifications
The device can measure a 3-phase current of up to 100A and voltage up to 260V AC. It is also isolated from the mains voltage, making it safe to use.
Additional Features
An I2C port has been left available for adding a display or other I2C devices. Additionally, the device can be integrated with home automation systems via an MQTT broker.
Design and Manufacturing
The design of the PCB was created using a computer-aided design (CAD) software, and then converted into Gerber files. The JLCPCV service was used to manufacture the PCBs, which were received after 10 days.
Components and Assembly
A list of components is provided in the description below. The components were soldered onto the PCB, and the device was assembled.
Flashing the Firmware
A USB to TTL module was used to flash the S-MOTA firmware onto the ESP8266 microcontroller. The Tasmota web installer website provides a step-by-step guide for flashing the firmware.
Conclusion
This project demonstrates how to build a 3-phase AC power meter using the ESP8266 microcontroller and the PZEM0040 v3 module. The device is isolated from the mains voltage, making it safe to use, and can be integrated with home automation systems.
Purchasing Information
If you are interested in purchasing this power meter or other products, please contact us via Instagram. The link is provided in the description below.
Future Improvements
This is the first version of the project, and there are many things that can be improved. Please suggest improvements in the comments section.
Part List and Circuit Diagram
A list of components and a circuit diagram are provided in the description below. You can use these to build your own version of this project.
Disclaimer
This project is for educational purposes only, and you should not attempt to build it unless you are experienced with electronics and safety precautions.
Note: The article has been expanded to provide more details and explanations. The content has been rewritten to make it more comprehensive and easier to understand.

Power Meter
Definition: A power meter is an instrument used to measure the electrical power of a circuit. It is also known as wattmeter or electric power meter.
Background: The first power meters were developed in the late 19th century, shortly after the invention of the alternating current (AC) system. The earliest types of power meters used electrodynamic principles to measure the power consumed by a circuit.
Types: There are several types of power meters available, including analog and digital power meters, as well as specialized types such as kilowatt-hour (kWh) meters and harmonic analyzers.
Applications: Power meters have a wide range of applications in fields such as electrical engineering, energy management, and industrial automation. They are used to measure the power consumption of electrical devices, motors, and entire buildings.
Principle of Operation: A power meter measures the voltage and current flowing through a circuit and calculates the power consumed using Ohm's law (P = V x I). Modern digital power meters often use advanced algorithms to correct for errors and provide accurate measurements.


Building 3-Phase AC Power Meter with ESP8266

Introduction: In this article, we will explore how to build a 3-phase AC power meter using the popular ESP8266 microcontroller. The ESP8266 is a low-cost, Wi-Fi enabled microcontroller that can be used for a wide range of applications, including IoT projects like this one.
Components:
  • ESP8266 Microcontroller (e.g. NodeMCU v3)
  • 3-phase AC power meter IC (e.g. ATM90E32AS)
  • Current Transformers (CTs) for each phase
  • Voltage Transformers (VTs) for each phase
  • Resistors, capacitors, and other passive components
  • Breadboard and jumper wires
Circuit Diagram: The circuit diagram for this project is shown below. Please note that the actual circuit may vary depending on the specific components used. Circuit Diagram
Software: The software for this project will be written in C++ using the Arduino IDE. We will use the ESP8266WiFi library to connect to a Wi-Fi network and send data to a server.
#include <ESP8266WiFi.h>

// Define Wi-Fi credentials
const char* ssid = "your_ssid";
const char* password = "your_password";

// Define server URL
const char* serverUrl = "http://example.com/data";

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to Wi-Fi...");
  }
}

void loop() {
  // Read data from power meter IC
  int voltage = readVoltage();
  int current = readCurrent();

  // Send data to server
  sendToServer(voltage, current);

  delay(10000); // wait 10 seconds before sending next reading
}
Calibration: To ensure accurate readings, the power meter IC needs to be calibrated. This involves setting the calibration constants in the IC's register.
void calibrate() {
  // Set calibration constants
  writeRegister(0x00, 0x12); // set voltage gain
  writeRegister(0x01, 0x34); // set current gain
}
Testing: Once the circuit is built and the software is uploaded, it's time to test the power meter. Connect a load (e.g. a light bulb) to each phase of the power meter and measure the voltage and current readings.
void test() {
  // Read data from power meter IC
  int voltage = readVoltage();
  int current = readCurrent();

  Serial.println("Voltage: " + String(voltage));
  Serial.println("Current: " + String(current));
}
Conclusion: In this article, we have built a 3-phase AC power meter using the ESP8266 microcontroller and an ATM90E32AS IC. The device can measure voltage and current readings for each phase and send them to a server via Wi-Fi.


Q1: What is the main component used in building a 3-phase AC power meter with ESP8266? The main component used is the ESP8266 microcontroller, which is a low-cost Wi-Fi capable microcontroller.
Q2: What is the purpose of using an ACS712 current sensor in the project? The ACS712 current sensor is used to measure the current flowing through each phase of the 3-phase AC power system.
Q3: How does the ESP8266 microcontroller read the data from the ACS712 current sensors? The ESP8266 microcontroller reads the data from the ACS712 current sensors through analog-to-digital conversion (ADC) pins.
Q4: What is the role of the voltage divider circuit in the project? The voltage divider circuit is used to step down the high AC voltage to a lower DC voltage that can be read by the ESP8266 microcontroller.
Q5: How does the project calculate the power consumption of each phase? The project calculates the power consumption of each phase by multiplying the measured current and voltage values for each phase.
Q6: Can the project measure both active and reactive power? Yes, the project can measure both active and reactive power using the calculated power factor (PF) value.
Q7: How does the ESP8266 microcontroller send the measured data to a remote server? The ESP8266 microcontroller sends the measured data to a remote server using Wi-Fi communication protocol (e.g. HTTP or MQTT).
Q8: What is the purpose of using a calibration factor in the project? The calibration factor is used to adjust the measured values to match the actual power consumption values, taking into account any measurement errors.
Q9: Can the project be used for single-phase AC power metering as well? Yes, with some modifications to the circuit and code, the project can be used for single-phase AC power metering.
Q10: What are some potential applications of this 3-phase AC power meter project? Potential applications include industrial energy monitoring, smart grid systems, and IoT-based energy management solutions.




Rank Pioneers/Companies Contributions
1 Arduino Popularized the use of microcontrollers in DIY electronics, including the development of AC power meters with ESP8266.
2 Espressif Systems Developed the ESP8266 microcontroller, which is widely used in IoT projects, including building AC power meters.
3 Olimex Offered one of the first commercial ESP8266 development boards and provided extensive documentation and resources for building AC power meters.
4 SparkFun Electronics Created a range of ESP8266-based boards, including the SparkCore, which can be used for building AC power meters.
5 Adafruit Industries Provided extensive tutorials and resources on using ESP8266 for IoT projects, including building AC power meters.
6 Raspberry Pi Foundation Popularized the use of single-board computers in DIY electronics, including building AC power meters with ESP8266.
7 STMicroelectronics Developed a range of microcontrollers and sensors that can be used for building AC power meters, including the STM32 series.
8 NXP Semiconductors Provided a range of microcontrollers and sensors that can be used for building AC power meters, including the LPC series.
9 Microchip Technology Developed a range of microcontrollers and sensors that can be used for building AC power meters, including the PIC series.
10 Invensense Provided a range of sensors and microcontrollers that can be used for building AC power meters, including the MPU series.




Component Description Technical Details
ESP8266 Microcontroller Handles communication, data processing, and control tasks Tensilica L106 32-bit RISC CPU, 4MB flash memory, 96KB RAM, Wi-Fi capabilities (802.11 b/g/n)
ACS712 Current Sensor Module Measures current in each phase of the 3-phase AC power system Bipolar current sensing, ±5A range, 5V supply voltage, I2C interface, 10-bit ADC resolution
ZMPT101B Voltage Sensor Module Measures voltage in each phase of the 3-phase AC power system Single-phase voltage sensing, 0-300V range, 5V supply voltage, I2C interface, 10-bit ADC resolution
DS3231 Real-Time Clock (RTC) Module Provides accurate timekeeping and synchronization for data logging and analysis I2C interface, ±5ppm accuracy, battery backup, temperature compensation (-40°C to +85°C)
MicroSD Card Module Stores energy consumption data for later analysis and monitoring up to 32GB storage capacity, SPI interface, 3.3V supply voltage
Breadboard and Jumper Wires Provides a platform for prototyping and connecting components Insulated copper wire, 22AWG, 10cm length, 5V/3.3V compatible
Power Supply (optional) Provides power to the system if not using USB or battery power Input: 100-240V AC, Output: 5V DC, up to 2A current, compact design
Circuit Connection Details Description
VCC and GND connections Connect the VCC pin of each module to the 5V power rail on the breadboard, and the GND pin to the ground rail.
I2C connections Connect the SCL and SDA pins of the ACS712 and ZMPT101B modules to the corresponding pins on the ESP8266 ( GPIO5 and GPIO4, respectively).
SPI connections (MicroSD Card) Connect the MOSI, MISO, and SCK pins of the MicroSD Card module to the corresponding pins on the ESP8266 (GPIO13, GPIO12, and GPIO14, respectively).
Software Details Description
Programming Language Use the Arduino IDE or ESP8266 SDK to write C/C++ code for the project.
Library Dependencies Include libraries for I2C communication (e.g., Wire), SPI communication (e.g., SPI), and SD card access (e.g., SdFat).
Timekeeping and Synchronization Use the DS3231 RTC module to keep accurate time, and synchronize data logging and analysis using NTP or other time synchronization protocols.
Data Logging and Analysis Write code to read sensor data, perform calculations (e.g., energy consumption), and log data to the MicroSD card for later analysis.
Calibration and Testing Details Description
Sensor Calibration
Voltage Sensor Calibration Calibrate the ZMPT101B voltage sensor module by applying a known voltage to the inputs and adjusting the offset and gain values in software.
System Testing Verify that the system accurately measures energy consumption, logs data correctly, and transmits data wirelessly using Wi-Fi.