Support for PZEM 004T Energy monitor
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 13
- Joined: 22 Feb 2017, 15:07
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
Is it possible to have this FW for 1mb ROM?
-
- New user
- Posts: 8
- Joined: 09 Jan 2017, 12:35
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
Hi aleph0,
Can you tell me how connect pzem 004t to esp (my is a Wemos D1 mini)?
TX to GPIO 14 and RX to GPIO 12? only that? Directly without any resistance?
Thanks
Can you tell me how connect pzem 004t to esp (my is a Wemos D1 mini)?
TX to GPIO 14 and RX to GPIO 12? only that? Directly without any resistance?
Thanks
-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
Re: Support for PZEM 004T Energy monitor
@ruben : yes, I connected them directly without resistor to a wemos d1 mini. Pzem is powered with 5v, I read somewhere the wemos can handle 5v on the gpio pins, I wanted to test. So far it's working fine, but it's only ~20 days of continuous power up. We will see if it last 
@gajotnt : I'll try to compile for 1Mb and tell you what. Will be on weekend !

@gajotnt : I'll try to compile for 1Mb and tell you what. Will be on weekend !
-
- Normal user
- Posts: 13
- Joined: 22 Feb 2017, 15:07
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
Thanksaleph0 wrote: ↑12 Dec 2017, 20:18 @ruben : yes, I connected them directly without resistor to a wemos d1 mini. Pzem is powered with 5v, I read somewhere the wemos can handle 5v on the gpio pins, I wanted to test. So far it's working fine, but it's only ~20 days of continuous power up. We will see if it last
@gajotnt : I'll try to compile for 1Mb and tell you what. Will be on weekend !

@Ruben_Ramos, bom ver um Tuga

-
- New user
- Posts: 8
- Joined: 09 Jan 2017, 12:35
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
I think have something wrong..
Give me values -1

my connections are:

thanks for help
Give me values -1

my connections are:

thanks for help

