Support for PZEM 004T Energy monitor

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
goldriver
Normal user
Posts: 15
Joined: 14 Jan 2018, 22:55

Re: Support for PZEM 004T Energy monitor

#71 Post by goldriver » 15 Jan 2018, 12:38

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



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 :

Code: 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"
}
(version was missing and platforms mispelled :( )

After that, I was able to compile espeasy with the plugin and send it to the esp via OTA :)

asking
Normal user
Posts: 11
Joined: 11 Aug 2017, 06:39

Re: Support for PZEM 004T Energy monitor

#72 Post by asking » 18 Jan 2018, 02:40

aleph0 wrote: 06 Dec 2017, 13:15
sega2177 wrote: 06 Dec 2017, 04:08 Hello aleph0, could you put the compiled firmware with the plugin PZET-004?
Please 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 !
aleph0 thanks for wonderful work...

But i need to know more about polling. If main line voltage is available ? what's the update rate ? Every second ? can i ?

asking
Normal user
Posts: 11
Joined: 11 Aug 2017, 06:39

Re: Support for PZEM 004T Energy monitor

#73 Post by asking » 19 Jan 2018, 03:03

I have uploaded .bin file to ESP8266 but its not showing any hotspot in wifi search of my laptop.. have anyone tried this Flash ?

aleph0
Normal user
Posts: 21
Joined: 08 Nov 2017, 09:28

Re: Support for PZEM 004T Energy monitor

#74 Post by aleph0 » 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 :-)

asking
Normal user
Posts: 11
Joined: 11 Aug 2017, 06:39

Re: Support for PZEM 004T Energy monitor

#75 Post by asking » 22 Jan 2018, 05:03

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 :-)
What's your update rate you're testing? 🤔
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

aleph0
Normal user
Posts: 21
Joined: 08 Nov 2017, 09:28

Re: Support for PZEM 004T Energy monitor

#76 Post by aleph0 » 22 Jan 2018, 05:22

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

asking
Normal user
Posts: 11
Joined: 11 Aug 2017, 06:39

Re: Support for PZEM 004T Energy monitor

#77 Post by asking » 22 Jan 2018, 05:31

Okay will try that, thanks for suggesting.

nicofly974
New user
Posts: 2
Joined: 24 Jan 2018, 22:57

Re: Support for PZEM 004T Energy monitor

#78 Post by nicofly974 » 24 Jan 2018, 23:16

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
espc.JPG
espc.JPG (55.6 KiB) Viewed 830654 times
consolepzem.JPG
consolepzem.JPG (59.66 KiB) Viewed 830654 times
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
domo.JPG
domo.JPG (44.93 KiB) Viewed 830654 times
If you have an idear
Great thanks for this plugin

dcjona
New user
Posts: 7
Joined: 13 Dec 2017, 14:05

Re: Support for PZEM 004T Energy monitor

#79 Post by dcjona » 25 Jan 2018, 10:46

aleph0 wrote: 13 Jan 2018, 21:55
dcjona wrote: 12 Jan 2018, 08:19 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 ?
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
hi, yes i have 233 in voltage but nothing else

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Support for PZEM 004T Energy monitor

#80 Post by TD-er » 25 Jan 2018, 17:03

dcjona wrote: 25 Jan 2018, 10:46 [...]

hi, yes i have 233 in voltage but nothing else
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.

nicofly974
New user
Posts: 2
Joined: 24 Jan 2018, 22:57

Re: Support for PZEM 004T Energy monitor

#81 Post by nicofly974 » 26 Jan 2018, 13:40

I've a current charge, in icon pezm1 I've 0.24A
but nothing in Energie and Power

Some idear?

dcjona
New user
Posts: 7
Joined: 13 Dec 2017, 14:05

Re: Support for PZEM 004T Energy monitor

#82 Post by dcjona » 27 Jan 2018, 12:55

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

Image

