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
21.75k stars 4.72k forks source link

Adding support for PZEM004T energy monitor for 3 phase - request #2315

Closed roblad closed 4 years ago

roblad commented 6 years ago

Hi,

Is it possible add USE_PZEM004T and add support for PZEM004T Energy monitor for 3 phase by using USE_SERIAL_BRIDGE and report each phase through that functionality ? May be there is possibility to use 3 phase config for USE_PZEM004T as it is in that project:

https://github.com/apreb/eNode

rt400 commented 4 years ago

thanks.. i run it with 3 PZEM04 v3 and igot in console " PzemAc error 8" and error 7 , and still got all 0

adityama commented 4 years ago

This is a great news. I will try it at the earliest. I guess we still need to give correct addresses to the modules before connecting them together.

On Sun, 15 Sep, 2019, 8:52 PM Theo Arends, notifications@github.com wrote:

I changed both -004T and modbus versions so all should be supported.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arendst/Sonoff-Tasmota/issues/2315?email_source=notifications&email_token=ACEHVVIK7IB5745KIXHXMLTQJZHJXA5CNFSM4EYK56K2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6XS5MA#issuecomment-531574448, or mute the thread https://github.com/notifications/unsubscribe-auth/ACEHVVMVQL3WPF6PV2UQMHLQJZHJXANCNFSM4EYK56KQ .

rt400 commented 4 years ago

@arendst i try to use with this , all model allready set to 0.0.0.1 , 0.0.0.2 , 0.0.0.3 connect the rx tx to nodemcu model , isee in web that i have 3 model but they going down to 2 and stay in 1 . in web log i can't see anything...so strange

rt400 commented 4 years ago

i found my problem...the gnd was little bit out . now amazing its works... image

localhost61 commented 4 years ago

I follow this thread with great interest, as my goal to monitor on same modbus an SDM230 and two SDM120 is getting closer now ;-)

jziolkowski commented 4 years ago

Since the latest builds are not that common, I suggest changing the new command to something more specific, like PzemAddress in case more similar commands will appear in the future

meingraham commented 4 years ago

Or ModuleAddress <type>, <address> where e.g., <type> = PZEM to avoid a whole slew of new commands that are similar in function.

klotzma commented 4 years ago

What is the command now to change the address of the modules?

jziolkowski commented 4 years ago

No change, since Theo didn't reply with any decision nor any new commits pushed in this regard

klotzma commented 4 years ago

He added the command "Add command ModuleAddress 1/2/3" or not? Add command ModuleAddress 1/2/3

jziolkowski commented 4 years ago

Yes, it is in the commit and in the changelog

klotzma commented 4 years ago

So can I give the module the address with the command "ModuleAddress 1"?

adityama commented 4 years ago

@yuval I am at least couple of days away from testing the new code. Could you help test one specific scenerio - let's say one of the 3 phases is down, so you get the readings from remaining 2 phases. Would you be able to test this please.

On Tue, 17 Sep, 2019, 5:11 PM jziolkowski, notifications@github.com wrote:

Yes, it is in the commit and in the changelog

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arendst/Sonoff-Tasmota/issues/2315?email_source=notifications&email_token=ACEHVVM3KOAZLLKRYLJMTALQKC65BA5CNFSM4EYK56K2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64HUOY#issuecomment-532183611, or mute the thread https://github.com/notifications/unsubscribe-auth/ACEHVVLXNK4NNTGHS2CZVEDQKC65BANCNFSM4EYK56KQ .

jziolkowski commented 4 years ago

@klotzma yes, but you don't need to, since all PZEM modules have address 0.0.0.1 until specifically changed. So in practice you need to connect the module for L2 only and set it to address 2, and then only the module for L3 and set it address 3.

jziolkowski commented 4 years ago

@adityama I'm almost done building my 3 phase setup and could test that scenario for you. image

adityama commented 4 years ago

Your setup looks great. I need to find a similar enclosure 😊

On Tue, 17 Sep, 2019, 5:27 PM jziolkowski, notifications@github.com wrote:

