arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.04k stars 4.78k forks source link

DC meter from Peacefair with RS485 #3694

Closed eazuka closed 5 years ago

eazuka commented 6 years ago

Having just read about the support for PZEM004T Energy Monitor from Peacefair. I'm just wondering if it will be possible to add support for PZEM-003 and PZEM-017 DC meter with RS485 from same manufacturer (Peacefair). I have use cases where Sonoff 4CH Pro, Sonoff SV & Shelly 1 will be used with PZEM-017 DC meter for DC (Solar) power metering and switching?

The PZEM-003 and PZEM-017 DC meter uses RS485 to communicate.

@arendst i can donate the PZEM-003 or PZEM-017 DC meter from Peacefair if you don't already have but think its possible to support it.

gio-dot commented 4 years ago

I'm quite sure that there you have to connect gnd and 3.3V coming from node mcu

skeletik07 commented 4 years ago

I'm quite sure that there you have to connect gnd and 3.3V coming from node mcu

Yes! It's working now! Thanks a lot! And one last question, please. How i can save data with current and power for making daily graps? With MQTT brockers? Or it's some easy other way? Making graps i will be doing in excel or matlab, so i can save data in txt or some other text format.

gio-dot commented 4 years ago

I use home assistant to manage all domotic stuff.

skeletik07 commented 4 years ago

But can i take exectly the digits of power and current in home assistant? Because i'm gonna do some research work with this data and i need power measurement every 3/5 seconds and saving this stuff somewhere i can operate with this

rt45433 commented 4 years ago

I am using the pzem-017 and have got it working with tasmota. Just wanted to ask if there was a way to read the soc state or charge reading so I can use this through tasmato or have I missed it somewhere. I need this as I turn of my solar charger at 80% soc of the battery so want to see if I can did it using the pzem-017 and tasmota. Any help would be appreciated.

gio-dot commented 4 years ago

I am using the pzem-017 and have got it working with tasmota. Just wanted to ask if there was a way to read the soc state or charge reading so I can use this through tasmato or have I missed it somewhere. I need this as I turn of my solar charger at 80% soc of the battery so want to see if I can did it using the pzem-017 and tasmota. Any help would be appreciated.

It is not possible: soc calculation is very hard task that depend of a huge number of variables. It is not possible to calculate soc without knowing all those variables (battery type, battery capacity, battery state of healt, temperature, charge/discharge current, etc.)

rt45433 commented 4 years ago

Thanks for the reply and information. I will use it with the data it currently has. Thanks again 👍 -)

kittipongpoosri commented 3 years ago

I need to code

kittipongpoosri commented 3 years ago

āļ‰āļąāļ™āļ•āđ‰āļ­āļ‡āļāļēāļĢāļĢāļŦāļąāļŠāđ€āļžāļ·āđˆāļ­āđƒāļŠāđ‰āļāļąāļš esp8266

Oleg-Sob commented 3 years ago

22

Installed PZEM -017, everything works, the voltage shows an integer, tell me how you can make the voltage show with tenths or better hundredths.

austrisv commented 3 years ago

@Oleg-Sob it's VoltRes # https://tasmota.github.io/docs/Commands/

Oleg-Sob commented 3 years ago

Thank you very much, it worked out.

Oleg-Sob commented 3 years ago

It is not possible to calibrate the current in PZEM 017, it does not respond to the CurrentSet and CurrentCal commands. Tell me why.

Oleg-Sob commented 3 years ago

And the voltage fails to correct VoltageCal and VoltageSet does not respond, writes {"Command": "Error"}.

seliku commented 3 years ago

I am using the pzem-017 and have got it working with tasmota. Just wanted to ask if there was a way to read the soc state or charge reading so I can use this through tasmato or have I missed it somewhere. I need this as I turn of my solar charger at 80% soc of the battery so want to see if I can did it using the pzem-017 and tasmota. Any help would be appreciated.

It is not possible: soc calculation is very hard task that depend of a huge number of variables. It is not possible to calculate soc without knowing all those variables (battery type, battery capacity, battery state of healt, temperature, charge/discharge current, etc.)

Hi, I also have a PZEM-017 setup with a D1-Mini on my battery. Included are a tempsensor and 2 relays (heating-pads and fan). Throug rules Tasmota manages the health of the battery in addition of an BMS. The battery is getting charged from multiple sources. For example a charger hooked up to mains, solar panel charger and other small experimental generators. So far so good. Works like a charm.

My only wish would be that Tasmota + PZEM-017 would distinguish between charging and discharging. At the moment it only shows one (mixed) value. So if I am using 200 Watts and simultanious charging 50 Watts it shows 150 Watts. Or if I am using 50 Watts and charging 200 Watts it also shows 150 Watts.