zacaruca1
New user
Posts: 1
Joined: 16 Feb 2018, 20:41

Re: Support for PZEM 004T Energy monitor

#83 Post by zacaruca1 » 16 Feb 2018, 20:51

Para los que teneis errores en la lectura, debeis modificar en la libreria espsoftwareserial-3.2.3 , el fichero SoftwareSerial.cpp la siguiente linea:

Code: Select all

 unsigned long wait = m_bitTime + m_bitTime/3 - 500;
por esta otra:

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;

Raspi_0x00
New user
Posts: 5
Joined: 22 Mar 2018, 08:03

Re: Support for PZEM 004T Energy monitor

#84 Post by Raspi_0x00 » 22 Mar 2018, 08:19

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?

Raspi_0x00
New user
Posts: 5
Joined: 22 Mar 2018, 08:03

Re: Support for PZEM 004T Energy monitor

#85 Post by Raspi_0x00 » 22 Mar 2018, 21:35

Could you help me in this case?

Raspi_0x00
New user
Posts: 5
Joined: 22 Mar 2018, 08:03

Re: Support for PZEM 004T Energy monitor

#86 Post by Raspi_0x00 » 27 Mar 2018, 11:24

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

drfranky
New user
Posts: 2
Joined: 02 Apr 2018, 14:36

Re: Support for PZEM 004T Energy monitor

#87 Post by drfranky » 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.
Image

Can you tell me please how I can solve this issue?
I tried with formulas but without success.

Regards

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Support for PZEM 004T Energy monitor

#88 Post by papperone » 02 Apr 2018, 18:24

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.
Image

Can you tell me please how I can solve this issue?
I tried with formulas but without success.

Regards
With this module the ESPEasy plugin does nothing but fetching the numbers from the module and use them as they are.
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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Support for PZEM 004T Energy monitor

#89 Post by TD-er » 02 Apr 2018, 22:32

papperone wrote: 02 Apr 2018, 18:24
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.
Image

Can you tell me please how I can solve this issue?
I tried with formulas but without success.

Regards
With this module the ESPEasy plugin does nothing but fetching the numbers from the module and use them as they are.
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...
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?
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?

drfranky
New user
Posts: 2
Joined: 02 Apr 2018, 14:36

Re: Support for PZEM 004T Energy monitor

#90 Post by drfranky » 03 Apr 2018, 10:15

TD-er wrote: 02 Apr 2018, 22:32
papperone wrote: 02 Apr 2018, 18:24
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.
Image

Can you tell me please how I can solve this issue?
I tried with formulas but without success.

Regards
With this module the ESPEasy plugin does nothing but fetching the numbers from the module and use them as they are.
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...
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?
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?
Hi,

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

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Support for PZEM 004T Energy monitor

#91 Post by papperone » 03 Apr 2018, 13:17

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....
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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Support for PZEM 004T Energy monitor

#92 Post by TD-er » 03 Apr 2018, 20:11

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.

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: Support for PZEM 004T Energy monitor

#93 Post by DaveS » 03 May 2018, 19:24

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

maluko
Normal user
Posts: 112
Joined: 02 Sep 2015, 00:49

Re: Support for PZEM 004T Energy monitor

#94 Post by maluko » 04 May 2018, 12:31

hi

look at this acessorio to pzem 004t :)

http://www.movimentomaker.pt/t/bh-pzem- ... -wi-fi/234

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: Support for PZEM 004T Energy monitor

#95 Post by DaveS » 04 May 2018, 17:46

Thank you maluko.
Will compile this and test it.
Only need MQTT functionality !

dio45rus
New user
Posts: 1
Joined: 11 May 2018, 11:15

Re: Support for PZEM 004T Energy monitor

#96 Post by dio45rus » 11 May 2018, 11:21

dcjona wrote: 12 Jan 2018, 08:19 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 ?
I suspect that you pull all wires of the cable throught current transformer, but need only one of them.
Image

