Table of Contents
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}
Calibration
Per Theo - As the PZEM is a dedicated energy monitor, device calibration in TASMOTA is currently not supported.
Wiki has moved to link on the left.