ESP8266-PZEM004T
ESP8266-PZEM004T copied to clipboard
A WiFi enabled PowerMeter for AC Voltage, Current and Power. Implementing a nice looking Web-Interface, a RESTful API, OpenHAB 1 & 2 Callbacks and a MQTT client.
ESP8266-PZEM004T
A WiFi enabled PowerMeter for AC Voltage, Current and Power. Implementing a nice looking Web-Interface, a RESTful API, OpenHAB 1 & 2 Callbacks and a MQTT client.

Precompiled Firmware
Find the precompiled firmware in the firmware directory.
Compile
This is a PlatformIO project.
Firmware Reset
- Power on the PowerMeter (plug in)
- Press down and hold the Button during the first 5s
- Release Button when the WiFi LED starts rapidly fast blinking
- The firmware reset ends after about 30s indicated by a permanent WiFi LED on.
Default Settings
After a firmware reset the following values are set.
| value | description | |
|---|---|---|
| WiFi SSID | PowerMeter-esp id |
SSID in accesspoint mode |
| IP Address | 192.168.192.1 | ip address in accesspoint mode |
| Admin password | admin | Setup admin password |
| OTA Hostname | wifi-socket-1 | Over The Air hostname |
| OTA Password | otapass | OTA firmware upload password |
| OpenHAB Callback Enabled | false | |
| OpenHAB Version | 1 | Callback for OpenHAB version 1 or 2 |
| OpenHAB Item Voltage | PowerMeter1Voltage | |
| OpenHAB Item Current | PowerMeter1Current | |
| OpenHAB Item Power | PowerMeter1Power | |
| OpenHAB Host | 192.168.1.1 | |
| OpenHAB Port | 80 | |
| OpenHAB Use Authentication | false | |
| OpenHAB User | user | |
| OpenHAB Password | password | |
| OpenHAB SendingInterval | 60 | interval time in seconds |
| MQTT Enabled | false | |
| MQTT ClientId | PowerMeter1 | |
| MQTT Host | 192.168.1.1 | |
| MQTT Port | 80 | |
| MQTT Use Authentication | false | |
| MQTT User | user | |
| MQTT Password | password | |
| MQTT Topic Voltage | powermeter1/voltage | |
| MQTT Topic Current | powermeter1/current | |
| MQTT Topic Power | powermeter1/power | |
| MQTT Topic JSON | powermeter1/json | sending all values in JSON format |
| MQTT Sending Interval | 60 | interval time in seconds |
Hardware
| hardware | description | pins |
|---|---|---|
| ESP8266 Mainboard | WEMOS D1 mini lite | |
| OLED Display | WEMOS OLED Shield | D1 (SCL,GPIO5), D2 (SDA,GPIO4) |
| AC Digital Multifunction Meter | PZEM004T Module | D5 (RX,GPIO14), D6 (TX,GPIO12) |
| WiFi LED | LED + 150Ω Resistor | D0 (GPIO16) |
| Button | Touch button | D7 (GPIO13) |
References
- PlatformIO
- Arduino core for ESP8266 WiFi chip
- Async TCP Library for ESP8266
- Async Web Server for ESP8266 and ESP32
- Arduino-pubsubclient - A client library for the ESP8266 that provides support for MQTT
- Pure.CSS - A nice CSS, as GZIP it is less than 4k so it is useful for embedded devices
- ESP8266 OLED SSD1306 with 64x48 support