Support for PZEM 004T Energy monitor

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#201 Post by djelau » 06 Jul 2020, 18:10

xxrock wrote: 05 Jul 2020, 11:58 Can you please give advise what I do wrong?
I think you cumulate all the errors that I solve previously:
- Avoid Node MCU because voltage level are 3V3 whereas PZEM expects 5V. It could work but it's not sure
- Avoid HW serial
- RX and TX are inverted to work with HW serial
- Deactivate serial communication in Tools->Advanced-> Serial Port

So follow very carefully this link, and normally everything should be OK. If not, use a wemos D1.

xxrock
New user
Posts: 7
Joined: 01 Jul 2020, 17:50

Re: Support for PZEM 004T Energy monitor

#202 Post by xxrock » 09 Jul 2020, 14:41

djelau wrote: 06 Jul 2020, 18:10 I think you cumulate all the errors that I solve previously:
- Avoid Node MCU because voltage level are 3V3 whereas PZEM expects 5V. It could work but it's not sure
- Avoid HW serial
- RX and TX are inverted to work with HW serial
- Deactivate serial communication in Tools->Advanced-> Serial Port

So follow very carefully this link, and normally everything should be OK. If not, use a wemos D1.
Thanks. I connect PZEM RX to GPIO13, TX to GPI12, G to G and 5V to VU (this is 5V from microUSB). I don't know why, but GPIO01 and GPI03 don't work :roll:
Now two diodes in PZEM blinks regulary I can see Voltage and Frequency. But Current and power is zero...
How can I check that coils works normally?
Снимок.PNG
Снимок.PNG (16.21 KiB) Viewed 1205967 times

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#203 Post by djelau » 09 Jul 2020, 15:25

xxrock wrote: 09 Jul 2020, 14:41 I don't know why, but GPIO01 and GPI03 don't work :roll:
It should work but in your initial set up, you should select SW serial rather than HW serial and set GPIO <- TX as GPIO-1 and GPIO->RX as GPIO-3
xxrock wrote: 09 Jul 2020, 14:41 How can I check that coils works normally?
What kind of load do you connect ?
For your info, coil impedance is roughly 60 ohms.

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

Re: Support for PZEM 004T Energy monitor

#204 Post by TD-er » 09 Jul 2020, 16:12

If using the pins for the normal serial port, then make sure to uncheck (thus disable) serial port support in Tools => Advanced.
Otherwise ESPEasy may send out debug data or logs to that port, which may affect the connected sensor.

xxrock
New user
Posts: 7
Joined: 01 Jul 2020, 17:50

Re: Support for PZEM 004T Energy monitor

#205 Post by xxrock » 09 Jul 2020, 17:36

Now I connect GPIO1 & GPIO3 it works, but still show only voltage :(
Yes, I choose Software serial port in communication settings and disable setrial port in advanced settings.
My coil's impendancw is 55.4Ohm. I connect coil to extension cord which connected to monitors and notebook. Ноw can I check PZEM send any current and power data?

Image

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

#206 Post by grovkillen » 09 Jul 2020, 18:47

Could you show how you have mounted it, over one wire? Or else the net sum will always be zero.
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:

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

Re: Support for PZEM 004T Energy monitor

#207 Post by TD-er » 09 Jul 2020, 20:08

What Jimmy said (Grovkillen), you should only have 1 wire of the AC string going through this coil, not both wires.

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#208 Post by djelau » 09 Jul 2020, 20:52

xxrock wrote: 09 Jul 2020, 17:36 Ноw can I check PZEM send any current and power data?
If displayed current is 0A then data are sent correctly. Otherwise, you will have NAN. (and power would be NAN if no communication)
With current =0A, power=0, it's normal.

So a photo of your overall wiring setup will be helpful.

xxrock
New user
Posts: 7
Joined: 01 Jul 2020, 17:50

Re: Support for PZEM 004T Energy monitor

#209 Post by xxrock » 10 Jul 2020, 06:36

TD-er wrote: 09 Jul 2020, 20:08 What Jimmy said (Grovkillen), you should only have 1 wire of the AC string going through this coil, not both wires.
Hello,
It really was a mistake related to the wrong connection of the coil. I just did not study carefully the connection diagram. Now everything works as expected. Thank you all for the help, especially to djelau (for firmware and help). :)

