Peacefair PZEM-004T Energy Monitor

Note

This page is incomplete and could use some work. If you want to contribute, please read the contributing guide. This page is missing:

  • An image for the front page.

  • Images/screenshots/example configs of this device being used in action.

The pzem004t sensor platform allows you to use PZEM-004 (version with 8-segment screens, website) and PZEM-004T V1 energy monitors (website) sensors with ESPHome.

Warning

This page refers to version V1 of the PZEM-004T, which has been out of stock for a while. The PZEM-004, however, is still working (and selling) with this protocol and does not use modbus. For using the newer V3 variant of this sensor please see pzemac.

The communication with this component is done via a UART. You must therefore have a uart: entry in your configuration with both the TX and RX pins set to some pins on your board and the baud rate set to 9600.

# Example configuration entry
uart:
  tx_pin: D1
  rx_pin: D2
  baud_rate: 9600

sensor:
  - platform: pzem004t
    current:
      name: "PZEM-004T Current"
    voltage:
      name: "PZEM-004T Voltage"
    power:
      name: "PZEM-004T Power"
    energy:
      name: "PZEM-004T Energy"
    update_interval: 60s

Configuration variables:

  • current (Optional): Use the current value of the sensor in amperes. All options from Sensor.

  • power (Optional): Use the (active) power value of the sensor in watts. All options from Sensor.

  • voltage (Optional): Use the voltage value of the sensor in volts. All options from Sensor.

  • update_interval (Optional, Time): The interval to check the sensor. Defaults to 60s.

  • uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses.

Hardware considerations:

These devices have optocouplers on the UART port and the resistors mounted on the board have been designed to work with 5V devices. ESPs need a Level Shifter to be compatible with TTL levels.

Note

You need a IC level shifter and not a Mosfet-based level shifter, because you need to power the optocoupler’s LEDs without an additional resistor in the path.

If prefer, you could change the value of the optocoupler’s resistors by following this or this guide.

Your ESP shall be powered by an external power supply and cannot be connected to the PZEM for power.

See Also