Last edited by ruben_ramos on 12 Dec 2017, 22:20, edited 2 times in total.
-
- New user
- Posts: 8
- Joined: 09 Jan 2017, 12:35
- Location: Portugal
-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
Re: Support for PZEM 004T Energy monitor
You have inverted the pins on the white connector. Look carefully on the PCB, the pins are identified with numbers and meaningruben_ramos wrote: ↑12 Dec 2017, 22:12 I think have something wrong..
Give me values -1
my connections are:
thanks for help![]()
-
- New user
- Posts: 8
- Joined: 09 Jan 2017, 12:35
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
i have noticed that, and changed, but without success.. continue the same, give me -1.
How to know if pzem its working good? or its damaged?
How to know if pzem its working good? or its damaged?
-
- New user
- Posts: 5
- Joined: 17 Dec 2017, 19:45
Re: Support for PZEM 004T Energy monitor
Hello,
I have a wemos connected to a pzem running a few months ago, this sends the information to a PC with domoticz who keeps track of these variables.
I have a wemos connected to a pzem running a few months ago, this sends the information to a PC with domoticz who keeps track of these variables.
You do not have the required permissions to view the files attached to this post.
-
- New user
- Posts: 8
- Joined: 09 Jan 2017, 12:35
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
giruchile can you show how you had connected pzem to wemos?
-
- New user
- Posts: 5
- Joined: 17 Dec 2017, 19:45
Re: Support for PZEM 004T Energy monitor
Hello,
for the connection I did it directly, but with 3.3v and I put a resistance in parallel within the pzem, the idea is that the optocoupler is running with 3.3v and not with 5v as it comes originally.
Now I'm not at home, I can barely get a picture of the change I made.
for the connection I did it directly, but with 3.3v and I put a resistance in parallel within the pzem, the idea is that the optocoupler is running with 3.3v and not with 5v as it comes originally.
Now I'm not at home, I can barely get a picture of the change I made.
-
- New user
- Posts: 8
- Joined: 09 Jan 2017, 12:35
- Location: Portugal
Re: Support for PZEM 004T Energy monitor
I appreciate that!
Thanks,
Thanks,
-
- New user
- Posts: 5
- Joined: 17 Dec 2017, 19:45
Re: Support for PZEM 004T Energy monitor
You do not have the required permissions to view the files attached to this post.
-
- Normal user
- Posts: 10
- Joined: 26 Jun 2017, 12:25
Re: Support for PZEM 004T Energy monitor
Hi. giruchile, could you put the compiled firmware with the plugin PZET-004 ?
-
- Normal user
- Posts: 497
- Joined: 04 Oct 2016, 23:16
Re: Support for PZEM 004T Energy monitor
It seems the plugin of giruchile is a different one from the oen I uploaded to the GitHub; it would be great to keep just one plugin per device to avoid duplication and confusion...
I don't mind even to remove mine if the other is better but I'd like as I wrote to make sure users won't get confused with this...
I don't mind even to remove mine if the other is better but I'd like as I wrote to make sure users won't get confused with this...
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
-
- New user
- Posts: 5
- Joined: 17 Dec 2017, 19:45
Re: Support for PZEM 004T Energy monitor
I actually copied codes from several sides until it worked. it is a very crude and imperfect programming.
I attach the code I use if someone wants to use it and better if they fix it, use it with espeasy 1.4 and mega espaesy.
_P099_PZEM.ino
in ESPEasy.ino add
I did not put all the values in the same device because I caused problems when integrating it in Domotics
I attach the code I use if someone wants to use it and better if they fix it, use it with espeasy 1.4 and mega espaesy.
_P099_PZEM.ino
Code: Select all
//#######################################################################################################
//#################################### Plugin 099: PZEM-004T ############################################
//#######################################################################################################
#define PLUGIN_099
#define PLUGIN_ID_099 99
#define PLUGIN_NAME_099 "PZEM-004T"
#define PLUGIN_VALUENAME1_099 ""
boolean Plugin_099(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_099;
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
Device[deviceCount].ValueCount = 1;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].FormulaOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_099);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_099));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[4];
options[0] = F("Voltaje");
options[1] = F("Corriente");
options[2] = F("Potencia");
options[3] = F("Energia");
int optionValues[4];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
optionValues[3] = 3;
string += F("<TR><TD>Indicator:<TD><select name='plugin_099'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg("plugin_099");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
success = true;
break;
}
case PLUGIN_READ:
{
float value = 0;
float cont = 0;
switch(Settings.TaskDevicePluginConfig[event->TaskIndex][0])
{
case 0: //Voltaje
{
value = pzem.voltage(ip);
while(value < 0 ){
cont++;
if (cont == 3) {
return success;
}
value = pzem.voltage(ip);
String log = F("PZEM : ERROR LECTURA VOLTAJE");
addLog(LOG_LEVEL_ERROR,log);
}
break;
}
case 1: //Corriente
{
value = pzem.current(ip);
while(value < 0){
cont++;
if (cont == 3) {
return success;
}
value = pzem.current(ip);
String log = F("PZEM : ERROR LECTURA CORRIENTE");
addLog(LOG_LEVEL_ERROR,log);
}
break;
}
case 2: //Potencia
{
value = pzem.power(ip);
while(value < 0){
cont++;
if (cont == 3) {
return success;
}
value = pzem.power(ip);
String log = F("PZEM : ERROR LECTURA POWER");
addLog(LOG_LEVEL_ERROR,log);
}
break;
}
case 3: //Energia
{
value = pzem.energy(ip);
while(value < 0){
cont++;
if (cont == 3) {
return success;
}
value = pzem.energy(ip);
String log = F("PZEM : ERROR LECTURA ENERGIA");
addLog(LOG_LEVEL_ERROR,log);
}
break;
}
}
UserVar[event->BaseVarIndex] = value;
String log = F("PZEM : ");
log += value;
addLog(LOG_LEVEL_INFO,log);
success = true;
break;
}
}
return success;
}
Code: Select all
#include <PZEM004T.h>
-
- New user
- Posts: 7
- Joined: 13 Dec 2017, 14:05
Re: Support for PZEM 004T Energy monitor
hello
no chance for me i tried but still 0...
i tried to plug to D5 and D6 on the wemos D& mini and also D3 and D4 but still the same ...
swap RX and TX done too
Voltage (V):233
Current (A): 0
Power (W): 0
Energy (Wh):45
any help please ?
no chance for me i tried but still 0...
i tried to plug to D5 and D6 on the wemos D& mini and also D3 and D4 but still the same ...
swap RX and TX done too
Voltage (V):233
Current (A): 0
Power (W): 0
Energy (Wh):45
any help please ?
-
- New user
- Posts: 1
- Joined: 12 Jan 2018, 18:44
Re: Support for PZEM 004T Energy monitor
Hola.
Estoy usando el sistema de aleph0, funcionando perfectamente, he conectado la alimentación de 5V. desde el ESP8266, en VIN y GND, en VIN hay 5V,
Hi.
I am using the aleph0 system, working perfectly, I have connected the 5V power. from ESP8266, in VIN and GND, in VIN there are 5V,