p.s. If somebody else wants connect NodeMCU Lolin v3 to PZEM-004T v3 can use this pins:
IMG_20200710_104414.jpg
IMG_20200710_104414.jpg (1.15 MiB) Viewed 1205883 times

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#210 Post by djelau » 10 Jul 2020, 11:16

xxrock wrote: 10 Jul 2020, 06:36 I just did not study carefully the connection diagram. Now everything works as expected. Thank you all for the help, especially to djelau (for firmware and help). :)
Good job !

ice77
Normal user
Posts: 18
Joined: 05 Apr 2020, 05:47

Re: Support for PZEM 004T Energy monitor

#211 Post by ice77 » 05 Aug 2020, 05:19

good morning @all

@djelau:
first of all: THANK YOU SO MUCH FOR YOUR WORK. I tried your firmware with one PZEM004T and it works like a charme. I get the values via MQTT into my ioBroker and its really fine. What I am thinking about is - how many PZEM004T could I connect to one ESP8266 (D1 Mini - which is highly recommended how I've read).

Is there a hard limitation? I am thinking about to attach 6 PZEM 004T to one D1 mini Pro. Would this be possible?
When attached several PZEMs - do they have to be separated (timing) in polling intervall or would it be ok to set 10sec polling to all of them?
Actually I bought 3 PZEMs - if I could drive 6 of them with one D1 Mini I would order other 3 @Ali.

Did anyone of you measure how much power consumption is realized for each PZEM to measure?

Thank you in advice

have a nice day

ice77

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#212 Post by djelau » 14 Aug 2020, 21:32

Hello ice77,

It's ok to set 10sec polling to all of them. Each instance of slave are executed sequentially (not simultaneaously).

I don't test with 6PZEM but it should work: Eventually you can supply PZEM by using the 5V from the AC/DC of wall plug rather than the one from wemos. Just connect gnd all together.
And communication protocol is fast enough to communicate with 6 PZEM.

ice77
Normal user
Posts: 18
Joined: 05 Apr 2020, 05:47

Re: Support for PZEM 004T Energy monitor

#213 Post by ice77 » 23 Aug 2020, 19:10

Hi djelau,

Thank you for your answer. I ordered other 5 PZEM-004T V3. I will test it, when the hardware arrives.

I actually use a simple D1 mini, but will swap to the D1 mini pro to get an external antenna attached. The PZEM delivers 5V and I am not sure, if the D1 mini (pro) is 5V tolerant for a very long time. Would it be advisable, to use an level shifter to 3,3V? for example this one https://www.aliexpress.com/item/3-3V-5V ... 4c4dz3hrJG

Would you recommend that or can I drive the D1 mini with 5V to the GPIO Pins without having fear to burn it?

Has anyone ever measured the power consumption of one PZEM-004T V3?
pzem004Tv3.jpeg
pzem004Tv3.jpeg (38.97 KiB) Viewed 1205355 times
Here is a pic of the power measurement of an Intel NUC 8i5 with proxmox.

dear community - have phun and stay tuned :-)

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#214 Post by djelau » 24 Aug 2020, 11:49

