Skip to content

PZEM-0xx power monitor~

PZEM is a dedicated separate energy monitor, device calibration in Tasmota is not supported.

PZEM-004~

The PZEM-004T together with a Sonoff Basic provide a good clamp on energy monitor.

Parts needed~

  • Sonoff Basic
  • PZEM-004T
  • Resistor 1k
  • Enclosure
  • Power cable

Preparation~

Install Tasmota on the Sonoff Basic and confirm it is functional before connecting the PZEM-004T to its serial interface.

Hardware connections~

As the PZEM-004T expects 5V serial data and the Sonoff Basic only provides up to 3V3, the expected optocoupler input power of the PZEM-004T has to be reduced. This can be accomplished by soldering a 1k resistor between the joints shown below (modification works for version v.1.0 and v.3.0).

PZEM-004T v.1.0

PZEM-004T v.3.0

Connect the serial interface of the Sonoff Basic with the serial interface of the PZEM-004T. See pictures regarding used colors and connections.

  • 3V3/5V Red
  • Rx Yellow
  • Tx Green
  • Gnd Grey

(Image re-used from https://www.instructables.com/id/Use-Homie-Firmware-to-Drive-Sonoff-Switch-Module-E/ Thanks @amayii0)

As the PZEM004T is functioning better on 5V, it can be obtained from the Voltage regulator as shown in this image.

Cut the power cable in two and connect the input wires to both Sonoff Basic and PZEM-004T. Route one of the power output wires through the PZEM-004T core and connect the output wires to the Sonoff Basic output.

As most parts are connected to high voltage AC it is recommended to fit the hardware in a solid enclosure.

Software configuration~

Configure the GPIO's for hardware serial connection as shown below.

IMPORTANT: If using the connections as following, the communication works in all cores due to TASMOTA using hardware serial. If the user wants to use other GPIOs for communication, TASMOTA will emulate a serial interface using software serial. This feature does not work using core 2.3.0 due to insufficient RAM. To use the software serial feature, you must use a core version of 2.4.2 or greater.

Device Template
PZEM-004T version prior to V3:

{"NAME":"HW-655 PZEM","GPIO":[0,62,0,63,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

PZEM-004T version V3~

{"NAME":"HW-655 PZEM","GPIO":[0,62,0,98,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}


The PZEM-004T together with a HW-655 Relay provide a good clamp-on energy monitor for a 240V clothes dryer.

Parts needed~

Preparation~

Install Tasmota on the ESP-01 and confirm it is functional before connecting the PZEM-004T to its serial interface. Use of pins other that the default hardware serial GPIO (01 & 03) in order for TASMOTA to emulate a serial interface using software serial.

Hardware connections~


Connect the serial interface of the HW-655 with the serial interface of the PZEM-004T.


As most parts are connected to high voltage AC it is recommended to fit the hardware in a solid enclosure.


Software configuration~

Device Template
PZEM-004T version prior to V3:

{"NAME":"HW-655 PZEM","GPIO":[0,63,0,62,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}

PZEM-004T version V3~

{"NAME":"HW-655 PZEM","GPIO":[0,98,0,62,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}

Use the module template to configure the GPIO's for hardware serial connection.

IMPORTANT: If using the connections as following, the communication works in all cores due to TASMOTA using hardware serial. If the user wants to use other GPIOs for communication, TASMOTA will emulate a serial interface using software serial. This feature does not work using core 2.3.0 due to insufficient RAM. To use the software serial feature, you must use a core version of 2.4.2 or greater.

Connected Power Meter using PZEM-004T, Wemos D1 Mini and a 1602 I2C display~

Parts needed~

  • Wemos D1 Mini
  • PZEM-004T
  • 1kOhm Resistor (optional - see alternate wiring)
  • Enclosure
  • 5V buck converter power supply (search for "700ma 3.5w 5v" on usual stores...)
  • I2C 1602 LCD Display (I had issues with green one, I2C address 0x3F, while no problems with blue ones, address 0x27)
  • Mains Power cable
  • Mammuth Clamps

Preparation~

You need to compile your own Tasmota firmware as none of the pre-compiled binaries have support for display and PZEM module.

Set up your preferred IDE as described in wiki

Enable IDE to Use Custom Settings

Create user_config_override.h in the tasmota folder and paste the contents of this sample configuration file.

PlatformIO

  • Rename platformio_override_sample.ini. to platformio_override.ini
  • Enter platformio run -e <variant-name>
    Examples:
  • platformio run -e tasmota-sensors
  • platformio run -e tasmota-DE

Arduino IDE

  • Edit my_user_config.h. Uncomment the statement by removing the "//" in front of the line: #define USE_CONFIG_OVERRIDE
  • Click compile

Flash the binary on the Wemos D1 Mini and confirm it is functional before connecting the PZEM-004T to its serial interface.

Tasmota Parameter Configuration~

Device Template
PZEM-004T version prior to V3:

{"NAME":"HW-655 PZEM","GPIO":[0,63,0,62,6,5,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}

PZEM-004T version V3~

{"NAME":"HW-655 PZEM","GPIO":[0,98,0,62,6,5,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}

  • use I2CScan to detect your device address
  • use DeviceAddress XXX (where XXX is the decimal converted address found) to set the I2C address
  • set TelePeriod 10 to have the display refresh every 10 seconds (you can't go under this value)
  • set DisplayModel 1, and DisplayMode 0
  • finally, add a Rule to display values (I choose these):
Rule1 ON Tele-ENERGY#Power DO DisplayText [z] [x1y0]%value%W ENDON ON Tele-ENERGY#Today DO DisplayText [x8y0]%value%Wh ENDON ON Tele-ENERGY#Voltage DO DisplayText [x1y1]%value%V ENDON ON Tele-ENERGY#Current DO DisplayText [x8y1]%value%A ENDON
  • remember to enable the rule, with Rule1 1

Images and Wiring diagram~

DANGER - MAINS VOLTAGE. Be sure to crimp connectors and use heat-shrinking tube wherever possible/needed, and tightly secure any screw.



How it looks, from web GUI:



How it looks, from enclosure:

You can set the contrast using the little trimmer/pot on back of the display. I cut a bit of the corners from the display to have it flush with border, and used two hexagonal plastic standoffs with nuts and bolts to secure it to transparent top.

Mains IN, mains OUT, all sealed:



Wiring Diagram: * Check images below for more information about the 1kOhm resistor needed to shift the voltage to 5V from 3V3 for the PZEM-004T serial connection.

PZEM-004T v.1.0

PZEM-004T v.3.0

Calibration~

Per Theo - As the PZEM is a dedicated energy monitor, device calibration in TASMOTA is currently not supported.

PZEM-016~

⚠️ ⚠️ ⚠️
DO NOT PERFORM THIS MODIFICATION WITHOUT REMOVING POWER FROM THE PZEM FIRST!
⚠️ ⚠️ ⚠️

Note: the PZEM-016 TTL output is at 5V signal levels. There are varying schools of thought on whether the ESP82xx has 5V tolerant GPIO. You may want to use a level shifter for the serial communications signals to bring them to the recommended 3.3V.

PZEM-016 modules can be converted from RS485 to TTL serial level devices by simply removing the internal MAX485 chip and adding two internal jumper wires. This will bring the serial port connections out via the four-pin terminal block. Pin A is now TTL serial out (Tx) and pin B TTL serial in (Rx). The modification retains the optical isolation used by the PZEM for safety to ensure no high voltages on the outputs.

You can use a voltage level shifter to power the ESP82xx from the PZEM-016 module's 5V power. This may also require a 470uf 35V capacitor across the 5V line to work reliably.

Tasmota Configuration~

It is recommended to use GPIO1/GPIO3 or GPIO13/GPIO15 for the most reliable serial communications. You can use any GPIO but anything else will use serial emulation (software). Software serial is not supported with the 2.3 Arduino Core.

GPIO Component PZEM
1 PZEM0XX Tx (62) Pin B
3 PZEM016 Rx (98) Pin A