Estoy usando el sistema de aleph0, funcionando perfectamente, he conectado la alimentación de 5V. desde el ESP8266, en VIN y GND, en VIN hay 5V,
Hi.
I am using the aleph0 system, working perfectly, I have connected the 5V power. from ESP8266, in VIN and GND, in VIN there are 5V,

-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
Re: Support for PZEM 004T Energy monitor
As you get voltage value, it means the module communicates with the ESP. But you don't get current, thus no power : Check your CT
-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
-
- Normal user
- Posts: 15
- Joined: 14 Jan 2018, 22:55
Re: Support for PZEM 004T Energy monitor
Hi Alepho
I tried to compile using your directions below but I have error that I can't fgure out, could you help me with this please
First I would like to say that I am new to the ESP world and second I am new to compiling of firmware and ... english is not my primary language so please bare with me...
I'm trying to build a firmware that would include the PZEM004T plugin, I installed the Atom environment together with the PlateformIO and I have been able to build the vanilla ESPeasy bin file, not without issues (I had errors with the some IR that I removed from the build to fix) but I got it to build a firmware.
Then, I dowloaded the PZEM004T.io thast i added in the src directory and I also dowloaded the PZEM004.ZIP (containing the librairies, .h files etc) that I put in the lib directory and also download espsoftwareserial-3.2.3 in wich I modified the library.json as you mentionned and tried building a normal 4096 file and I got the following errors:
.pioenvs\normal_ESP8266_4096\lib298\libespsoftwareserial-3.2.3.a(SoftwareSerial.o): In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xd0): multiple definition of `sws_isr_0()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xd4): first defined here
.pioenvs\normal_ESP8266_4096\lib298\libespsoftwareserial-3.2.3.a(SoftwareSerial.o): In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0xe8): multiple definition of `sws_isr_1()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xec): first defined here
.pioenvs\normal_ESP8266_4096\lib298\libespsoftwareserial-3.2.3.a(SoftwareSerial.o): In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x100): multiple definition of `sws_isr_2()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0x104): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\normal_ESP8266_4096\firmware.elf] Error 1
thanks for any help
I tried to compile using your directions below but I have error that I can't fgure out, could you help me with this please
First I would like to say that I am new to the ESP world and second I am new to compiling of firmware and ... english is not my primary language so please bare with me...
I'm trying to build a firmware that would include the PZEM004T plugin, I installed the Atom environment together with the PlateformIO and I have been able to build the vanilla ESPeasy bin file, not without issues (I had errors with the some IR that I removed from the build to fix) but I got it to build a firmware.
Then, I dowloaded the PZEM004T.io thast i added in the src directory and I also dowloaded the PZEM004.ZIP (containing the librairies, .h files etc) that I put in the lib directory and also download espsoftwareserial-3.2.3 in wich I modified the library.json as you mentionned and tried building a normal 4096 file and I got the following errors:
.pioenvs\normal_ESP8266_4096\lib298\libespsoftwareserial-3.2.3.a(SoftwareSerial.o): In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xd0): multiple definition of `sws_isr_0()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xd4): first defined here
.pioenvs\normal_ESP8266_4096\lib298\libespsoftwareserial-3.2.3.a(SoftwareSerial.o): In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0xe8): multiple definition of `sws_isr_1()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xec): first defined here
.pioenvs\normal_ESP8266_4096\lib298\libespsoftwareserial-3.2.3.a(SoftwareSerial.o): In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x100): multiple definition of `sws_isr_2()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0x104): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\normal_ESP8266_4096\firmware.elf] Error 1
thanks for any help
aleph0 wrote: ↑08 Nov 2017, 10:03 Hi, and thanks for making this nice plugin !
As I had to do some searching to finally compile and install it, here is a all-in-one summary of what needs to be done :
1/ Install and configure platform.io according to the instructions here :
https://www.letscontrolit.com/wiki/inde ... Platformio
then
https://www.letscontrolit.com/wiki/inde ... platformio
2/ Download the source tree from here :
https://github.com/letscontrolit/ESPEas ... .0.0-dev12 (or later version as there are being developed
3/ Download the plugin source from here and copy it in the main source
https://github.com/papperone/ESPEasyPlu ... M-004T.ino
4/ Download PZEM004T library from here and copy it in the lib subdirectory of the main source
https://github.com/olehs/PZEM004T
5/ Download SofwareSerial library in version 3.2.3 from here and copy it in the lib subdirectory of the main source
https://github.com/plerup/espsoftwarese ... /tag/3.2.3
6/ Update the library.json file that came from the softwareserial library with the following content :(version was missing and platforms mispelledCode: Select all
{ "name": "EspSoftwareSerial", "version": "3.2.3", "keywords": [ "serial", "io", "softwareserial" ], "description": "Implementation of the Arduino software serial for ESP8266.", "repository": { "type": "git", "url": "https://github.com/plerup/espsoftwareserial" }, "frameworks": "arduino", "platforms": "espressif8266" }
)
After that, I was able to compile espeasy with the plugin and send it to the esp via OTA![]()
-
- Normal user
- Posts: 11
- Joined: 11 Aug 2017, 06:39
Re: Support for PZEM 004T Energy monitor
aleph0 thanks for wonderful work...aleph0 wrote: ↑06 Dec 2017, 13:15Please find attached the version for 4Gb flash with all the "Testing" plugins enabled, including the PZEM-004T with my last modifications to handle two modules. Use "port" to select the module : port 0 for first module and port 1 for second module. Remember each module will take up to 12s to answer in case there is no voltage on the main terminal, so don't poll faster then 15s*the number of modules
Feedback is welcome !
But i need to know more about polling. If main line voltage is available ? what's the update rate ? Every second ? can i ?
-
- Normal user
- Posts: 11
- Joined: 11 Aug 2017, 06:39
Re: Support for PZEM 004T Energy monitor
I have uploaded .bin file to ESP8266 but its not showing any hotspot in wifi search of my laptop.. have anyone tried this Flash ?
-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
Re: Support for PZEM 004T Energy monitor
@asking
When everything goes well, one module answer within 1s. But if you poll faster than 12s/module, your espeasy will crash in case of no measurment voltage.
And, of course I tested the bin file, I uploaded the one I'm using here, it's been up for 50 days now and doing the job fine
When everything goes well, one module answer within 1s. But if you poll faster than 12s/module, your espeasy will crash in case of no measurment voltage.
And, of course I tested the bin file, I uploaded the one I'm using here, it's been up for 50 days now and doing the job fine