Would you recommend that or can I drive the D1 mini with 5V to the GPIO Pins without having fear to burn it?
For professional application (I'm electronic engineer), I would say that it is forbidden. The D1 datasheet says max input voltage 3V3. And we always apply some margin to improve reliability. So I would recommend 3V max on the input.

For my personnal use, I try to have a simple design, easy to replace in case of failure. In my case, environmental conditions are very favorable (external temperature ~20°, low temperature variation, no vibration, no acceleration, no extrem humidity, no pressure, low EMC field). Thus I use 5V since more than 1 year and my wemos is stil alive.

Your proposal of level shifter will work.
I don't measure the consumption of PZEM.

xxrock
New user
Posts: 7
Joined: 01 Jul 2020, 17:50

Re: Support for PZEM 004T Energy monitor

#215 Post by xxrock » 27 Aug 2020, 17:56

djelau,
I use your version of ESPEasy with PZEM004T support. It works great. I need additionally connect AM2320 sensor (temperature+humidity). It support by original version of ESPEasy, but not yours. Is it possible add support of this device to your version of firmware?

User avatar
Andrew Mamohin
Normal user
Posts: 95
Joined: 12 Jun 2020, 08:30
Location: Belarus, Gomel
Contact:

Re: Support for PZEM 004T Energy monitor

#216 Post by Andrew Mamohin » 04 Sep 2020, 17:40

xxrock wrote: 27 Aug 2020, 17:56 djelau,
Is it possible add support of this device to your version of firmware?
I subscribe to this request. I want a new version too. Please!
Andy.

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#217 Post by djelau » 05 Sep 2020, 11:53

Hi,

I compile this version with AM2320:
ESP_Easy_mega_20200905_normal_ESP8266_4M1M.zip
(567.35 KiB) Downloaded 2734 times
I don't test it, I only connect to the Wemos and check devices are available (PZEM and AM2320)

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

Re: Support for PZEM 004T Energy monitor

#218 Post by TD-er » 05 Sep 2020, 14:33

Is it based on different source code compared to what is in the main repository?
If so, can you make a pull request?

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#219 Post by djelau » 05 Sep 2020, 22:20

TD-er wrote: 05 Sep 2020, 14:33 Is it based on different source code compared to what is in the main repository
I add the PZEM code and the associated libraries.
And I modify define_plugin_sets.h in order to add my plugin and activate the AM2320 plugin.
Otherwise, initial source code hasn't been modified.

What do you call different source code ?

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

Re: Support for PZEM 004T Energy monitor

#220 Post by TD-er » 06 Sep 2020, 11:46

I get it then is one of the playground plugins?
If so, which is it, then we can add it to the main repository.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#221 Post by olegvstt » 10 Sep 2020, 12:44

Help please, I can not connect PZEM-017 to the ESP Easy. Is it possible to make a bin file like ESP_Easy_mega-20191003_PZEM_core_ESP8266_4M1M.bin only for PZEM-017.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#222 Post by olegvstt » 10 Sep 2020, 12:57

I have pzem-017 v1.0 at https://github.com/maxzerker/PZEM-017-v1 there is a library, but I don't know how to add to ESP Easy.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#223 Post by olegvstt » 12 Sep 2020, 08:50

Please tell me how you can integrate the library https://github.com/maxzerker/PZEM-017-v1 into ESP Easy.

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#224 Post by djelau » 14 Sep 2020, 17:21

olegvstt wrote: 12 Sep 2020, 08:50 lease tell me how you can integrate the library
Hi,

I would say:
- Download the source code from official repository here
- Download PZEM004Tv30.cpp and _P251_PZEM004Tv3.ino in my fork here
- In PZEM004Tv30.cpp and _P251_PZEM004Tv3.ino, change library PZEM004Tv30.h by pzem-017 library
- Integrate these 3 files in the official source code + update plugin list
- Compile with a tool such as vscode + plateformio

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#225 Post by olegvstt » 15 Sep 2020, 12:40

Thanks, I'll try to do it. I'm wondering if there is a ready-made bin file for PZEM 017. Maybe someone has already done it, otherwise I'm a beginner in programming.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#226 Post by olegvstt » 15 Sep 2020, 16:25

I tried it, it didn't work. Can anyone have a bin file PZEM-017 for ESPEasy, send Please.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#227 Post by olegvstt » 16 Sep 2020, 09:42

- Integrate these 3 files in the official source code + update plugin list
Please describe how to integrate these 3 files into VS Code.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#228 Post by olegvstt » 11 Oct 2020, 16:03

Please help me connect the PZEM-017 to EspEasy.

djelau
Normal user
Posts: 45
Joined: 08 Nov 2019, 15:33
Location: France

Re: Support for PZEM 004T Energy monitor

#229 Post by djelau » 12 Oct 2020, 23:52

olegvstt wrote: 11 Oct 2020, 16:03 Please help me connect the PZEM-017 to EspEasy.
I don't think you will have lot of answers in this topic for PZEM 004T. Better way would be to open a new topic about PZEM017.

About directory organization, for PZEM004Tv30.cpp and PZEM004Tv30.h, I create a new directory in \lib\PZEM-004T-v30
For the P251_PZEM004Tv3.ino file, I put it in \src
And finally, in define_plugin_sets.h, I add #define USES_P251 to activate the plugin.

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: Support for PZEM 004T Energy monitor

#230 Post by ssd » 15 Oct 2020, 12:50

Hi,

Can someone please provide connection diagram for connecting PZEM-004t withesp8266 nodemcu and load? I am unable to get any value on ESPeasy web interface.

IgorTu
New user
Posts: 5
Joined: 15 Oct 2020, 13:26

Re: Support for PZEM 004T Energy monitor

#231 Post by IgorTu » 15 Oct 2020, 13:47

Hi!
I've problem with P_251 plugin compile under platformio-ide. follow errors was happen:

Compiling .pio/build/custom_ESP8266_4M1M/libeca/Regexp/Regexp.cpp.o
lib/PZEM-004T-v30/PZEM004Tv30.cpp: In constructor 'PZEM004Tv30::PZEM004Tv30(uint8_t, uint8_t, uint8_t)':
lib/PZEM-004T-v30/PZEM004Tv30.cpp:58:56: error: no matching function for call to 'ESPeasySerial::ESPeasySeria
l(uint8_t&, uint8_t&)'
swSerial= new ESPeasySerial(receivePin, transmitPin);
^
lib/PZEM-004T-v30/PZEM004Tv30.cpp:58:56: note: candidates are:
In file included from lib/PZEM-004T-v30/PZEM004Tv30.h:31:0,
from lib/PZEM-004T-v30/PZEM004Tv30.cpp:1:
.pio/libdeps/custom_ESP8266_4M1M/ESPeasySerial/ESPeasySerial.h:220:3: note: ESPeasySerial::ESPeasySerial(ESPE
asySerialPort, int, int, bool, unsigned int, bool)
ESPeasySerial(ESPEasySerialPort port,
^
.pio/libdeps/custom_ESP8266_4M1M/ESPeasySerial/ESPeasySerial.h:220:3: note: candidate expects 6 arguments,
2 provided
.pio/libdeps/custom_ESP8266_4M1M/ESPeasySerial/ESPeasySerial.h:210:7: note: constexpr ESPeasySerial::ESPeasyS
erial(const ESPeasySerial&)
class ESPeasySerial : public Stream {
^
.pio/libdeps/custom_ESP8266_4M1M/ESPeasySerial/ESPeasySerial.h:210:7: note: candidate expects 1 argument, 2
provided
*** [.pio/build/custom_ESP8266_4M1M/lib946/PZEM-004T-v30/PZEM004Tv30.cpp.o] Error 1

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

Re: Support for PZEM 004T Energy monitor

#232 Post by TD-er » 15 Oct 2020, 13:58

You are probably either missing this
#include <ESPeasySerial.h>

or you have not included the lib_dep in the platformio.ini configuration.

Code: Select all

lib_deps                  = https://github.com/TD-er/ESPEasySerial.git#v2.0.5
You probably need more then just this lib.
See the platformio_xxx.ini files in the repository.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Support for PZEM 004T Energy monitor

#233 Post by Ath » 15 Oct 2020, 14:01

ssd wrote: 15 Oct 2020, 12:50 Hi,

Can someone please provide connection diagram for connecting PZEM-004t withesp8266 nodemcu and load? I am unable to get any value on ESPeasy web interface.
If you start reading from message #205 in this thread and down it should be quite clear.
/Ton (PayPal.me)

IgorTu
New user
Posts: 5
Joined: 15 Oct 2020, 13:26

Re: Support for PZEM 004T Energy monitor

#234 Post by IgorTu » 15 Oct 2020, 15:06

TD-er wrote: 15 Oct 2020, 13:58 You are probably either missing this
#include <ESPeasySerial.h>

or you have not included the lib_dep in the platformio.ini configuration.

Code: Select all

lib_deps                  = https://github.com/TD-er/ESPEasySerial.git#v2.0.5
You probably need more then just this lib.
See the platformio_xxx.ini files in the repository.
Thanks! You absolutely right! (it was happen, not full libraries depensity integration) Re-depensity resolve it error

IgorTu
New user
Posts: 5
Joined: 15 Oct 2020, 13:26

Re: Support for PZEM 004T Energy monitor

#235 Post by IgorTu » 15 Oct 2020, 16:15

Ho to use DAC output in PCF8591?

IgorTu
New user
Posts: 5
Joined: 15 Oct 2020, 13:26

Re: Support for PZEM 004T Energy monitor

#236 Post by IgorTu » 15 Oct 2020, 16:53

while compile normal_ESP8266_4M1 or dev_
happen follow errors:
Compiling .pio/build/normal_ESP8266_4M1M_VCC/src/src/Commands/Blynk.cpp.o
/PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino: In function 'boolean Plugin_
251(byte, EventStruct*, String&)':
/PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:54:37: error: 'SENSOR_TYPE_QUAD' was not declared in this scope
Device[deviceCount].VType = SENSOR_TYPE_QUAD;
^
In file included from /PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:11:0:
.pio/libdeps/normal_ESP8266_4M1M_VCC/PZEM-004T-v30/PZEM004Tv30.h:82:10: error: 'void PZEM004Tv30::init(uint8_
t)' is private
void init(uint8_t addr); // Init common to all constructors
^
/PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:226:46: error: within this co
ntext
P251_PZEM_sensor->init(P251_PZEM_ADDR);
^
In file included from /PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:11:0:
.pio/libdeps/normal_ESP8266_4M1M_VCC/PZEM-004T-v30/PZEM004Tv30.h:82:10: error: 'void PZEM004Tv30::init(uint8_
t)' is private
void init(uint8_t addr); // Init common to all constructors
^
/PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:259:48: error: within this context
P251_PZEM_sensor->init(P251_PZEM_ADDR);
^
In file included from /PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:11:0:
.pio/libdeps/normal_ESP8266_4M1M_VCC/PZEM-004T-v30/PZEM004Tv30.h:82:10: error: 'void PZEM004Tv30::init(uint8_
t)' is private
void init(uint8_t addr); // Init common to all constructors
^
/PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:301:47: error: within this context
P251_PZEM_sensor->init(event->Par1);
^
Compiling .pio/build/normal_ESP8266_4M1M_VCC/src/src/Commands/Common.cpp.o
Compiling .pio/build/normal_ESP8266_4M1M_VCC/src/src/Commands/Controller.cpp.o
Compiling .pio/build/normal_ESP8266_4M1M_VCC/src/src/Commands/Diagnostic.cpp.o
*** [.pio/build/normal_ESP8266_4M1M_VCC/src/ESPEasy.ino.cpp.o] Error 1

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