Sabado
New user
Posts: 1
Joined: 29 May 2018, 20:09

Re: Support for PZEM 004T Energy monitor

#97 Post by Sabado » 29 May 2018, 20:38

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

Raspi_0x00
New user
Posts: 5
Joined: 22 Mar 2018, 08:03

Re: Support for PZEM 004T Energy monitor

#98 Post by Raspi_0x00 » 07 Jun 2018, 14:09

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?

aleph0
Normal user
Posts: 21
Joined: 08 Nov 2017, 09:28

Re: Support for PZEM 004T Energy monitor

#99 Post by aleph0 » 07 Jun 2018, 14:13

Yes... but I stopped at 2 modules because I didn't like the solution I programmed... I need to work again on this subject ;-)

Raspi_0x00
New user
Posts: 5
Joined: 22 Mar 2018, 08:03

Re: Support for PZEM 004T Energy monitor

#100 Post by Raspi_0x00 » 21 Jun 2018, 10:28

When do you think, you finish new version of FW to handle 3 PZEM modules?

ut1545
Normal user
Posts: 32
Joined: 22 Mar 2016, 20:56

Re: Support for PZEM 004T Energy monitor

#101 Post by ut1545 » 08 Jul 2018, 18:26

Hello,

I'm trying to compile last ESPeasy V2.0 release (ESPEasy-2.0-20180510) but I'm getting the same errors as #71 http://www.letscontrolit.com/forum/view ... 585#p22585.

Did anyone solve this issue? How to compile this plug in under the latest releases of ESPeasy software?
Thanks in advance,

asking
Normal user
Posts: 11
Joined: 11 Aug 2017, 06:39

Re: Support for PZEM 004T Energy monitor

#102 Post by asking » 12 Jul 2018, 16:04

Raspi_0x00 wrote: 27 Mar 2018, 11:24 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
i am also getting same error -1 randomely inbetween 1 minute readings... did you solved it ? what was the issue ? can you share ?

aleph0
Normal user
Posts: 21
Joined: 08 Nov 2017, 09:28

Re: Support for PZEM 004T Energy monitor

#103 Post by aleph0 » 13 Jul 2018, 08:55

I have two pzem connected to my wemos ; I've also got this problem on one of them :-( I never understood what was the cause, I simply ignore wrong reading in domoticz. Not very satisfying, but enough for my purpose

asking
Normal user
Posts: 11
Joined: 11 Aug 2017, 06:39

Re: Support for PZEM 004T Energy monitor

#104 Post by asking » 13 Jul 2018, 18:01

aleph0 wrote: 13 Jul 2018, 08:55 I have two pzem connected to my wemos ; I've also got this problem on one of them :-( I never understood what was the cause, I simply ignore wrong reading in domoticz. Not very satisfying, but enough for my purpose
Do you think its related to software library of arduino ? or TTL 5V to 3.3V Converter issue ?

aleph0
Normal user
Posts: 21
Joined: 08 Nov 2017, 09:28

Re: Support for PZEM 004T Energy monitor

#105 Post by aleph0 » 13 Jul 2018, 18:18

asking wrote: 13 Jul 2018, 18:01 Do you think its related to software library of arduino ? or TTL 5V to 3.3V Converter issue ?
I don't think so as the 2 pzem are connected on the same module, so same software library ; I also don't use any converters and connected 5V to GPIO directly. This is not conventional but I wanted to make a test and it's working 24/7 since last november, so I think it's safe enough ;-)

It's something related to either the pzem itselft, or the GPIO used to connect them. But as my setup is now kinda "in production" I cannot make any tests anymore :-(

I plan to buy some more for another equipment, it'll give me another testing possibility. But it'll be in a month or so

miki_tnt
New user
Posts: 3
Joined: 14 Aug 2018, 11:29

Re: Support for PZEM 004T Energy monitor

#106 Post by miki_tnt » 14 Aug 2018, 11:37