-
- Normal user
- Posts: 11
- Joined: 11 Aug 2017, 06:39
Re: Support for PZEM 004T Energy monitor
What's your update rate you're testing?aleph0 wrote: ↑19 Jan 2018, 17:14 @asking
When everything goes well, one module answer within 1s. But if you poll faster than 12s/module, your espeasy will crash in case of no measurment voltage.
And, of course I tested the bin file, I uploaded the one I'm using here, it's been up for 50 days now and doing the job fine![]()
Because if i poll faster than 5 seconds update frequency is not periodic and updates randomely.
Anyways its working great...i am looking for 1 second update rate if possible
-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
Re: Support for PZEM 004T Energy monitor
Yes, it's not that surprising : once in a while a value is not coming, triggering the timeout (1s each) and the retry (3 times). It's been reported the quality of 5v supply have an influence on this.
If you want to be able to poll faster, you need to edit the source code to shorten the timeout and no retry. In that case I advise you keep the error value transmitted (-1) and to manage reading errors in the host instead of in esp
If you want to be able to poll faster, you need to edit the source code to shorten the timeout and no retry. In that case I advise you keep the error value transmitted (-1) and to manage reading errors in the host instead of in esp
-
- Normal user
- Posts: 11
- Joined: 11 Aug 2017, 06:39
Re: Support for PZEM 004T Energy monitor
Okay will try that, thanks for suggesting.
-
- New user
- Posts: 2
- Joined: 24 Jan 2018, 22:57
Re: Support for PZEM 004T Energy monitor
Hello,
I'm new in esp easy,
I've a pzem004 with wemos mini pro and domoticz
I've put P171 of playground
I've tension and current in panel control of my ESP, but 0 for Power and Energy Second problem, in domoticz I've icon pzem with: 0;232,1;0,23;0;0 icon Voltage 232,1 but nothing in the others icons If you have an idear
Great thanks for this plugin
I'm new in esp easy,
I've a pzem004 with wemos mini pro and domoticz
I've put P171 of playground
I've tension and current in panel control of my ESP, but 0 for Power and Energy Second problem, in domoticz I've icon pzem with: 0;232,1;0,23;0;0 icon Voltage 232,1 but nothing in the others icons If you have an idear
Great thanks for this plugin
You do not have the required permissions to view the files attached to this post.
-
- New user
- Posts: 7
- Joined: 13 Dec 2017, 14:05
Re: Support for PZEM 004T Energy monitor
-
- Core team member
- Posts: 9907
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Support for PZEM 004T Energy monitor
Can you draw a schematic on how your module is connected?
The current is measured over a shunt resistor, but if no current passes through this shunt, nothing will be measured.
-
- New user
- Posts: 2
- Joined: 24 Jan 2018, 22:57
Re: Support for PZEM 004T Energy monitor
I've a current charge, in icon pezm1 I've 0.24A
but nothing in Energie and Power
Some idear?
but nothing in Energie and Power
Some idear?
-
- New user
- Posts: 7
- Joined: 13 Dec 2017, 14:05
Re: Support for PZEM 004T Energy monitor
off course :
just like this but gnd and vcc on the wemos d1 mini
i tried D5-D6 and TX-RX -> same issue