Re: Support for PZEM 004T Energy monitor

#237 Post by TD-er » 15 Oct 2020, 22:44

If you're seeing errors like those, I guess you are not using the latest source code of ESPEasy.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Support for PZEM 004T Energy monitor

#238 Post by Ath » 16 Oct 2020, 07:55

IgorTu wrote: 15 Oct 2020, 16:53 /PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:54:37: error: 'SENSOR_TYPE_QUAD' was not declared in this scope
Device[deviceCount].VType = SENSOR_TYPE_QUAD;
That should at least be adjusted to: (just a quick peek in one of the other, more current, _Pxxx.ino files)

Code: Select all

         Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
IgorTu wrote: 15 Oct 2020, 16:53 In file included from /PlatformIO/Projects/ESPEasy-power/src/_P251_PZEM004Tv3.ino:11:0:
.pio/libdeps/normal_ESP8266_4M1M_VCC/PZEM-004T-v30/PZEM004Tv30.h:82:10: error: 'void PZEM004Tv30::init(uint8_
t)' is private
void init(uint8_t addr); // Init common to all constructors
^
That is a different error, but should be easily fixed by moving the declaration into the correct region (public:) in the class definition
/Ton (PayPal.me)

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: Support for PZEM 004T Energy monitor

#239 Post by ssd » 16 Oct 2020, 09:19