@adityama https://github.com/adityama I'm almost done building my 3 phase setup and could test that scenario for you. [image: image] https://user-images.githubusercontent.com/11555742/65039659-0cb1c280-d953-11e9-9193-346a809763ed.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arendst/Sonoff-Tasmota/issues/2315?email_source=notifications&email_token=ACEHVVOH5XO266CBZU7JQSTQKDA4PA5CNFSM4EYK56K2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64I2WQ#issuecomment-532188506, or mute the thread https://github.com/notifications/unsubscribe-auth/ACEHVVJ6GQYVAMRN55BFONLQKDA4PANCNFSM4EYK56KQ .

jziolkowski commented 4 years ago

@arendst @adityama so I've done some testing.

Assembled the whole device, configured ModuleAddresses and started all. Then in TDM I've configured autotelemetry with 2-second interval and watched the readouts. As expected, when all 3phases are connected, telemetry has all three readings, but when I disconnected one device from AC while tasmota was online, the readings were inconsistent, as in: around 7-8 out of ten readings were correct (correct V, correct V, 0), but every now and then the telemetry returned [0,0,0].

2nd test wa booting the device with only 2 phases present on PZEMs. Device returns telemetry only for two phases, bt this time without 0 for the missing phase. Reconnecting the "missing" phase doesn't make the readings appear in the telemetry, because I've found that if PZEM is not connected to AC voltage during boot/sensor initialization, then it will remain inactive (doesn't return any readings and I'm 50/50 sure it even accepts commands, but the latter wasn't tested thoroughly by me).

I hope that helps. Let me know if any further testing is needed.

arendst commented 4 years ago

Thx for testing.

I'm currently offline. Will follow up this weekend.

jziolkowski commented 4 years ago

Solving the first "issue" will be great; if someone expects that some phases might be disconnected as a normal scenario, having consistent telemetry output is important.

2nd I understand. However, under some circumstances (when user has one phase offline) the PZEM will be offline as well, until next re-initialization of a fully connected PZEM. But it's not "our" fault, it's PZEM issue.

Thanks again for adding three phase support. Grafana charts will be glorious :)

roguestreak commented 4 years ago

(Pre-script; just realised there are two PZEM threads, so some may relate to the other thread) Thought it would be best to discuss/include in this thread for future user reference;

PS. I'm only on single phase, but greatly interested in using multiple CTs in future to monitor all circuits in the house; has anyone tested more than 3 addresses yet, purely from the data perspective rather than the web interface? I could query each address directly via NodeRed

jziolkowski commented 4 years ago

I've read that CTs should not be installed without termination, especially on high-current lines. Maybe it's my imagination, but when I was installing the CTs today, I first installed them on the wires which then were pulled live and when fiddling around with the cables I felt a small sting from a CT installed on a ~2A current wire. But it makes sense that a transformer can be damaged if the energy isn't being used.

No idea about the hack, but AFAIK PZEM always shows positive flow, irelevant of the current flow. IDK if it's in the chip nor is it configurable.

3 addresses is the newly expanded limitation of tasmota. It doesn't matte rif you dont need the webui interface: tasmota won't poll any more PZEMs than 3. Therefore, for monitoring multiple curcuits you would have to use a tasmota device per each three circuits. Also take note of the above tests I've did; if a PZEM is not connected to live AC during tasmota boot, it won't be recognized and its data will be ignored.

PS can't you get a PZEM with open clamp?

roguestreak commented 4 years ago

Thanks @jziolkowski I just found that this was in fact the one thread, just that many of the posts were collapsed; wondering whether using @adityama's serial method with NodeRed can address more than 3 units?

RE: current export detection, I believe the PZEM-004t doesn't have Pin 51 of the main SDIC SD3004 chip connected to anything, hence why it can't detect/specify direction, but the datasheet for the chip itself says the following of pin 51: "Goes high when phase difference between voltage and current is greater than 90 degrees. REVP updates its logic state when a CF pulse is issued." The THEORY is that if you have this pin expanded out, and feed to a GPIO, you could use that as a flag so you can change the sign of the power data from the PZEM, eg. the 2kW it's reading is actually 2kW export rather than import. But I've yet to see verification that this pin does in fact toggle when you are exporting power.

I can get a split CT clamp, and have ordered my v3 with one, but while I'm happy to play with power on extension cords etc. behind safety switches and RCDs, I'll leave it to the professionals when opening up my meter box and installing inside, especially on the supply side where there's no "off" switch. Heard a few horror stories of literally smoking corpses where the mains fuse hasn't blown, not something I want to subject my kids to (or myself for that matter)

Jason2866 commented 4 years ago