Dear all,
i have tried to compile the _P171_PZEM-004T.ino plugin (last version 8 months ago) and I get some errors and warnings:

lib/AS_BH1750/AS_BH1750A.cpp: In member function 'bool AS_BH1750A::startMeasurementAsync(TimeFuncPtr)':
lib/AS_BH1750/AS_BH1750A.cpp:518:7: warning: unused variable '_lastResult' [-Wunused-variable]
int _lastResult = -1;
^
lib/AS_BH1750/AS_BH1750A.cpp: In member function 'bool AS_BH1750A::delayExpired()':
lib/AS_BH1750/AS_BH1750A.cpp:533:19: warning: comparison between signed and unsigned integer expressions [-Ws
ign-compare]
if (timestamp < _lastTimestamp)
^
lib/AS_BH1750/AS_BH1750A.cpp:536:45: warning: statement has no effect [-Wunused-value]
delayTime = MAX_U_LONG - _lastTimestamp + timestamp;
^
lib/AS_BH1750/AS_BH1750A.cpp:542:24: warning: comparison between signed and unsigned integer expressions [-Ws
ign-compare]
return (delayTime >= _nextDelay);

ESPEasy-mega-20180809/src/_P171_PZEM-004T.ino: In function 'boolean Plugin_171(byte, Eve
ntStruct*, String&)':
ESPEasy-mega-20180809/src/_P171_PZEM-004T.ino:69:68: error: too many arguments to functi
on 'void addFormNote(const String&)'
addFormNote(string, F("SoftSerial: 1st=RX-Pin, 2nd=TX-Pin"));
^
ESPEasy-mega-20180809/src/WebServer.ino:2788:6: note: declared here
void addFormNote(const String& text)


Could anybody help me with these issues?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Support for PZEM 004T Energy monitor

#107 Post by TD-er » 14 Aug 2018, 13:56

The signed/unsigned warning can be ignored.

The errors in WebServer.ino are also quite simple to resolve.
The functions used there in the "PLUGIN_WEBFORM_LOAD" case no longer need the first parameter "string"
So just remove that parameter:

addFormNote(string, F("SoftSerial: 1st=RX-Pin, 2nd=TX-Pin"));

Change it into:

addFormNote(F("SoftSerial: 1st=RX-Pin, 2nd=TX-Pin"));

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Support for PZEM 004T Energy monitor

#108 Post by papperone » 14 Aug 2018, 18:46

I need to review this plugin in order to move it to the standard repository...
honestly still same issue, lack of time to improve it making it working with multiple devices (e.g. to monitor multiple lines or 3-phase AC).
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

miki_tnt
New user
Posts: 3
Joined: 14 Aug 2018, 11:29

Re: Support for PZEM 004T Energy monitor

#109 Post by miki_tnt » 16 Aug 2018, 19:15

yes, you are right, I already corrected the error regarding addFormNote function, but I am getting more errors after the warning

ESPeasySoftwareSerial.cpp:(.iram.text+0xd4): multiple definition of `sws_isr_0()'
.pioenvs/normal_ESP8266_1024/lib010/SoftwareSerial/SoftwareSerial.cpp.o:SoftwareSerial.cpp:(.iram.text+0xf8):
first defined here
.pioenvs/normal_ESP8266_1024/libc99/ESPEasySoftwareSerial/ESPeasySoftwareSerial.cpp.o: In function `sws_isr_1
()':

