Energy measurement with espeasy and pzem-004t
Moderator: leecollings
Re: Energy measurement with espeasy and pzem-004t
Hi !
i am trying to connect 2 PZEM-004t V3 on a Wemos D1 mini pro with ESP Easy then link them to Domoticz. The purpose is to monitor consuption and solar production.
I read many posts here and on "Let's Control it" forum, but i get lost now, like "papperone" wrote on the Let's control forum
-many different solutions, but not in the same unique post, so i can't understand wich software comes with wich wiring !
All of the authors are great to share their work, and i feel ashame not understanding all their explanations
I tried multi softwareserial solution from aleph0 (ESPEasy-2.0.0-dev12_test_4096.bin.zip), with two modules: the system polls (i see the same led on PZEM flashing 12 times on each PZEM one after the other ( i suppose it is espeasy request to the PZEM) without any reponse.
The same happens when swapping RX and TX, just the led flashing is different.
By the way, i can't be sure which is the right Rx/Tx wiring as i don't understand the comment under Software serial gpios field.
I didn't made any 5v to 3.3V conversion, but i have an ESP32 is working like that with HW serial, but could it be a direction ?
Does the pins in Espeasy hardware has to be set (input or output)?
I loaded "firmware_PZEM004T multiple.bin" wich looks like a sequential polling of the PZEM 5V, but hardly imagine the wiring
So if someone could kindly link or post a working solution (software and wiring) ?
i am trying to connect 2 PZEM-004t V3 on a Wemos D1 mini pro with ESP Easy then link them to Domoticz. The purpose is to monitor consuption and solar production.
I read many posts here and on "Let's Control it" forum, but i get lost now, like "papperone" wrote on the Let's control forum
-many different solutions, but not in the same unique post, so i can't understand wich software comes with wich wiring !
All of the authors are great to share their work, and i feel ashame not understanding all their explanations
I tried multi softwareserial solution from aleph0 (ESPEasy-2.0.0-dev12_test_4096.bin.zip), with two modules: the system polls (i see the same led on PZEM flashing 12 times on each PZEM one after the other ( i suppose it is espeasy request to the PZEM) without any reponse.
The same happens when swapping RX and TX, just the led flashing is different.
By the way, i can't be sure which is the right Rx/Tx wiring as i don't understand the comment under Software serial gpios field.
I didn't made any 5v to 3.3V conversion, but i have an ESP32 is working like that with HW serial, but could it be a direction ?
Does the pins in Espeasy hardware has to be set (input or output)?
I loaded "firmware_PZEM004T multiple.bin" wich looks like a sequential polling of the PZEM 5V, but hardly imagine the wiring
So if someone could kindly link or post a working solution (software and wiring) ?
-
- Posts: 85
- Joined: Thursday 12 May 2016 15:47
- Target OS: Linux
- Domoticz version: 11838
- Location: South of France
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Did you put 220v on the pzem while trying ? Mine does not respond without 220v
Edit : I just read again the thread on let's control it and they say the protocol have changed for pzem v3 ; my precompiled firmware won't work with those ones, sorry
Edit : I just read again the thread on let's control it and they say the protocol have changed for pzem v3 ; my precompiled firmware won't work with those ones, sorry
Re: Energy measurement with espeasy and pzem-004t
OK,thanks for your answer
Yes i tried it with 220v, but if the protocol has changed, i can understand the lack of answers ( library pzemt30v30 ?).
just have to find a 3.0 solution
Yes i tried it with 220v, but if the protocol has changed, i can understand the lack of answers ( library pzemt30v30 ?).
just have to find a 3.0 solution
Re: Energy measurement with espeasy and pzem-004t
So i solved my problem abandoning Espeasy and using multi instances of Software serial, it works even if it not the most elegant way
-
- Posts: 112
- Joined: Monday 26 June 2017 21:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Spain
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Tasmota is suposed to work, i'll test in a few daysSherco49 wrote:So i solved my problem abandoning Espeasy and using multi instances of Software serial, it works even if it not the most elegant way
Enviado desde mi Mi A2 mediante Tapatalk
-
- Posts: 4
- Joined: Wednesday 05 February 2020 7:40
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Hi, pzem users!
Is there any way to calclate day/night power consumption with esp and pzem004 connected to it?
I have already four virtual counters in my Domoticz system for: Voltage, Current, Energy and Power (delivered by espeasy rules from WeMos D1 mini).
The problem is in that Power is counted continiously as increasing value, and i need to divide it into two dummy counters: increasing day power consumtion (kWh) and the samre thing for the night time (kWh). Is it possible to do using some variables/scripts?
And for pzem-004 we have another problem - it drops power usage counter when it reaches 9999 value.
Is there any way to calclate day/night power consumption with esp and pzem004 connected to it?
I have already four virtual counters in my Domoticz system for: Voltage, Current, Energy and Power (delivered by espeasy rules from WeMos D1 mini).
The problem is in that Power is counted continiously as increasing value, and i need to divide it into two dummy counters: increasing day power consumtion (kWh) and the samre thing for the night time (kWh). Is it possible to do using some variables/scripts?
And for pzem-004 we have another problem - it drops power usage counter when it reaches 9999 value.
-
- Posts: 85
- Joined: Thursday 12 May 2016 15:47
- Target OS: Linux
- Domoticz version: 11838
- Location: South of France
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Hi !
This is the function I use for this usage
This is the function I use for this usage
Code: Select all
function pzem_read(pzem,HC,dev_V,dev_A,dev_W,dev_CP)
--[[Read measures from a pzem in a 3Amps device
and dispatch measures for voltage, current and power in corresponding devices
Input :
pzem : type 3phase current
HC : switch "On"=night time
Output :
dev_V : type voltage
dev_A : type current
dev_W : type P1 smart counter
dev_CP : type custom, for cos phi
Variable : you need to create a variable with the same name as the pzem device followed by _idx to store the index
]]--
local u1, u2, p1, p2
local val_V,val_A,val_W,val_Wh
local local_dbg=0
old_Wh=uservariables[pzem.."_idx"]
u1, u2, p1, p2 = string.match(otherdevices_svalues[dev_W],"(.-);(.-);(.-);(.-);.*")
-- Usefull for newly created counters
u1=u1 or 0
u2=u2 or 0
p1=p1 or 0
p2=p2 or 0
val_V,val_A,val_W,val_Wh=string.match(otherdevices_svalues[pzem],"(.-);(.-);(%d*);(%d*)")
if local_dbg==1 then
print(otherdevices_svalues[pzem])
print("V "..val_V)
print("A "..val_A)
print("W "..val_W)
print("Wh "..val_Wh)
print("Old Wh "..old_Wh)
print("------")
end
if tonumber(val_V)>1 then UpdateDev(dev_V,0,val_V) end
UpdateDev(dev_A,0,val_A)
if tonumber(val_A)>0 and tonumber(val_W)>0 then
-- If we don't have a measurement for voltage, we take previous one
if tonumber(val_V)==0 then val_V=otherdevices[dev_V] end
val_CP=val_W/val_V/val_A
if local_dbg==1 then
print("V "..val_V)
print("A "..val_A)
print("W "..val_W)
print("CP "..val_CP)
end
if val_CP>=0 and val_CP<=1 then UpdateDev(dev_CP,0,round(val_CP,2)) end
end
if tonumber(val_Wh)>=tonumber(old_Wh) then
if otherdevices[HC] == 'Off' then
-- svalue=USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD
UpdateDev(dev_W,0,tostring(u1+val_Wh-old_Wh)..';'..tostring(u2)..';0;0;'..tostring(val_W)..';0')
else
UpdateDev(dev_W,0,tostring(u1)..';'..tostring(u2+val_Wh-old_Wh)..';0;0;'..tostring(val_W)..';0')
end
end
if val_Wh>0 then UpdateVar(pzem.."_idx",val_Wh) end
end
Re: Energy measurement with espeasy and pzem-004t
NiCOOLaS wrote: ↑Thursday 23 January 2020 14:08Can you please show full script and how it's runyo3hjv wrote: ↑Thursday 25 April 2019 4:22 Hello and thank you for the nice "How to".
I did it and it is working.
Seems to work properly, I also included the ">0" mod.
I have only one observation: the "Current" value is showing the last maximum current.
I wonder if someone can help me with LUA script to make the "Current" show the "now" value of the current.
Thank you and please forgive my stupidity.
LE. I think I got it like this:
if tonumber(val_V)>1 then UpdateDev(dev_V,0,val_V)
UpdateDev(dev_A,0,val_A) end
-- if tonumber(val_A)>0 then UpdateDev(dev_A,0,val_A) end--
Sorry for late answer!
Here is the code:
Code: Select all
--[[Script to read infos from espeasy/pzem-004t and disptach it in correct devices
]]--
-- Edit the dummies name below to match yours
local dev_HC ="Elec happy hours"
local dev_pzem1 ="pzem1"
local dev_V1 ="Retea"
local dev_A1 ="Curent_Instant"
local dev_W1 ="Consum"
-- End of user-edit part
function UpdateVar(variable,valeur)
--Update une variable Domoticz
commandArray[#commandArray+1] = {['Variable:'..variable] = tostring(valeur)}
end
function UpdateDev(device,nvalue,svalues)
--Met à jour un device numérique Domoticz
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[device]..'|'..tostring(nvalue)..'|'..tostring(svalues)}
end
function pzem_read(pzem,HC,dev_V,dev_A,dev_W)
--[[Read values from a 3ph-amp dummies and dispatch them in sensor for voltage, current, and power
Input :
pzem : type 3ph amp, updated by espeasy
HC : switch "On"=happy hours for electricity
Output :
dev_V : type voltage
dev_A : type current
dev_W : P1 smart counter
]]--
local u1, u2, p1, p2
local val_V,val_A,val_W,val_Wh
local local_dbg=0
old_Wh=uservariables[pzem.."_idx"]
u1, u2, p1, p2 = string.match(otherdevices_svalues[dev_W],"(.-);(.-);(.-);(.-);.*")
-- Usefull for newly created counters
u1=u1 or 0
u2=u2 or 0
p1=p1 or 0
p2=p2 or 0
val_V,val_A,val_W,val_Wh=string.match(otherdevices_svalues[pzem],"(.-);(.-);(%d*);(%d*)")
if local_dbg==1 then
print(otherdevices_svalues[pzem])
print(val_V)
print(val_A)
print(val_W)
print(val_Wh)
end
if tonumber(val_V)>1 then UpdateDev(dev_V,0,val_V)
UpdateDev(dev_A,0,val_A) end
-- if tonumber(val_A)>0 then UpdateDev(dev_A,0,val_A) end--
if tonumber(val_Wh)>=tonumber(old_Wh) then
if otherdevices[HC] == 'Off' then
-- svalue=USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD
UpdateDev(dev_W,0,tostring(u1+val_Wh-old_Wh)..';'..tostring(u2)..';0;0;'..tostring(val_W)..';0')
else
UpdateDev(dev_W,0,tostring(u1)..';'..tostring(u2+val_Wh-old_Wh)..';0;0;'..tostring(val_W)..';0')
end
UpdateVar(pzem.."_idx",val_Wh)
end
end
commandArray = {}
if devicechanged[dev_pzem1] then pzem_read(dev_pzem1,dev_HC,dev_V1,dev_A1,dev_W1) end
return commandArray
I monitor the instant current even when there is no consumption. I like to see when it's starting and when it's stopping.
Best regards, Adrian
-
- Posts: 3
- Joined: Saturday 16 March 2019 10:37
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Bonjour, je suis ce fil depuis quelques jours et n'arrive pas à m'en sortir seul.
J'ai un seul PZEM-004T V30 sur WEMOS D1 Mini et tourne sur un firmware perso ESPEASY.
J'ai bien mes valeurs dans ESPEASY, je n'arrive à envoyer que Voltage dans Domoticz.
J'ai essayé avec Rules par plusieurs moyens dans Domoticz (capteurs virtuels....) mais je ne reçoit rien
Rules Espeasy
on PZEM#Current do
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1402&nvalue=0&svalue=[PZEM#Voltage]
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1403&nvalue=0&svalue=[PZEM#Current]
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1404&nvalue=0&svalue=[PZEM#Power]
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1405&nvalue=0&svalue=[PZEM#Energy]
endon
J'ai un seul PZEM-004T V30 sur WEMOS D1 Mini et tourne sur un firmware perso ESPEASY.
J'ai bien mes valeurs dans ESPEASY, je n'arrive à envoyer que Voltage dans Domoticz.
J'ai essayé avec Rules par plusieurs moyens dans Domoticz (capteurs virtuels....) mais je ne reçoit rien
Rules Espeasy
on PZEM#Current do
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1402&nvalue=0&svalue=[PZEM#Voltage]
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1403&nvalue=0&svalue=[PZEM#Current]
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1404&nvalue=0&svalue=[PZEM#Power]
SendToHTTP 192.168.1.151,8080,/json.htm?type=command¶m=udevice&idx=1405&nvalue=0&svalue=[PZEM#Energy]
endon
-
- Posts: 3
- Joined: Saturday 16 March 2019 10:37
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Je ne sais pas ce que j'ai oublié dans Domoticz ou ESPEASY.
Merci de m'aider
-
- Posts: 20
- Joined: Saturday 09 January 2021 18:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
can some please help me with this subject or renew it i can't see the pictures,
-
- Posts: 317
- Joined: Thursday 12 January 2017 15:30
- Target OS: Linux
- Domoticz version: Beta Ch
- Location: Finland
- Contact:
Re: Energy measurement with espeasy and pzem-004t
All pictures are there
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
-
- Posts: 1
- Joined: Saturday 12 February 2022 19:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Hi,
Are you able to share the original pictures of the beginning of this tread ?
I can not see its...
Sorry
Eric
Are you able to share the original pictures of the beginning of this tread ?
I can not see its...
Sorry
Eric
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Please reload the page. Something's the webserver acts strange.I can see all the images.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Energy measurement with espeasy and pzem-004t
That means you allow to show external links that have an invalid certificate!
SO... those images are stored on server with a different domainname than the link contains ...hence the CERT error and them not being displayed.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 86
- Joined: Friday 08 November 2019 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Thanks, it works great for now. only kWh need to be converted to Wh P1 meter ( Domoticz)
- psubiaco
- Posts: 194
- Joined: Monday 20 August 2018 9:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Italy
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Maybe you can try the new PZEM plugin that permits to connect up to 51 PZEM meters to the same bus, using a cheap RS485/USB adapter or RS485/net/wifi module: https://github.com/CreasolTech/domoticz-pzem-016
Actually it was tested with PZEM-004T, PZEM-014 and PZEM-016.
Device names can be translated in your preferred language: if you write here the translated device names and language code, I can add that language in the plugin.
Many thanks for any feedback / suggestion / translation !
Actually it was tested with PZEM-004T, PZEM-014 and PZEM-016.
Device names can be translated in your preferred language: if you write here the translated device names and language code, I can add that language in the plugin.
Many thanks for any feedback / suggestion / translation !
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
-
- Posts: 7
- Joined: Wednesday 03 January 2024 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Energy measurement with espeasy and pzem-004t
Thanks for making this!!!!psubiaco wrote: ↑Thursday 21 December 2023 11:48 Maybe you can try the new PZEM plugin that permits to connect up to 51 PZEM meters to the same bus, using a cheap RS485/USB adapter or RS485/net/wifi module:
Actually it was tested with PZEM-004T, PZEM-014 and PZEM-016.
Device names can be translated in your preferred language: if you write here the translated device names and language code, I can add that language in the plugin.
Many thanks for any feedback / suggestion / translation !
Unfortunately I just can't read data my PZEM-004T has both tx,/Rx LEDs flashing, and if I flip the polarity of the rs 485 they stop. I'm using a pi with a usb 2wire 485:adapter as shown on the GitHub tutorial. I installed plugin via the plugin manager. I'm not sure if this is an issue with pyserial or the other module? I've tried installing pyserial bit get thrown an error.. is this installed as part of the plugin? Same with the other file.
I'm selecting USB0 from the drop-down
Any help obviously appreciated.
Who is online
Users browsing this forum: No registered users and 1 guest