Support for PZEM 004T Energy monitor
Moderators: grovkillen, Stuntteam, TD-er
Re: Support for PZEM 004T Energy monitor
Hello, im New in forum and If that can help, Ill be glad.
https://github.com/apreb/eNode
https://github.com/apreb/eNode
Re: Support for PZEM 004T Energy monitor
Hmm, that looks like a nice project to read aboutGermil wrote: ↑15 Nov 2017, 21:38 Hello, im New in forum and If that can help, Ill be glad.
https://github.com/apreb/eNode
Re: Support for PZEM 004T Energy monitor
Hi all,
here is a fix for the problem of parameters being taken into account only at boot. Now things can be changed on the fly by re-doing initialisation at every "submit" of the form :
Sorry, I don't know how to use git to make pull requests this will come also, please bear with my learning curve
I also found a workaround to have several modules using the "port" feature of espeasy but it's a bit ugly ; if anybody have urgent need of many module I can publish, if not I'll wait to find a better solution !
here is a fix for the problem of parameters being taken into account only at boot. Now things can be changed on the fly by re-doing initialisation at every "submit" of the form :
Code: Select all
//#######################################################################################################
//################### Plugin 171 PZEM-004T AC Current and Voltage measurement sensor ####################
//#######################################################################################################
//
// This plugin is interfacing with PZEM-004T Sesor with softserial communication as the sensor
// has an UART pinout (TX/RX/VCC/GND)
//
#ifdef PLUGIN_BUILD_TESTING
#include <SoftwareSerial.h>
#include <PZEM004T.h>
PZEM004T *Plugin_171_pzem;
IPAddress pzemIP(192,168,1,1); // required by the library but not used (dummy value)
boolean Plugin_171_init = false;
#define PLUGIN_171
#define PLUGIN_ID_171 171
#define PLUGIN_171_DEBUG true //activate extra log info in the debug
#define PLUGIN_NAME_171 "Voltage & Current (AC) - PZEM-004T [TESTING]"
#define PLUGIN_VALUENAME1_171 "Voltage (V)"
#define PLUGIN_VALUENAME2_171 "Current (A)"
#define PLUGIN_VALUENAME3_171 "Power (W)"
#define PLUGIN_VALUENAME4_171 "Energy (Wh)"
// local parameter for this plugin
#define PZEM_MAX_ATTEMPT 3
boolean Plugin_171(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_171;
Device[deviceCount].Type = DEVICE_TYPE_DUAL;
Device[deviceCount].VType = SENSOR_TYPE_QUAD;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
Device[deviceCount].ValueCount = 4;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].GlobalSyncOption = false;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_171);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_171));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_171));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_171));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[3], PSTR(PLUGIN_VALUENAME4_171));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
addFormNote(string, F("SoftSerial: 1st=to TX-Pin, 2nd=to RX-Pin"));
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
Plugin_171_init = false;
success = true;
break;
}
case PLUGIN_READ:
{
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: Reading started.");
addLog(LOG_LEVEL_INFO, log);
}
float pzVoltage = Plugin171_ReadVoltage();
float pzCurrent = Plugin171_ReadCurrent();
float pzPower = Plugin171_ReadPower();
float pzEnergy = Plugin171_ReadEnergy();
//-------------------------------------------------------------------
// readings can be ZERO if there's no AC input on the module.
// in this case V A and W are reported correctly as ZERO but
// the accumulated Energy paramenter will not be saved so to
// preserve previous value
//-------------------------------------------------------------------
UserVar[event->BaseVarIndex] = pzVoltage;
UserVar[event->BaseVarIndex + 1] = pzCurrent;
UserVar[event->BaseVarIndex + 2] = pzPower;
if (pzEnergy>=0) UserVar[event->BaseVarIndex + 3] = pzEnergy;
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: Voltage="); log += pzVoltage; log += F(" V");
addLog(LOG_LEVEL_INFO, log);
log = F("PZEM004T: Current="); log += pzCurrent; log += F(" A");
addLog(LOG_LEVEL_INFO, log);
log = F("PZEM004T: Power="); log += pzPower; log += F(" W");
addLog(LOG_LEVEL_INFO, log);
log = F("PZEM004T: Energy="); log += pzEnergy; log += F(" Wh");
addLog(LOG_LEVEL_INFO, log);
}
success = true;
break;
}
case PLUGIN_INIT:
{
if (!Plugin_171_init)
{
int pzemRXpin = Settings.TaskDevicePin1[event->TaskIndex];
int pzemTXpin = Settings.TaskDevicePin2[event->TaskIndex];
Plugin_171_pzem = new PZEM004T(pzemRXpin, pzemTXpin);
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: Object Initialized");
log += F(" - RX-Pin="); log += pzemRXpin;
log += F(" - TX-Pin="); log += pzemTXpin;
addLog(LOG_LEVEL_INFO, log);
}
Plugin_171_pzem->setAddress(pzemIP); // This initializes the PZEM004T library using a (useless) fake IP address
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: setup address (dummy)");
log += F(" - "); log += pzemIP;
addLog(LOG_LEVEL_INFO, log);
}
}
Plugin_171_init = true;
success = true;
break;
}
}
return success;
}
//************************************//
//***** reading values functions *****//
//************************************//
// NOTE: readings are attempted only PZEM_AMX_ATTEMPT times
float Plugin171_ReadVoltage() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->voltage(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (reading == -1) reading = 0;
if (PLUGIN_171_DEBUG) {
String log = F("Voltage try :"); log += counter;
addLog(LOG_LEVEL_DEBUG, log);
}
return reading;
}
float Plugin171_ReadCurrent() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->current(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (reading == -1) reading = 0;
if (PLUGIN_171_DEBUG) {
String log = F("Current try :"); log += counter;
addLog(LOG_LEVEL_DEBUG, log);
}
return reading;
}
float Plugin171_ReadPower() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->power(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (reading == -1) reading = 0;
if (PLUGIN_171_DEBUG) {
String log = F("Power try :"); log += counter;
addLog(LOG_LEVEL_DEBUG, log);
}
return reading;
}
float Plugin171_ReadEnergy() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->energy(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (PLUGIN_171_DEBUG) {
String log = F("Energy try :"); log += counter;
addLog(LOG_LEVEL_DEBUG, log);
}
return reading;
}
#endif
I also found a workaround to have several modules using the "port" feature of espeasy but it's a bit ugly ; if anybody have urgent need of many module I can publish, if not I'll wait to find a better solution !
Re: Support for PZEM 004T Energy monitor
Hi,
Great plugin!
All values show correctly in the web interface that runs on the esp.
At first, some values weren't Always displayed.
I solved that by using another power supply for the 5v supply for the pzem004t.
Maybe some other users can solve their problems reading the values knowing that.
Now, I can add the pzem to Domoticz without problems, only one value is displayed.. The voltage. Other then that, nothing shows.
I was wondering if it would be possible to choose an IDX for each value of the sensor?
I don't know if that is possible at all in esp-easy?
It would help me out a lot.
Since I'm not a die hard coder, I can't do it myself...
Hope someone can help!
Keep up the good work!
\
Best regards,
Frank.
Great plugin!
All values show correctly in the web interface that runs on the esp.
At first, some values weren't Always displayed.
I solved that by using another power supply for the 5v supply for the pzem004t.
Maybe some other users can solve their problems reading the values knowing that.
Now, I can add the pzem to Domoticz without problems, only one value is displayed.. The voltage. Other then that, nothing shows.
I was wondering if it would be possible to choose an IDX for each value of the sensor?
I don't know if that is possible at all in esp-easy?
It would help me out a lot.
Since I'm not a die hard coder, I can't do it myself...
Hope someone can help!
Keep up the good work!
\
Best regards,
Frank.
Re: Support for PZEM 004T Energy monitor
Sorry for late reply but I missed your post; you are right about the bug on save changin parameter, it's enough to destroy the object so it will be recreated on the init (no need of the boolean flag), I will submit this bug-fix asap.aleph0 wrote: ↑19 Nov 2017, 18:13 Hi all,
here is a fix for the problem of parameters being taken into account only at boot. Now things can be changed on the fly by re-doing initialisation at every "submit" of the form :
[ CODE ]
Sorry, I don't know how to use git to make pull requests this will come also, please bear with my learning curve
I also found a workaround to have several modules using the "port" feature of espeasy but it's a bit ugly ; if anybody have urgent need of many module I can publish, if not I'll wait to find a better solution !
Can you please explain better what you mean with "port feature of espeasy" so I can implement the multiple sensor support? (you can share your code even via PM and I can incorporate with my plugin and publish it on GitHub to be tested)
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
Re: Support for PZEM 004T Energy monitor
Hello aleph0, could you put the compiled firmware with the plugin PZET-004?
Re: Support for PZEM 004T Energy monitor
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 !
- Attachments
-
- ESPEasy-2.0.0-dev12_test_4096.bin.zip
- (401.93 KiB) Downloaded 7883 times
Re: Support for PZEM 004T Energy monitor
Have a look here for a workaround viewtopic.php?p=20595#p20595
Re: Support for PZEM 004T Energy monitor
Ok thanks,
I must have overlooked that...
I never used code in domoticz before. How do I use it?
I googled and looked in the wiki pages. But can't find an answer to it?
Maybe I'm not looking at the right places?
I must have overlooked that...
I never used code in domoticz before. How do I use it?
I googled and looked in the wiki pages. But can't find an answer to it?
Maybe I'm not looking at the right places?
Re: Support for PZEM 004T Energy monitor
Thank you very much, everything turned out, but as with many, only the voltage in domoticz is output, you gave an example above how to prescribe, so that this does not happen-I did not understand which folder I should throw it in?
Re: Support for PZEM 004T Energy monitor
I figured out the numeric values, but when I open the log, it's empty (((
Re: Support for PZEM 004T Energy monitor
I have put the code in the file device.Lua?
Don't know for sure if this is the correct file? Or how to do this correctly.
I do get four separate values now, as shown in the picture below.
But indeed the log stays empty.
Hope you can help me out here.
At least I want to log Voltage and Current.
So I hope this will be possible with my setup
Many thanks for all the help.
Don't know for sure if this is the correct file? Or how to do this correctly.
I do get four separate values now, as shown in the picture below.
But indeed the log stays empty.
Hope you can help me out here.
At least I want to log Voltage and Current.
So I hope this will be possible with my setup
Many thanks for all the help.
Re: Support for PZEM 004T Energy monitor
Hi!
Regarding domoticz code, you have two choices :
- either you copy it in the domoticz/script/lua folder with a name ending by _device.lua eg pzem_device.lua
- either you go to the tools menu->more-> events, create a new "lua" "device" script named as you want and replace the default content by the code I posted
You also need to edit the first lines of the script starting by local dev,_... to match the name of your own devices
Btw, it's normal for the dummy pzem log to be empty as we overload the object. You'll get the log from the devices managed by the script
Hope it helps !
Regarding domoticz code, you have two choices :
- either you copy it in the domoticz/script/lua folder with a name ending by _device.lua eg pzem_device.lua
- either you go to the tools menu->more-> events, create a new "lua" "device" script named as you want and replace the default content by the code I posted
You also need to edit the first lines of the script starting by local dev,_... to match the name of your own devices
Btw, it's normal for the dummy pzem log to be empty as we overload the object. You'll get the log from the devices managed by the script
Hope it helps !
Re: Support for PZEM 004T Energy monitor
Thanks a lot!
I will look into that after work.
I have been looking for some setting regarding lua scripts as I thought I had to look in thst way. But didn't find any...
Now... I may have overlooked it, but can it be a specific version when it was introduced?
If i click update, It says it's the latest.
Thanks again!
I will look into that after work.
I have been looking for some setting regarding lua scripts as I thought I had to look in thst way. But didn't find any...
Now... I may have overlooked it, but can it be a specific version when it was introduced?
If i click update, It says it's the latest.
Thanks again!
Re: Support for PZEM 004T Energy monitor
it is not entirely clear what to prescribe after dev, could you describe in more detail, since I'm new to this and I'm hard at programming, thank you in advance
Re: Support for PZEM 004T Energy monitor
I can understand . This issue is now purely related to domoticz and not espeasy. So far, espeasy is doing the job correctly If it's ok for you all, I'll open a thread on the domoticz forum and upload a detailed tutorial over there. It'll be this week-end as I have no time for this during the week ; I'll post the link here when I'm done with it
Re: Support for PZEM 004T Energy monitor
That would be great!
Thanks!
Thanks!
Re: Support for PZEM 004T Energy monitor
we will wait, thank you
Re: Support for PZEM 004T Energy monitor
Hi All !
Here is the link to topic on the domoticz forum on how to retreive the pzem values :
https://www.domoticz.com/forum/viewtopi ... 14&t=20820
Please note that in that post, I updated the domoticz script compared to the one I posted here previously to fix a few bugs, and for more accurate measurements
Feedback is welcome !
Here is the link to topic on the domoticz forum on how to retreive the pzem values :
https://www.domoticz.com/forum/viewtopi ... 14&t=20820
Please note that in that post, I updated the domoticz script compared to the one I posted here previously to fix a few bugs, and for more accurate measurements
Feedback is welcome !
Re: Support for PZEM 004T Energy monitor
Hi, I did everything as you do, but in the device tab, the values are shown, and when you switch to auxiliary values by zero, what else could it be? It is not entirely clear what values to write when assigning a variable? Same as you on the screen or others?
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
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 !
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
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?
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.
-
- 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?
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,
Re: Support for PZEM 004T Energy monitor
Hi. giruchile, could you put the compiled firmware with the plugin PZET-004 ?
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
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>
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 ?
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,
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
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 mispelled )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" }
After that, I was able to compile espeasy with the plugin and send it to the esp via OTA
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 ?
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 ?
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
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
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
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
Re: Support for PZEM 004T Energy monitor
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.
Who is online
Users browsing this forum: No registered users and 128 guests