ESPeasySoftwareSerial.cpp:(.iram.text+0xec): multiple definition of `sws_isr_1()'
.pioenvs/normal_ESP8266_1024/lib010/SoftwareSerial/SoftwareSerial.cpp.o:SoftwareSerial.cpp:(.iram.text+0x110)
: first defined here
.pioenvs/normal_ESP8266_1024/libc99/ESPEasySoftwareSerial/ESPeasySoftwareSerial.cpp.o: In function `sws_isr_2
()':
ESPeasySoftwareSerial.cpp:(.iram.text+0x104): multiple definition of `sws_isr_2()'
.pioenvs/normal_ESP8266_1024/lib010/SoftwareSerial/SoftwareSerial.cpp.o:SoftwareSerial.cpp:(.iram.text+0x128)
: first defined here
collect2: error: ld returned 1 exit status
*** [.pioenvs/normal_ESP8266_1024/firmware.elf] Error 1
========================== [ERROR] Took 59.91 seconds ==========================
Environment normal_ESP8266_1024 [ERROR]

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Support for PZEM 004T Energy monitor

#110 Post by TD-er » 16 Aug 2018, 21:49

Hmm, that's very strange, I only got those errors when building the latest ESP32 code.
Try to run a "clean" build first before recompiling.

miki_tnt
New user
Posts: 3
Joined: 14 Aug 2018, 11:29

Re: Support for PZEM 004T Energy monitor

#111 Post by miki_tnt » 16 Aug 2018, 23:00

Thank you very much.
Yes, it is very strange. I have cleaned the project and compiled it again but no luck... I dont understand what it is going on. I am using last mega release.
Any other suggestion will be appreciated.

kind regards,

Dim33
New user
Posts: 2
Joined: 14 May 2018, 23:43

Re: Support for PZEM 004T Energy monitor

#112 Post by Dim33 » 29 Aug 2018, 00:16

Hello everybody,

My energy measurement is operationnal by following this post and this one http://www.domoticz.com/forum/viewtopic ... 14&t=20820
I use an ESP8266_4096.

But I have a problem :

- if I boot my ESP connected to the PZEM. My ESP doesn't start (no effect if I push on RESET button),
- If I boot my ESP (not connected to the PZEM), this one start normaly and after i can connect the PZEM to the ESP and the Energy measurement is OK.

This problem is painful because if i have a power cut, my Energy measurement does not restart.

Can you help me ?

Thanks in advance.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Support for PZEM 004T Energy monitor

#113 Post by TD-er » 29 Aug 2018, 13:28

Maybe you connected the sensor to one of the pins needed to indicate the boot-mode?
For example GPIO0, which is connected to the "Flash" button on NodeMCU boards, will put the ESP into flash mode when pressed.
I can imagine the sensor will do the same when connected to that pin.

Dim33
New user
Posts: 2
Joined: 14 May 2018, 23:43

Re: Support for PZEM 004T Energy monitor

#114 Post by Dim33 » 30 Aug 2018, 22:56

Dim33 wrote: 29 Aug 2018, 00:16 Hello everybody,

My energy measurement is operationnal by following this post and this one http://www.domoticz.com/forum/viewtopic ... 14&t=20820
I use an ESP8266_4096.

But I have a problem :

- if I boot my ESP connected to the PZEM. My ESP doesn't start (no effect if I push on RESET button),
- If I boot my ESP (not connected to the PZEM), this one start normaly and after i can connect the PZEM to the ESP and the Energy measurement is OK.

This problem is painful because if i have a power cut, my Energy measurement does not restart.

Can you help me ?

Thanks in advance.
I modified the GPIO pin : GPIO-12 and 13 instead of GPIO-14 and 15 and all is OK.

pppp33
Normal user
Posts: 71
Joined: 25 Oct 2015, 17:53

Re: Support for PZEM 004T Energy monitor

#115 Post by pppp33 » 30 Aug 2018, 23:17

Hi there,
I've got a PZEM an tried to compile, but got same "multiple definition" error, as miki_tnt :

.pioenvs\test_ESP8266_4096\lib46c\ESPEasySoftwareSerial\SoftwareSerial.cpp.o: In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xd0): multiple definition of `sws_isr_0()'
.pioenvs\test_ESP8266_4096\lib46c\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0xd4): first defined here
.pioenvs\test_ESP8266_4096\lib46c\ESPEasySoftwareSerial\SoftwareSerial.cpp.o: In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0xe8): multiple definition of `sws_isr_1()'
.pioenvs\test_ESP8266_4096\lib46c\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0xec): first defined here
.pioenvs\test_ESP8266_4096\lib46c\ESPEasySoftwareSerial\SoftwareSerial.cpp.o: In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x100): multiple definition of `sws_isr_2()'
.pioenvs\test_ESP8266_4096\lib46c\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0x104): first defined here
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z21Plugin171_ReadVoltagev+0x8): undefined reference to `PZEM004T::voltage(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o: In function `Plugin171_ReadVoltage()':
ESPEasy.ino.cpp:(.text._Z21Plugin171_ReadVoltagev+0x25): undefined reference to `PZEM004T::voltage(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z21Plugin171_ReadCurrentv+0x0): undefined reference to `PZEM004T::current(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z21Plugin171_ReadCurrentv+0x1d): undefined reference to `PZEM004T::current(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z19Plugin171_ReadPowerv+0x0): undefined reference to `PZEM004T::power(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z19Plugin171_ReadPowerv+0x1d): undefined reference to `PZEM004T::power(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z20Plugin171_ReadEnergyv+0x0): undefined reference to `PZEM004T::energy(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o: In function `Plugin171_ReadEnergy()':
ESPEasy.ino.cpp:(.text._Z20Plugin171_ReadEnergyv+0x1d): undefined reference to `PZEM004T::energy(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z10Plugin_171hP11EventStructR6String+0x1c): undefined reference to `PZEM004T::PZEM004T(unsigned char, unsigned char)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o:(.text._Z10Plugin_171hP11EventStructR6String+0x20): undefined reference to `PZEM004T::setAddress(IPAddress const&)'
.pioenvs\test_ESP8266_4096\src\ESPEasy.ino.cpp.o: In function `Plugin_171(unsigned char, EventStruct*, String&)':
ESPEasy.ino.cpp:(.text._Z10Plugin_171hP11EventStructR6String+0x14e): undefined reference to `PZEM004T::PZEM004T(unsigned char, unsigned char)'
ESPEasy.ino.cpp:(.text._Z10Plugin_171hP11EventStructR6String+0x15b): undefined reference to `PZEM004T::setAddress(IPAddress con
.....
.....
....


Is there any suggestion to overcome this issue ?
Perhaps something changed in libraries, etc. in the last months ?
Thanx & Regards
Paolo

GieBek
New user
Posts: 7
Joined: 29 Aug 2018, 23:25

Re: Support for PZEM 004T Energy monitor

#116 Post by GieBek » 30 Nov 2018, 23:34

Would it give advice to throw the plugin into the latest software. PZEM has been working very well for me for half a year but I miss some features from the new software.

Greetings.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Support for PZEM 004T Energy monitor

#117 Post by grovkillen » 30 Nov 2018, 23:38

Please open an issue for it on GitHub and ask the maintainer to add it as a PR.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

GieBek
New user
Posts: 7
Joined: 29 Aug 2018, 23:25

Re: Support for PZEM 004T Energy monitor

#118 Post by GieBek » 01 Dec 2018, 00:01

Thank you very much for your answer.

I did what you wrote.

Greetings.
GieBek

lyovav
New user
Posts: 9
Joined: 27 Sep 2018, 12:46

Re: Support for PZEM 004T Energy monitor

#119 Post by lyovav » 10 Dec 2018, 12:13


hnaeem07
New user
Posts: 1
Joined: 23 Dec 2018, 13:16

Re: Support for PZEM 004T Energy monitor

#120 Post by hnaeem07 » 23 Dec 2018, 13:25

I am not getting correct value for Watts when i did the calculation, example as below

Actual reading from meter = 232.20 Volts , 2.89 Amps, 665.00 Watts, 1311707.00 KWH

232.20 x 2.89 = 671.06 Watts, but in the meter it shows 665.00, can i know why its not accurate ?

Thanks in advance. :D

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests