Whole Home Energy Monitoring based on PZEM-004T V3

Peacefair PZEM-004T Version 3.0

The PZEM-004T V3 is a single phase AC power monitoring module that supports measurement of 80-260 V voltage, 100 A max current, frequency and power factor (datasheet), it talks Modbus protocol on RS-485 serial.

I bought one off AliExpress for a total of €8.17 with free shipping, including a noninvasive current measuring transformer sensor (which is usually called a CT clamp) for ease of installation:

pzem

Hardware

The circuit is very simple. Since the PZEM uses a passive serial port thus requires an external +5V supply, for convenience, a WeMos D1 mini module which has a built-in USB 5V to 3.3V power supply circuit was chosen, instead of a bare ESP-12F.

An additional logic level shifter is required to convert the 5V TTL of the PZEM to the 3.3V accepted by the ESP.

schematic

Completed circuit board, PZEM and voltage probe (just a standard plug):

The relay on the circuit board is prepared for controlling the building gate in a future project

overview

Install the current probe

⚡ DANGER! ELECTRICAL HAZARD ⚡

You probably need to extend the current probe's cable first.

Remove the breaker panel, find the main live or neutral wire (usually the thickest, and goes into the main breaker), clamp the current probe on it:

ct-clamp-installed

Put back the panel and lead the probe cable out from a hole:

breaker-box

Connect the voltage and current probes to the PZEM module respectively according to the instructions printed on its enclosure, then connect power to the ESP module and it's done:

done

Software

Example ESPHome configuration:

esphome:
  name: energy-meter
  comment: 'PZEM-004T Energy Meter'

esp8266:
  board: d1_mini

logger:
  level: WARN
#  baud_rate: 115200

wifi:
  fast_connect: true
  networks:
    - ssid: !secret wifi_ssid
      bssid: !secret wifi_bssid
      password: !secret wifi_password

api:
ota:
  password: !secret energy_meter_ota_password

uart:  # enable a software UART
  tx_pin: 4
  rx_pin: 5
  baud_rate: 9600
modbus:  # enable Modbus

sensor:
  - platform: pzemac
    address: 1  # specify the PZEM Modbus custom address, this is useful when there is multiple PZEM connected
    current:
      name: 'Current'
    voltage:
      name: 'Voltage'
    energy:
      name: 'Energy'
      # convert it to kWh
      filters:
        - multiply: 0.001
      unit_of_measurement: 'kWh'
      accuracy_decimals: 3
    power:
      name: 'Power'
    frequency:
      name: 'Frequency'
    power_factor:
      name: 'Power Factor'
    update_interval: 30s

Now you can add it to HASS and select sensor.energy as the Energy platform data source.

hass-energy

If you would like to add a glance card to your lovelace dashboard, configure two utility_meter sensors first:

energy_monthly:
  source: sensor.energy
  cycle: monthly
energy_daily:
  source: sensor.energy
  cycle: daily

lovelace glance card:

lovelace-glance-card

type: glance
title: Energy Consumption
show_icon: true
show_state: true
state_color: false
entities:
  - entity: sensor.power
  - entity: sensor.energy_daily
    name: Daily
  - entity: sensor.energy_monthly
    name: Monthly

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.