0 PZEM004T, Wemos D1 Mini and a 1602 I2C display
blakadder edited this page 2019-11-01 19:05:09 +01:00

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 sonoff folder and paste the contents of this sample configuration file.

PlatformIO

  • Edit platformio.ini. Uncomment the statement by removing the ";" in front of the line:
    -DUSE_CONFIG_OVERRIDE
  • Enter platformio run -e <variant-name>
    Examples:
    • platformio run -e sonoff-sensors
    • platformio run -e sonoff-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.