just like this but gnd and vcc on the wemos d1 mini
i tried D5-D6 and TX-RX -> same issue

-
- New user
- Posts: 1
- Joined: 16 Feb 2018, 20:41
Re: Support for PZEM 004T Energy monitor
Para los que teneis errores en la lectura, debeis modificar en la libreria espsoftwareserial-3.2.3 , el fichero SoftwareSerial.cpp la siguiente linea:
por esta otra:
For those who have errors in reading, you must modify in the library espsoftwareserial-3.2.3, the SoftwareSerial.cpp file the following line:
for this other:
Code: Select all
unsigned long wait = m_bitTime + m_bitTime/3 - 500;
Code: Select all
unsigned long wait = m_bitTime + m_bitTime/2 - 500;
For those who have errors in reading, you must modify in the library espsoftwareserial-3.2.3, the SoftwareSerial.cpp file the following line:
Code: Select all
unsigned long wait = m_bitTime + m_bitTime / 3 - 500;
for this other:
Code: Select all
unsigned long wait = m_bitTime + m_bitTime / 2 - 500;
-
- New user
- Posts: 5
- Joined: 22 Mar 2018, 08:03
Re: Support for PZEM 004T Energy monitor
Hi,
Please forgive me but I'm new.
I have ESP12 and PZEM004 that I successfully used for one year sending data to ThingSpeak.
Now I have Demoticz system + ESPEasy. And I woudl like to add this energy meter to my system.
I downloaded bin file from:
download/file.php?id=1760
and uploaded to my ESP12.
Everything is OK beside reading of energy meter values, all are -1.
I think everything is OK from HW side but as I can see I have problem with correct settings of RX, TX lines in ESPeasy SW.
According to the doc I should use GPIO1 and GPIO3. But these lines are inactive in ESPeasy SW.
Could you help me in this case?
Please forgive me but I'm new.
I have ESP12 and PZEM004 that I successfully used for one year sending data to ThingSpeak.
Now I have Demoticz system + ESPEasy. And I woudl like to add this energy meter to my system.
I downloaded bin file from:
download/file.php?id=1760
and uploaded to my ESP12.
Everything is OK beside reading of energy meter values, all are -1.
I think everything is OK from HW side but as I can see I have problem with correct settings of RX, TX lines in ESPeasy SW.
According to the doc I should use GPIO1 and GPIO3. But these lines are inactive in ESPeasy SW.
Could you help me in this case?
-
- New user
- Posts: 5
- Joined: 22 Mar 2018, 08:03
Re: Support for PZEM 004T Energy monitor
Could you help me in this case?
-
- New user
- Posts: 5
- Joined: 22 Mar 2018, 08:03
Re: Support for PZEM 004T Energy monitor
Hi,
Problem solved. Works grate!!! The problem was that my PCB was configured for use UART0 (GPIO1..3).
When I changed do 13-15 everything is OK.
But I wonder why the Voltage measurement is such unstalble ( I get -1 in most readings).
Any ideas? Update rate is 1min
Problem solved. Works grate!!! The problem was that my PCB was configured for use UART0 (GPIO1..3).
When I changed do 13-15 everything is OK.
But I wonder why the Voltage measurement is such unstalble ( I get -1 in most readings).
Any ideas? Update rate is 1min
-
- New user
- Posts: 2
- Joined: 02 Apr 2018, 14:36
Re: Support for PZEM 004T Energy monitor
Hello from yesterday I trying to configure PZEM 004 with ESP.
Everything is fine but some of the values are not correct. I mean the power is incorrect.
As you can see from screenshot ESP shows power 22W but should be 236.4 V * 0.18A = 42.55 W.