Hello,

I am trying to connect PZEM-004t with nodemcu with the following configuration:-

Nodemcu is connected to a laptop USB. 5V, GND for PZem is taken from raspberry pi, and TX of PZem is connected to D7, and RX is connected to D6.
pzem.png
pzem.png (28.12 KiB) Viewed 1203579 times
It gives me Nan in all the fields. I have disabled serial port in settings as well.
The LED of D2 is turned ON all the time. D1 is off.

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

Re: Support for PZEM 004T Energy monitor

#240 Post by TD-er » 16 Oct 2020, 11:01

Well that configuration just simply is wrong.
You cannot have an I2C address set and GPIO pins.
That's not using the correct ESPEasy serial wrapper calls.

IgorTu
New user
Posts: 5
Joined: 15 Oct 2020, 13:26

Re: Support for PZEM 004T Energy monitor

#241 Post by IgorTu » 16 Oct 2020, 11:43

TD-er wrote: 15 Oct 2020, 22:44 If you're seeing errors like those, I guess you are not using the latest source code of ESPEasy.
what source version you reccomend?

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#242 Post by olegvstt » 16 Oct 2020, 22:25

I have it connected like this, everything works.Image
Attachments
Снимок.PNG
Снимок.PNG (59.18 KiB) Viewed 1203513 times

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: Support for PZEM 004T Energy monitor

