This project reads electrical parameters (voltage, current, power, energy, frequency, power factor) from the PZEM-016 Modbus energy meter using an ESP32 over RS-485.
- ESP32 Development Board
- PZEM-016 Energy Meter
- RS-485 to TTL converter (e.g., MAX485)
- Jumper wires
- Power supply for the ESP32 and PZEM
| ESP32 Pin | MAX485 Pin | Description |
|---|---|---|
| GPIO 16 | RO | UART RX (Receive) |
| GPIO 17 | DI | UART TX (Transmit) |
| GPIO 4 | DE & RE | Data Direction Control (HIGH = TX, LOW = RX) |
| GND | GND | Common Ground |
| 3.3V/5V | VCC | Power (as per module rating) |
PZEM-016 is connected to the RS-485 A/B terminals of the MAX485 module.
- Sends Modbus RTU query
0x01 0x04 0x00 0x00 0x00 0x0A 0x70 0x0Dto the meter. - Receives and decodes 25-byte Modbus response.
- Parses and displays:
- Voltage (V)
- Current (A)
- Active Power (W)
- Energy (Wh)
- Frequency (Hz)
- Power Factor
- The ESP32 sends the query every 5 seconds via UART2.
- The MAX485 handles the RS-485 communication protocol.
- The DE/RE pin toggles transmit/receive mode.
- The incoming Modbus response is parsed and displayed over the serial monitor.
- Connect the hardware as per wiring table.
- Upload the
main.inosketch using Arduino IDE or PlatformIO. - Open the Serial Monitor at 115200 baud.
- Readings will appear every 5 seconds.
- Default Modbus address is
0x01. - Communication baud rate is
9600. - PZEM-016 requires external AC input to function.
- Be sure DE and RE pins are controlled together.
This project is open-source under the MIT License.