Can you tell me please how I can solve this issue?
I tried with formulas but without success.
Regards
Everything is fine but some of the values are not correct. I mean the power is incorrect.
As you can see from screenshot ESP shows power 22W but should be 236.4 V * 0.18A = 42.55 W.

Can you tell me please how I can solve this issue?
I tried with formulas but without success.
Regards
-
- Normal user
- Posts: 497
- Joined: 04 Oct 2016, 23:16
Re: Support for PZEM 004T Energy monitor
With this module the ESPEasy plugin does nothing but fetching the numbers from the module and use them as they are.drfranky wrote: ↑02 Apr 2018, 14:47 Hello from yesterday I trying to configure PZEM 004 with ESP.
Everything is fine but some of the values are not correct. I mean the power is incorrect.
As you can see from screenshot ESP shows power 22W but should be 236.4 V * 0.18A = 42.55 W.
Can you tell me please how I can solve this issue?
I tried with formulas but without success.
Regards
There's no calculation beside the ones done by the PZEM-004T itselft, so i can only guess the module you have does not work properly...
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
-
- Core team member
- Posts: 9907
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Support for PZEM 004T Energy monitor
I'm not (yet) familiar with the module. But is it possible the power in Watt is correct and also the current and voltage, but that there is some cos-phi acting up here?papperone wrote: ↑02 Apr 2018, 18:24With this module the ESPEasy plugin does nothing but fetching the numbers from the module and use them as they are.drfranky wrote: ↑02 Apr 2018, 14:47 Hello from yesterday I trying to configure PZEM 004 with ESP.
Everything is fine but some of the values are not correct. I mean the power is incorrect.
As you can see from screenshot ESP shows power 22W but should be 236.4 V * 0.18A = 42.55 W.
Can you tell me please how I can solve this issue?
I tried with formulas but without success.
Regards
There's no calculation beside the ones done by the PZEM-004T itselft, so i can only guess the module you have does not work properly...
What kind of load is connected to the sensor? Something with a true resistive load, like a heating element or something with an inductive load like an elektro motor or some switching power supply?
-
- New user
- Posts: 2
- Joined: 02 Apr 2018, 14:36
Re: Support for PZEM 004T Energy monitor
Hi,TD-er wrote: ↑02 Apr 2018, 22:32I'm not (yet) familiar with the module. But is it possible the power in Watt is correct and also the current and voltage, but that there is some cos-phi acting up here?papperone wrote: ↑02 Apr 2018, 18:24With this module the ESPEasy plugin does nothing but fetching the numbers from the module and use them as they are.drfranky wrote: ↑02 Apr 2018, 14:47 Hello from yesterday I trying to configure PZEM 004 with ESP.
Everything is fine but some of the values are not correct. I mean the power is incorrect.
As you can see from screenshot ESP shows power 22W but should be 236.4 V * 0.18A = 42.55 W.
Can you tell me please how I can solve this issue?
I tried with formulas but without success.
Regards
There's no calculation beside the ones done by the PZEM-004T itselft, so i can only guess the module you have does not work properly...
What kind of load is connected to the sensor? Something with a true resistive load, like a heating element or something with an inductive load like an elektro motor or some switching power supply?
The load is power supply for my laptop. There is no cos-phi variable.
I tried to fix this with formulas in Easyesp but I don't know what is the variable for Voltage and Current in the fields.
Regards
-
- Normal user
- Posts: 497
- Joined: 04 Oct 2016, 23:16
Re: Support for PZEM 004T Energy monitor
All the calculations are performed by the module itself, the plugin is simply reading data trough softserial and update the device variables.
As in my 2 modules the data are reported correcly (as in some of the screenshot I posted previously) and not knowing any calibration is possible with those devices, I see as only diagnosys that this module is faulty....
As in my 2 modules the data are reported correcly (as in some of the screenshot I posted previously) and not knowing any calibration is possible with those devices, I see as only diagnosys that this module is faulty....
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
-
- Core team member
- Posts: 9907
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Support for PZEM 004T Energy monitor
The cos phi is the phase shift between voltage and current.
So it is perfectly acceptable when the power in Watt is lower than the power in VA. It simply mean the cos phi is not 1 and thus there is a phase shift.
A switching power supply without power factor correction (essentially eliminating cos phi phase shift) usually has a cos phi of about 0.6, which means that a power of 100 VA results in 0.6*100 = 60 Watt.
Please try the measurement with something with a resistive load, like an oldfashioned glowing light bulb or a heating element and you'll see the power in Watt equals voltage * current.
For inductive loads (that result in a phase shift of current) the cos phi will be less than 1 and thus the power in Watt is lower than V * A.
With a cos phi of 1, the sinus of Voltage and the sinus of current are perfectly in sync. That means the current is 0 when voltage is 0 and max when voltage is max.
With inductive loads, the sinus of the current will shift a little, meaning the peak of the current is not at the moment of the voltage peak.
And with switching power supplies the curve of the current is not even a sinus anymore and its peak is very unlikely to be at the peak of the voltage.
In short:
V * A = VA
V * A * cos phi = Watt.
On electric motors, you often see a cos phi mentioned.
So it is perfectly acceptable when the power in Watt is lower than the power in VA. It simply mean the cos phi is not 1 and thus there is a phase shift.
A switching power supply without power factor correction (essentially eliminating cos phi phase shift) usually has a cos phi of about 0.6, which means that a power of 100 VA results in 0.6*100 = 60 Watt.
Please try the measurement with something with a resistive load, like an oldfashioned glowing light bulb or a heating element and you'll see the power in Watt equals voltage * current.
For inductive loads (that result in a phase shift of current) the cos phi will be less than 1 and thus the power in Watt is lower than V * A.
With a cos phi of 1, the sinus of Voltage and the sinus of current are perfectly in sync. That means the current is 0 when voltage is 0 and max when voltage is max.
With inductive loads, the sinus of the current will shift a little, meaning the peak of the current is not at the moment of the voltage peak.
And with switching power supplies the curve of the current is not even a sinus anymore and its peak is very unlikely to be at the peak of the voltage.
In short:
V * A = VA
V * A * cos phi = Watt.
On electric motors, you often see a cos phi mentioned.
-
- Normal user
- Posts: 25
- Joined: 12 Feb 2018, 17:35
Re: Support for PZEM 004T Energy monitor
Hi All,
Have flashed a wemos D1 mini and a nodemcu module with the firmware build posted on this thread (ESPEasy-2.0.0-dev12_test_4096.bin.zip) with the same results.
All options can be configured with no issues until selecting the PZEM004 as a device and configuring GPIO's and pressing submit radio button the device becomes unresponsive,no reply to ping after this.
A reboot will show all -1 values under devices,pages are very slow to open in browser.
Have powered ESP8266 from PC's USB port as well as a mobile phone charger so do not think 5 volt power is a problem.
PZEM module works perfectly when tested on an arduino and on ESP8266 using enode firmware file after doing R17 resistor mod for 3v3 operation.
Is there a fix for this or a later build of ESPeasy that supports the PZEM-004 module ?
Thanks
Dave
Have flashed a wemos D1 mini and a nodemcu module with the firmware build posted on this thread (ESPEasy-2.0.0-dev12_test_4096.bin.zip) with the same results.
All options can be configured with no issues until selecting the PZEM004 as a device and configuring GPIO's and pressing submit radio button the device becomes unresponsive,no reply to ping after this.
A reboot will show all -1 values under devices,pages are very slow to open in browser.
Have powered ESP8266 from PC's USB port as well as a mobile phone charger so do not think 5 volt power is a problem.
PZEM module works perfectly when tested on an arduino and on ESP8266 using enode firmware file after doing R17 resistor mod for 3v3 operation.
Is there a fix for this or a later build of ESPeasy that supports the PZEM-004 module ?
Thanks
Dave
-
- Normal user
- Posts: 112
- Joined: 02 Sep 2015, 00:49
-
- Normal user
- Posts: 25
- Joined: 12 Feb 2018, 17:35
Re: Support for PZEM 004T Energy monitor
Thank you maluko.
Will compile this and test it.
Only need MQTT functionality !
Will compile this and test it.
Only need MQTT functionality !
-
- New user
- Posts: 1
- Joined: 11 May 2018, 11:15
Re: Support for PZEM 004T Energy monitor
I suspect that you pull all wires of the cable throught current transformer, but need only one of them.