Is my consuption correct that the only solution is to use two different sets (Tasmota + PZEM-017) for each discharging and charging and doing the maths through rules or externaly?

Oleg-Sob commented 3 years ago

You can use INA219 or INA226, they show both + and -.

Oleg-Sob commented 3 years ago

I use PZEM-17 to measure the charge of batteries, if used to measure charge and discharge, it summarizes everything as positive and it is not clear how much charge, how much discharge.

seliku commented 3 years ago

Thanks for the reply. I have those INAs but they are specified for small loads. Can I connect them to a 300A shunt?

It looks like INA226 should do the trick. Its worth a try. I will post my results here.

Oleg-Sob commented 3 years ago

Yes, you can, and calibrate the readings with the formula. The microcircuit measures the drop to 320 mV, a 300a 75mv shunt will give a drop of 225mV

Oleg-Sob commented 3 years ago

It is necessary to use INA219, 226 measures a drop of 80 mV

seliku commented 3 years ago

The INA219 meassures a max of 26V and has an internal shunt for max 3.2A As I understood the INA226 can be used with an external shunt and max 36V

Oleg-Sob commented 3 years ago

26v this voltage, if you need to measure a higher voltage, you can put a divider.

Oleg-Sob commented 3 years ago

The current is measured on the shunt, the INA 219 has a drop on the 320mV shunt for the INA 226 to 80mV, on the INA226 the maximum shunt can be put at 100A 75mV

seliku commented 3 years ago

I see. Then I will test this with the INA219. It would be wonderfull if this works. Thanks again

jalakamkiranadspl commented 3 years ago

Hey has anyone supposed to find the schematics of PZEM 004t I am not able to get it anywhere in the internet?

Oleg-Sob commented 3 years ago

Connection diagram, or electrical of the device itself?

jalakamkiranadspl commented 3 years ago

Electrical of the device itself

Oleg-Sob commented 3 years ago

I didn’t find either.

jalakamkiranadspl commented 3 years ago

I think I have found something. Actually a friend did. https://www.youtube.com/watch?v=qRsjsenvlJA Check this video out.

ukewea commented 3 years ago

how to connect PZEM 017 DC with nodemcu ?

I recently made a modification to make it possible to connect a PZEM-017 with ESP32 directly (i.e., without RS485 converter), here's what I've done:

Note: after modification, you must supply 3.3V to the terminal instead of the original 5V.

austrisv commented 3 years ago

Thank you @vicfergar for the original idea and @ukewea for follow-up. Very helpful! I got my 017 connected and looks like all good. I did disconnect only TX pin of MAX485 (was too lazy to remove the chip). I wonder, is it ok if I'm feeding the data side from ESP's 3V3 pin? Tested and it's working. Or shall I rather go with proper 5V from usb and 2k pulldowns? (power side will be 12V, just in case) image

ukewea commented 3 years ago

Thank you @vicfergar for the original idea and @ukewea for follow-up. Very helpful! I got my 017 connected and looks like all good. I did disconnect only TX pin of MAX485 (was too lazy to remove the chip). I wonder, is it ok if I'm feeding the data side from ESP's 3V3 pin? Tested and it's working. Or shall I rather go with proper 5V from usb and 2k pulldowns? (power side will be 12V, just in case)

If someone's having similar question, a 3-month testing tells me that it's ok to feed the data directly from ESP, without pulldowns or anything else in between, and it's reporting data to my Home Assistant server nicely.

Also, I didn't put a resister between the TX of PZEM017 and ESP's RX.

KNXfriend commented 2 years ago

Thank you all for this great ideas and work!

I am currently prepring to monitor my boatÂīs batteries with this solution in the winterstock, while some systems stay up and online there. This is possible because of energy harvesting by solar panels and wind generator. But this includes the neccessarity to count not only one way. The batteries are charged over the day, while in the night the consumption typically is higher. So far I understand, that the PZEM 017 can only measure one way. ThatÂīs why I am thinking to take simply two, connect them to the same shunt, but one other way round connected. Since the PZEMs did not arrive so far, I cannot test it, but generally it should work. The only thing is - I donÂīt want to use an ESP for each.

Is there a way to enable the Tasmota software of one ESP to ask up to 4 different PZEMs over different modbus adresses? To give the different adresses to the PZEMs I found out so far.

The calculations about the energy balance sheet and taking Peukert factor into account would be calculated externally in the RasPI.

Target is a complete battery monitoring of service and starter batteries and the ability to manage the systems on the boat in dependency of the availability of energy.

Oleg-Sob commented 2 years ago