#243 Post by ssd » 17 Oct 2020, 06:48

TD-er wrote: 16 Oct 2020, 11:01 Well that configuration just simply is wrong.
You cannot have an I2C address set and GPIO pins.
That's not using the correct ESPEasy serial wrapper calls.
I am using plugin 251 from the ESPeasy plugin and it is set by default. Can anyone suggest a perfect plugin without an I2C address?

link of plugin I am using: - https://github.com/djelau/ESPEasyPlugin ... 004Tv3.ino

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: Support for PZEM 004T Energy monitor

#244 Post by ssd » 17 Oct 2020, 07:52

olegvstt wrote: 16 Oct 2020, 22:25 I have it connected like this, everything works.Image
Can you provide me the link and the schematic diagram for the same?

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: Support for PZEM 004T Energy monitor

#245 Post by ssd » 17 Oct 2020, 08:17

ssd wrote: 17 Oct 2020, 06:48
TD-er wrote: 16 Oct 2020, 11:01 Well that configuration just simply is wrong.
You cannot have an I2C address set and GPIO pins.
That's not using the correct ESPEasy serial wrapper calls.
I am using plugin 251 from the ESPeasy plugin and it is set by default. Can anyone suggest a perfect plugin without an I2C address?

link of plugin I am using: - https://github.com/djelau/ESPEasyPlugin ... 004Tv3.ino
by using plugin_171 I am unable to set port under devices tab also values shown are 0.
value-zero.png
value-zero.png (41.68 KiB) Viewed 1203449 times
pzem-2.png
pzem-2.png (36.71 KiB) Viewed 1203448 times

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#246 Post by olegvstt » 18 Oct 2020, 08:58

Disable on the Hardware I2C Interface tab and on the Tools tab advanced Serial port.

iotn00b
New user
Posts: 1
Joined: 18 Oct 2020, 08:34

Re: Support for PZEM 004T Energy monitor

#247 Post by iotn00b » 18 Oct 2020, 10:55

First of all many thanks to Espeasy and PZEM-multi developers!! You do an awesome job and help so many enthusiasts!

I used espeasy firmware for 2+ years, but as sensors and setups get more complicated while plugin/controller sets remain quite conservative I have to master custom builds. And here is where problems start, as I'm not developer and not really comfortable with PIO. For example: how to get full output if it is reaaly long? Or how to click on error and got positioned on a guilty line of source code.

I use 1M boards and need both Blynk and PZEM compiled. I tried ESPEasy_mega-20191003 as a source and it worked. Then I wanted to try more up-to-date source, did the same as for 20191003 but neither 20201009 nor 20201016 worked. PIO either throws a lot of 'warning: "BUILD_NO_DEBUG" redefined' junk and overflows console and status = success or fails on some unrelated libraries but second run without any change succeeds. Either way when I flashed and booted, I didn't have BLYNK in Controllers or PZEM in Devices. Initially I wanted to ask for help, but then figured out myself so I'll document it below. May be someone can find it helpful.