-
- New user
- Posts: 1
- Joined: 29 May 2018, 20:09
Re: Support for PZEM 004T Energy monitor
Hello, i am completely new and lost too.
I try to link a Pezm-004t with a wemos D1 R2 board.
my goals are monitoring my energy consumption, diverting the current i don't use at any moment, with some opto couplers relays, and data-log the currrent from my solar panels.
at the very moment :
i link the Pzem-004t to a source with a load. i have 235 volts on the curent input, and the coil on pin 3 4.
RX,Tx from Pzem are connected to TX,RX on Wemos D1R2 pin 8 9.ground to GND, and 5V (Pzem) to 5V (Wemos).
Running the PzemDisplay example(modified with PZEM004T pzem(8 ,9); // (RX,TX) connect to TX,RX of PZEM)
i have allways -1.00V , with RX,TX connected or not.
at this time, i have no idea about what i may try to have results.
Please, do you have any idea?
Best regards
I try to link a Pezm-004t with a wemos D1 R2 board.
my goals are monitoring my energy consumption, diverting the current i don't use at any moment, with some opto couplers relays, and data-log the currrent from my solar panels.
at the very moment :
i link the Pzem-004t to a source with a load. i have 235 volts on the curent input, and the coil on pin 3 4.
RX,Tx from Pzem are connected to TX,RX on Wemos D1R2 pin 8 9.ground to GND, and 5V (Pzem) to 5V (Wemos).
Running the PzemDisplay example(modified with PZEM004T pzem(8 ,9); // (RX,TX) connect to TX,RX of PZEM)
i have allways -1.00V , with RX,TX connected or not.
at this time, i have no idea about what i may try to have results.
Please, do you have any idea?
Best regards
-
- New user
- Posts: 5
- Joined: 22 Mar 2018, 08:03
Re: Support for PZEM 004T Energy monitor
I wonder how can I use 3 phase measurements.
The best would be to use one ESP module and use address of 3 PZEM modules. But fist thing is to set address to each module for each phase.
As I can see Espeasy FW dosn't support using of 3 modules or using of different address. Do you have any idea how can we find solutuion for 3 phase measurements?
The best would be to use one ESP module and use address of 3 PZEM modules. But fist thing is to set address to each module for each phase.
As I can see Espeasy FW dosn't support using of 3 modules or using of different address. Do you have any idea how can we find solutuion for 3 phase measurements?
-
- Normal user
- Posts: 21
- Joined: 08 Nov 2017, 09:28
Re: Support for PZEM 004T Energy monitor
Yes... but I stopped at 2 modules because I didn't like the solution I programmed... I need to work again on this subject 

-
- New user
- Posts: 5
- Joined: 22 Mar 2018, 08:03
Re: Support for PZEM 004T Energy monitor
When do you think, you finish new version of FW to handle 3 PZEM modules?
Who is online
Users browsing this forum: Anthropic Claude Bot [bot] and 16 guests