How to use PZEM004T Energy Monitor with esphome

Hello,

can pzem-004t.v3 with 100A coil be used to monitor whole house energy usage? I have main fuse 70A so it is less than 100A. If so why all diagrams shows coil installed on NEUTRAL rather than of LIVE?

I canā€™t see why not.

What diagrams?

100% can be used. Coil can be used on neutral or on live wire, there is no difference. Donā€™t know why most schematics of pzem connections report it on neutral, but you can use it also on live wire.
If you have to buy Pzem i suggest you to buy pzem-016 because it has internal 5V power supply that you can use to power your esphome device (however a little mod is needed).

Dead right, current in = current out (basic law of electrical engineering).

thanks gt4020 and nickrout. I have completed my project and attached coil to the live wire. @nickrout diagrams from https://innovatorsguru.com/pzem-004t-v3/ shows coil on neutral but as you guys explained that doesnā€™t meters.

One more question. Coil that comes with pzem has very short cable. Can I extend this cable a little bit? I am wandering if that will have an negative effect on true readings.

1 Like

Yes, you can extend wires. Is a low impedance device so it is wires lenght not very sensible.

1 Like

Hello,

Today I got the issue for my EPS8266 and Pzem 004T v3, The hass is showing connected but the values showing ā€œUnknowā€

Here is my config:

uart:
  tx_pin: TX
  rx_pin: RX 
  baud_rate: 9600
  stop_bits: 2

sensor:
  - platform: pzemac
    current:
      name: "PZEM-004T V3 Current"
    voltage:
      name: "PZEM-004T V3 Voltage"
    power:
      name: "PZEM-004T V3 Power"
    frequency:
      name: "PZEM-004T V3 Frequency"
    power_factor:
      name: "PZEM-004T V3 Power Factor"
    update_interval: 1s

And the show log information:

I also tried with:
tx_pin: D1
rx_pin: D2
and also used the pin RX->D1, TX-> D2 but no luck

What should I do? Thanks

Wait a bit longer?

Thanks for your message :slight_smile:
here is the log:

INFO Reading configuration /config/esphome/espmeter.yaml...
INFO Starting log output from 192.168.31.111 using esphome API
INFO Connecting to 192.168.31.111:6053 (192.168.31.111)
INFO Successfully connected to 192.168.31.111
[12:01:00][I][app:100]: ESPHome version 1.14.4 compiled on Sep 21 2020, 11:39:03
[12:01:00][C][wifi:415]: WiFi:
[12:01:00][C][wifi:283]:   SSID: [redacted]
[12:01:00][C][wifi:284]:   IP Address: 192.168.31.111
[12:01:00][C][wifi:286]:   BSSID: [redacted]
[12:01:00][C][wifi:287]:   Hostname: 'espmeter'
[12:01:00][C][wifi:291]:   Signal strength: -53 dB ā–‚ā–„ā–†ā–ˆ
[12:01:00][V][wifi:293]:   Priority: 0.0
[12:01:00][C][wifi:295]:   Channel: 8
[12:01:00][C][wifi:296]:   Subnet: 255.255.255.0
[12:01:00][C][wifi:297]:   Gateway: 192.168.31.1
[12:01:00][C][wifi:298]:   DNS1: (IP unset)
[12:01:00][C][wifi:299]:   DNS2: (IP unset)
[12:01:01][C][uart:140]: UART Bus:
[12:01:01][C][uart:142]:   TX Pin: GPIO1
[12:01:01][C][uart:145]:   RX Pin: GPIO3
[12:01:01][C][uart:147]:   Baud Rate: 9600 baud
[12:01:01][C][uart:148]:   Stop bits: 1
[12:01:01][C][uart:150]:   Using hardware serial interface.
[12:01:01][W][uart:379]:   You're using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.
[12:01:01][C][modbus:096]: Modbus:
[12:01:01][E][uart:391]:   Invalid stop bits: Integration requested stop_bits 2 but you have 1!
[12:01:01][C][logger:175]: Logger:
[12:01:01][C][logger:176]:   Level: VERBOSE
[12:01:02][C][logger:177]:   Log Baud Rate: 115200
[12:01:02][C][logger:178]:   Hardware UART: UART0
[12:01:02][C][logger:180]:   Level for 'mqtt.component': DEBUG
[12:01:02][C][logger:180]:   Level for 'mqtt.client': ERROR
[12:01:02][C][pzemac:061]: PZEMAC:
[12:01:02][C][pzemac:062]:   Address: 0x01
[12:01:02][C][pzemac:063]: Voltage 'PZEM-004T V3 Voltage'
[12:01:02][C][pzemac:063]:   Unit of Measurement: 'V'
[12:01:02][C][pzemac:063]:   Accuracy Decimals: 1
[12:01:02][C][pzemac:063]:   Icon: 'mdi:flash'
[12:01:02][C][pzemac:064]: Current 'PZEM-004T V3 Current'
[12:01:03][C][pzemac:064]:   Unit of Measurement: 'A'
[12:01:03][C][pzemac:064]:   Accuracy Decimals: 3
[12:01:03][C][pzemac:064]:   Icon: 'mdi:current-ac'
[12:01:03][C][pzemac:065]: Power 'PZEM-004T V3 Power'
[12:01:03][C][pzemac:065]:   Unit of Measurement: 'W'
[12:01:03][C][pzemac:065]:   Accuracy Decimals: 1
[12:01:04][C][pzemac:065]:   Icon: 'mdi:power'
[12:01:04][C][pzemac:066]: Frequency 'PZEM-004T V3 Frequency'
[12:01:04][C][pzemac:066]:   Unit of Measurement: 'hz'
[12:01:04][C][pzemac:066]:   Accuracy Decimals: 1
[12:01:04][C][pzemac:066]:   Icon: 'mdi:current-ac'
[12:01:04][C][pzemac:067]: Power Factor 'PZEM-004T V3 Power Factor'
[12:01:04][C][pzemac:067]:   Unit of Measurement: ''
[12:01:04][C][pzemac:067]:   Accuracy Decimals: 2
[12:01:04][C][pzemac:067]:   Icon: 'mdi:flash'
[12:01:04][C][captive_portal:169]: Captive Portal:
[12:01:04][C][web_server:123]: Web Server:
[12:01:04][C][web_server:124]:   Address: 192.168.31.111:80
[12:01:04][C][ota:029]: Over-The-Air Updates:
[12:01:05][C][ota:030]:   Address: 192.168.31.111:8266
[12:01:05][C][api:095]: API Server:
[12:01:05][C][api:096]:   Address: 192.168.31.111:6053
[12:01:05][C][mqtt:051]: MQTT:
[12:01:05][C][mqtt:053]:   Server Address: 192.168.31.5:1883 (192.168.31.5)
[12:01:05][C][mqtt:054]:   Username: [redacted]
[12:01:05][C][mqtt:055]:   Client ID: [redacted]
[12:01:05][C][mqtt:057]:   Discovery prefix: 'homeassistant'
[12:01:05][C][mqtt:058]:   Discovery retain: YES
[12:01:05][C][mqtt:060]:   Topic Prefix: 'espmeter'
[12:01:06][C][mqtt:062]:   Log Topic: 'espmeter'
[12:01:06][C][mqtt:065]:   Availability: 'espmeter/status'
[12:01:06][C][mqtt.sensor:024]: MQTT Sensor 'PZEM-004T V3 Voltage':
[12:01:06][C][mqtt.sensor:028]:   State Topic: 'espmeter/sensor/pzem-004t_v3_voltage/state'
[12:01:06][C][mqtt.sensor:024]: MQTT Sensor 'PZEM-004T V3 Current':
[12:01:06][C][mqtt.sensor:028]:   State Topic: 'espmeter/sensor/pzem-004t_v3_current/state'
[12:01:06][C][mqtt.sensor:024]: MQTT Sensor 'PZEM-004T V3 Power':
[12:01:07][C][mqtt.sensor:028]:   State Topic: 'espmeter/sensor/pzem-004t_v3_power/state'
[12:01:07][C][mqtt.sensor:024]: MQTT Sensor 'PZEM-004T V3 Frequency':
[12:01:07][C][mqtt.sensor:028]:   State Topic: 'espmeter/sensor/pzem-004t_v3_frequency/state'
[12:01:07][C][mqtt.sensor:024]: MQTT Sensor 'PZEM-004T V3 Power Factor':
[12:01:07][C][mqtt.sensor:028]:   State Topic: 'espmeter/sensor/pzem-004t_v3_power_factor/state'

I made it works after switch to Tasmota. Thanks

Hi, itā€™s too late but for next users :

