PZEM004T, Wemos D1 Mini and a 1602 I2C display - FengtianGu/Sonoff-Tasmota GitHub Wiki
- 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
You need to compile your own Tasmota firmware, as none of the pre-compiled binaries have support for both displays and the PZEM sensor module. To compile, edit these files:
-
sonoff_post.h: look for the line starting with
#ifdef USE_DISPLAYS
and comment out the#undef USE_ENERGY_SENSOR
that follows near there, so it should be like:
//#undef USE_ENERGY_SENSOR
-
user_config_override.h: before last
#endif
, add this line
#define USE_DISPLAYS
-
my_user_config.h: uncomment line with "
//#define USE_CONFIG_OVERRIDE
" so it's like:
#define USE_CONFIG_OVERRIDE
Flash the binary on the Wemos D1 Mini and confirm it is functional before connecting the PZEM-004T to its serial interface.
- set module as GENERIC (18), then GPIOs as in the image below:
- 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
, andDisplayMode 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
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.
- ALTERNATIVE: No modification required on the PZEM-004T. Rather than using the 3.3V output from the Wemos D1 Mini to power the PZEM-004T serial interface, use the same 5V buck converter output (also used to supply power to the display and the Wemos D1 Mini) as VDD on the PZEM-004T serial interface. This eliminates the need for the resistor and the need to modify the PZEM-004T in any way at all.
Per Theo - As the PZEM is a dedicated energy monitor, device calibration in TASMOTA is currently not supported.