PZEM 017 measures the current in two directions, when there is a charge and the discharge, it counts everything with a + sign. Therefore, it will not be clear how much has been discharged, how much has been charged. Therefore, using two pieces will be useless.

Oleg-Sob commented 2 years ago

You can use INA 219, it measures in two directions with positive and negative readings.

KNXfriend commented 2 years ago

Thank you for this information. Now I will be aware, that this is possible. But from where you got this information? Because I find contradictory information in german forums. There it is described, that negative currents are floored to zero. Ina 219 looks promising beside that I liked the already hardened hardware for rough environment and the isolation over RS485, which can of course been realized with Ina 219 as well.

barbudor commented 2 years ago

You can have up to 3 PZEM max per tasmota. Also pzem and ina219 are very different things PZEM are for AC high voltage INA219 is for DC low voltage (max 30V)

Oleg-Sob commented 2 years ago

As for the PZEM 017, I also thought to put 2 pcs. in two directions, but it did not work out since they measure the negative current as positive. And I connected INA219 to a shunt of 100A and I measure the voltage 60V through a resistor divider 1/3, 20V comes to INA219, and in fact 60 and I adjust it with the formula.

KNXfriend commented 2 years ago

I understand, that my original plan might not work, like expected. I am still interested to understand, how to connect more than 1 PZEM to tasmota.

barbudor, can you enlighten me, how to connect up to 3?

I only understand to configure two GPIOs as serial interface for modbus PZEM communication. As far as I have seen, it seems that the modbus address for PZEM is hardcoded to 1 in the source code of tasmota. How to arrange, that tasmota is asking other adresses over the same bus? And why this is limited to 3?

barbudor commented 2 years ago

Searching a bit and you would have found https://github.com/arendst/Tasmota/discussions/10567

Up to know Tasmota has been designed for monitoring a single point of power. 3 is the maximum number of phases that you will encounter in real life.

KNXfriend commented 2 years ago

Ok. Then we are talking about different things. I am about battery monitoring, not about any ac or 3 phase applications.

Thank you for your fast answer.

That tasmota is currently designed for one connection to a PZEM corresponds to my still very little understanding of current solution.

I just wandered, if someone has ideas, how to use modbus as a real bus with tasmota and just ask several of this PZEM devices then only one.

I found a first hook in the source code, where tasmota communicates with exact this one PZEM adress and I might be able to extend this. But since I not really understand the whole tasmota architecture yet, I am afraid, I need some help.

barbudor commented 2 years ago

You asked about 3 PZEM, I told you:

To monitor batteries / DC, look at INA219/226 but be careful about ground management As fas as I remember only 1 of those is supported by ESP I know that someone on Discord is working on ina3221 driver which is a 3 channels. If it doesn't come quickly, I can do it too

Oleg-Sob commented 2 years ago

I have 2 pieces of PZEM 017 working. They work fine, I have not tried 3 pieces, but I think they will work.

667

barbudor commented 2 years ago

@Oleg-Sob Is that on AC or DC? If DC do you have to tell the PZEM about it (and how)?

barbudor commented 2 years ago

OK pzem017 is for dc My experience is with pzem004 which is ac

Oleg-Sob commented 2 years ago

PZEM 004 4 pieces work for me on one ESP 8266, though EspEasy firmware. 111

grappini commented 2 years ago

I have 2 pieces of PZEM 017 working. They work fine, I have not tried 3 pieces, but I think they will work.

667

What is the wiring diagram of the 2 pzem's with ESP 8266 ? Did you add the 2 pzem's to tasmota with ModuleAddress x command ?

KNXfriend commented 2 years ago

Ok. Seams that the feature is already existing up to 3 PZEMs. But your question grappini shows me, that not only I have problems to find this information.

I can still only guess, bcause I can not try, due to missing PZEMS. From the information what I think to understand now, there is the ModuleAddress 1/2/3 command, which probably sets the modbus adress to the PZEM device, which is currently on the bus.

When there are adress 1 and 2 or 1, 2 and 3 the tasmota automatically reads them all and represents them in the homescreen like seen above.(?)

That seams to be partially described in change log to 6.6.0.12 20190910 for me.

Thank you all, so activly helping here!

ortegafernando commented 2 years ago

I use PZEM-17 to measure the charge of batteries, if used to measure charge and discharge, it summarizes everything as positive and it is not clear how much charge, how much discharge.

Hi @Oleg-Sob @seliku what do you think about this option to "know" negative or positive values ? https://github.com/arendst/Tasmota/discussions/13733 Thanks

Oleg-Sob commented 2 years ago

Pzem 017 does not show negative currents, I use ina 226.