Make sure the device is connected to the AC power! The 5V only power the optocouplers, not the actual chip !!!

You can use this library to test your PZEM-004T with arduino or ESP8266/Wemos D1 :

This one is great because it is simple : no tweaking to to except set the 2 serial pins, for example :

  • Pin D5 Rx (Connects to the Tx pin on the PZEM)
  • Pin D6 Tx (Connects to the Rx pin on the PZEM)
    It should work immediately even if you put AC power after ESP8266 boot.

Once itā€™s working, switch to ESPhome. The docmentation specify to put ā€œstop_bits: 2ā€ for the PZEM-004T V3 but it was false in my caseā€¦

My working config:

uart:
  rx_pin: D5
  tx_pin: D6
  baud_rate: 9600


sensor:
  - platform: pzemac
    current:
      name: "PZEM-004T V3 Current"
    voltage:
      name: "PZEM-004T V3 Voltage"
    energy:
      name: "PZEM-004T V3 Energy"
    power:
      name: "PZEM-004T V3 Power"
    frequency:
      name: "PZEM-004T V3 Frequency"
    power_factor:
      name: "PZEM-004T V3 Power Factor"
    update_interval: 2s

Can you share more info about getting 5V supply also any difference in accuracy compared to 004T V3 ?

hello, is there a way to reset the pzem energy counter (esphome)?
For exemple with an automationā€¦
Thanks


#FAST SENSORS FOR ENERGY CALCULATION & LOCAL DISPLAY
  - platform: pzemac
    current:
      name: "PZEM-016 Current"
      id: aac
      internal: true
    voltage:
      name: "PZEM-016 Voltage"
      id: vac
      internal: true
    power:
      name: "PZEM-016 Power"
      id: w
      internal: true
    frequency:
      name: "PZEM-016 Frequency"
      id: f
      internal: true
    power_factor:
      name: "PZEM-016 Power Factor"
      id: pf
      internal: true
    update_interval: 2s

  - platform: total_daily_energy
    name: "PZEM-016 Daily Energy"
    power_id: w 
    filters:
        # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh
    icon: mdi:counter
    accuracy_decimals: 1   


#SLOW SENSORS FOR HOME ASSISTANT
  - platform: template #########################
    name: "PZEM-016 Current Slow"
    lambda: |-
      if (id(aac).state) {
        return (id(aac).state);
      } else {
        return 0;
      }
    unit_of_measurement: A
    icon: "mdi:alpha-a-circle"
    update_interval: 10s
  
  - platform: template #########################
    name: "PZEM-016 Voltage Slow"
    lambda: |-
      if (id(vac).state) {
        return (id(vac).state);
      } else {
        return 0;
      }
    unit_of_measurement: V
    icon: "mdi:alpha-v-circle"
    update_interval: 10s
  
  - platform: template #########################
    name: "PZEM-016 Power Slow"
    lambda: |-
      if (id(w).state) {
        return (id(w).state);
      } else {
        return 0;
      }
    unit_of_measurement: W 
    icon: "mdi:alpha-w-circle"
    update_interval: 10s
  
  - platform: template #########################
    name: "PZEM-016 Frequency Slow"
    lambda: |-
      if (id(f).state) {
        return (id(f).state);
      } else {
        return 0;
      }
    unit_of_measurement: Hz
    icon: "mdi:alpha-f-circle"
    update_interval: 10s

  - platform: template #########################
    name: "PZEM-016 Power Factor Slow"
    lambda: |-
      if (id(pf).state) {
        return (id(pf).state);
      } else {
        return 0;
      }
    unit_of_measurement: PF
    icon: "mdi:alpha-p-circle"
    update_interval: 10s

@sendorm
Can you please show my how you have wired those 3?

Iā€™m going to make a 3 phase and another 3phase to monitor my solar installation.

also interested in the way to reset it.

You will nee to wire them via an rs485 to TTL converted. as the PZEM talks RS485 and EPS talks UART.

something like this you will need to place between the ESP and the PZEM:
https://www.amazon.de/-/nl/gp/product/B07RKY1G71

You have to use this: 68074678-0dd16e80-fd9e-11e9-8d80-5650e9e18fb8

I only had success with v3 of pzems. Also the diodeā€™s should be schottky.

1 Like

And this is my setup, I am using a 5volt dc source.

image

Can you please give me a link to the diodes you have used?

I have used bat45.

This is the source if anyone wonders.