You have a very small analog voltage to measure, adding additional stuff or make the wires longer of the CT will result in issues.

jziolkowski commented 4 years ago

I've extended the CT wires with ~20cm of .14mm2 wire. Hope that's not an issue

Jason2866 commented 4 years ago

20 cm should work...

adityama commented 4 years ago

@arendst Fantastic. Thank you. This fix makes the solution perfect.

ascillato2 commented 4 years ago

Closing this issue as the feature has been added by Theo.

Thanks to everyone for working on this :+1:

klotzma commented 4 years ago

Thanks for the great work.

I got it to work when I wired it as shown in the picture. Is it correct that way ? Or do I have to wire it differently?

Because it is indeed a Modbus, must there now be a terminal resistor?

Improves me.

As shown here, it did not work: Uart Bus issue comment

pzem

jziolkowski commented 4 years ago

You definitely need protection diodes. See drawings earlier.

Jason2866 commented 4 years ago

https://github.com/arendst/Sonoff-Tasmota/issues/2315#issuecomment-384643624

klotzma commented 4 years ago

So I had connected it before and it did not work

localhost61 commented 4 years ago

@klotzma , did you use fast shottky diodes? Did you respect the polarity? The schema shows an "open collector" principle, the bus is pulled high by the pullup resistor and pushed down when a slave is sending a Low level on its Tx pin. The Modbus resistors are used for line impedance adaptation, to avoid signal reflections that cause spikes, this is totally different.

Jason2866 commented 4 years ago

It does work @jziolkowski has builded as described. If your setup does not work you have done something wrong.

jziolkowski commented 4 years ago

@klotzma initially I didn't use diodes and resistors and it wasn't working. I guess that people who said it's required knew what they were talking :)

rt400 commented 4 years ago

Must connect diodes otherwise it just doesn't work. From experience.

klotzma commented 4 years ago

Yes, I used the Bat43 diodes! I checked everything twice and three times. But it only worked like in the picture from my previous post.

klotzma commented 4 years ago

With this setting

Screenshot_20191006-183321_Chrome

localhost61 commented 4 years ago

Isn't it #6585 issue solved 3 days ago by Theo? All PZEM004T devices have their own address? Can you describe your issue with more details, what doesn't work?

klotzma commented 4 years ago

Danke für die tolle Arbeit.

Ich habe es zum Laufen gebracht, als ich es wie im Bild gezeigt verdrahtet habe. Ist es so richtig? Oder muss ich es anders verkabeln?

Da es sich in der Tat um einen Modbus handelt, muss es jetzt einen Abschlusswiderstand geben?

Verbessert mich

Wie hier gezeigt, hat es nicht funktioniert: Uart Bus Problem Kommentar

pzem

It works as pictured in this picture, all pzem have their own address, from 1-3.

But if I put the Bat diodes in between, then no data comes back

klotzma commented 4 years ago

I had used the 6.6.0.15.

I will try it later with the 6.6.0.16.

localhost61 commented 4 years ago

6.6.0.17 now ;-)

klotzma commented 4 years ago

Ok, I got it, the diodes were labeled wrong. Or in the plan the diode is wrongly drawn. The cathode was not where the line is, but on the other side.

When I turned the diode, it worked.

klotzma commented 4 years ago

Can I reset all the energy to zero with tasmota?

localhost61 commented 4 years ago

Yes, it should be allowed since commit v6.6.0.15 20191003. Try SetOption72 0 to select software counters Then EnergyReset3 0 (Didn't try myself)

rt400 commented 4 years ago

@localhost61 @klotzma i have the same issue. i try all the command but still i got the "Total" from the PZEM even with SetOption72 0

localhost61 commented 4 years ago

@rt400 Hum, yes I see your last comment on issue #6561

klotzma commented 4 years ago

@localhost61 @klotzma i have the same issue. i try all the command but still i got the "Total" from the PZEM even with SetOption72 0

Does not work for me either.

arendst commented 4 years ago

At least with version 6.6.0.16 and SetOption72 0, EnergyReset3 0 will reset the total counter to 0, then add the energy from today.

But if you want to reset the total counter to 0 now, you will need to execute first EnergyReset1 0 followed by EnergyReset3 0.

rt400 commented 4 years ago

@arendst but its not work.. look in my issue #6561

arendst commented 4 years ago

See #6561 for latest change.