What I did:
- downloaded sources
- put PZEM004Tv30.cpp and PZEM004Tv30.h from the Playground to ./lib/PZEM-004T-v30
- had some errors in PZEM004Tv30.cpp regarding a number of arguments (related to ESPeasySerial.h) so I changed PZEM004Tv30.cpp:
swSerial= new ESPeasySerial(receivePin, transmitPin); TO swSerial= new ESPeasySerial(ESPEasySerialPort::software, receivePin, transmitPin);
- put _P251_PZEM004Tv3.ino to ./src
- changed _P251_PZEM004Tv3.ino
Device[deviceCount].VType = SENSOR_TYPE_QUAD; to Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
(thanks to several posts above)
- added a section for my board to platformio_esp82xx_envs.ini

Code: Select all

[env:test_ESP8266_1M]
extends                   = esp8266_1M
platform                  = ${testing.platform}
platform_packages         = ${testing.platform_packages}
build_flags               = ${testing.build_flags}
                            ${esp8266_1M.build_flags}
                            -DUSE_CUSTOM_H
board                     = ${esp8266_1M.board}
framework                 = arduino
- chose this setup as default in platformio.ini
default_envs = test_ESP8266_1M
- added Blynk and PZEM via ./src/Custom.h
#define USES_P251 // PZEM-04T
#define USES_C012 // Blynk HTTP
#define USES_C015 // Blynk

- removed some sensors which I don't use to save memory in ./src/Custom.h like this:
#ifdef USES_P025
# undef USES_P025 // ADS1115
#endif

- just in case I added to define_plugin_sets.h
#define USES_C012 // Blynk HTTP
#define USES_C015 // Blynk
after #ifdef CONTROLLER_SET_TESTING
and
#define USES_P251 // PZEM-04T
after
#ifdef PLUGIN_SET_TESTING
- Looks like Blynk got skipped due to the following section of define_plugin_sets.h

Code: Select all

// Due to size restrictions, disable a few plugins/controllers for 1M builds
#ifdef SIZE_1M
  #ifdef USES_C003
    #undef USES_C003
  #endif
  #ifndef LIMIT_BUILD_SIZE
    #define LIMIT_BUILD_SIZE
  #endif
#endif
...
#ifdef LIMIT_BUILD_SIZE
...
  #ifdef USES_BLYNK
    #undef USES_BLYNK
I fixed it by commenting out:

Code: Select all

//  #ifdef USES_BLYNK
//    #undef USES_BLYNK
//  #endif

One question though: do I need to change wait timeouts in ./lib/ESPEasySerial/ESPeasySoftwareSerial.cpp like in post #126 (viewtopic.php?p=36179#p36179) ?
MAX_PIN 15 instead of MAX_PIN 16
and
unsigned long wait = m_bitTime + m_bitTime / 2; instead of unsigned long wait = m_bitTime + m_bitTime / 3 - 500;
and
while (ESP.getCycleCount()-start < wait);
wait += m_bitTime;

instead of
WAIT;

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: Support for PZEM 004T Energy monitor

#248 Post by ssd » 19 Oct 2020, 07:20

olegvstt wrote: 18 Oct 2020, 08:58 Disable on the Hardware I2C Interface tab and on the Tools tab advanced Serial port.
I flushed my ESPeasy and reinstalled the firmware and the sensor works perfectly fine with the 217 plugin without disabling I2C interface or serial port. Will it have any adverse effect in long term? or is it fin if it is working perfectly?

Thanks!! :D

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#249 Post by olegvstt » 22 Oct 2020, 15:08

It does not work for me when the serial port is on.

olegvstt
Normal user
Posts: 13
Joined: 10 Sep 2020, 11:38

Re: Support for PZEM 004T Energy monitor

#250 Post by olegvstt » 22 Oct 2020, 15:14

I meant uncheck the box here.
Attachments
Снимок.PNG
Снимок.PNG (15.26 KiB) Viewed 1203200 times

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests