New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration for ADE7880 (3-phase power monitor, used in Shelly 3EM) #1579
Comments
Setting the GPIO linked to the ADE’s IRQ in a correct way is important, as wrong configuration can lead to heating of the device and potential fire hazard! Refering to this related issue: arendst/Tasmota#7991 (comment) |
A Tasmota component for the Shelly 3EM is being built as people started contributing photos of the PCB's and investigated code dumps. All information is in this discussion: arendst/Tasmota#13515. As I'm not that proficient with coding in Python and C (yet), would someone be willing to complete my draft code for an ADE7880 component in ESPHome? |
Hi Michael! |
Hi @kroimon , I didn’t progress further on this, unfortunately. My fork of esphome is still the most recent one. In the meantime, I see quite some activity in the Tasmota discussion (see link in my previous post) with interesting info on how to download the device calibration parameters from the original firmware, before putting new firmware on it. |
It's standard and known for a long time, if you're not downloading the calibration data for your 3EM and flash it, then it's worthless electronic waste. |
@michaelpiron what's the current status on support 3-phases system without neutral? thx! |
Since I have four 3EMs and a strong desire to run ESPHome on them, I've begun working on this component. Hopefully I'll get some early progress posted in the next day or two. |
Development is happening here. Current status:
Tasks left (at least):
|
Major progress... I now have most of the sensors reporting as planned, and the numbers match very closely to the Shelly firmware. Tomorrow I'll start working on docs! The image below has the top three channels from a 3EM running Shelly firmware, and the bottom three channels from a 3EM running ESPHome, with the current clamps on the same wires. |
The PRs to merge this into ESPHome are up for review now. If anyone would like to help test this before it is merged, the docs are here. You can add the component to your configuration like this: external_components:
- source: github://kpfleming/esphome/ade7880
- components: [ ade7880 ] I'll be opening a PR later today for the |
Example config for Shelly 3EM. |
Hi guys, my Shelly 3EM is on its way so I started to prepare everything for the firmware conversion.
external_components:
- source:
type: git
url: https://github.com/kpfleming/esphome
ref: ade7880
components: [ ade7880 ]
#refresh: never
(Please note that c4a2a214 can be different, be sure to edit the right one) CONF_PHASE_A = "phase_a"
CONF_PHASE_B = "phase_b"
CONF_PHASE_C = "phase_c"` Put them just above
INFO ESPHome 2023.7.1
INFO Reading configuration /config/esphome/sh-3em-1.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing sh-3em-1 (board: esp01_1m; framework: arduino; platform: platformio/espressif8266@3.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 1.2.3
|-- ESPAsyncWebServer-esphome @ 2.1.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.4
|-- Wire @ 1.0
Compiling /data/sh-3em-1/.pioenvs/sh-3em-1/src/main.cpp.o
Linking /data/sh-3em-1/.pioenvs/sh-3em-1/firmware.elf
RAM: [==== ] 44.2% (used 36212 bytes from 81920 bytes)
Flash: [===== ] 51.3% (used 525701 bytes from 1023984 bytes)
Building /data/sh-3em-1/.pioenvs/sh-3em-1/firmware.bin
esp8266_copy_factory_bin(["/data/sh-3em-1/.pioenvs/sh-3em-1/firmware.bin"], ["/data/sh-3em-1/.pioenvs/sh-3em-1/firmware.elf"])
========================= [SUCCESS] Took 8.18 seconds =========================
INFO Successfully compiled program. |
Ahh, you are correct, thanks for the details. This branch won't work completely standalone as an external component because it contains a patch to |
Ciao @kpfleming, I can confirm you that everything is working correctly.
|
Which ESP board are you using, and how many of the ade7880 sensors do you have enabled?
Unfortunately I do not; I had the same situation on my units but since I don't have clamps installed on the neutral conductors I didn't care about it. Someone will eventually need to talk to Shelly about those calibration constants to find out what the correct way to use |
It is a Shelly 3EM, I took your config example and just added some minor changes. If you want to check I can attach the full config.
Hmm, interesting, I will try to find out more and eventually I'll write to the shelly team. |
Yes, of course... it was a silly question I asked :-) Most likely the cause of those warnings is that the logger level is set to You can ignore the warning, as there is no actual problem. You can also set the log level to |
Hi @kpfleming this morning I switched to Tasmota in order to make some comparison.
Let me provide you an example with some numbers: Have you experienced something similar? Maybe I'm missing something. |
Thanks for the report! I have not seen this sort of problem on my own devices; I ran two 3EMs in parallel (one with the Shelly firmware and one with ESPHome) for about a week to confirm that the reported numbers were close enough to be acceptable. There were minor differences, but I assumed those were caused by CT clamp and/or calibration differences. This component does gather the Wh data differently than the Shelly firmware and Tasmota do; they both read the Wh registers every second, and then report the sum periodically. This component reads the registers at each |
Also, are only the Wh sensors incorrect (meaning the other sensors are correct)? |
I have not specified it so should be 60s as default. I can confirm that also in the logs the data were retrieved every minute.
You're idea about the register overflow and the update time can be the point. Are you updating the sensors faster? |
No, I'm also using the default update interval of 60s. |
In order to avoid spamming everyone else subscribed to this issue, please open one in https://github.com/kpfleming/esphome and we'll work through this there. I'll report back results to this issue once we've reached a conclusion. |
@dinamitemic I've just pushed an update to the PR branch. It resolves the issue with not being able to provide the I've also removed the commit which moved around the |
Since the weirdness with the |
Is this component dependent on having all three phases connected? I'm testing it with just neutral and A wired - and I'm not getting the expected readings.
Using the https://deploy-preview-499--esphome-devices.netlify.app/devices/Shelly-3EM yaml with my calib.dat entries merged (and a lot of the other entities commented out, same result with the full config for that matter). |
No, the phases (all four) are independently read and reported. Would you be willing to test with Tasmota to see if it reports the same readings (or correct readings) using the same calibration values? |
@kpfleming I have issues compiling a firmware for the shelly3em because my calibration data does not validate. The power values are to low and return the error value must be at least -8388608 on compilation. This is my calibration data: {
"state": 0,
"rms": {
"current_a": 3115853,
"current_b": 3145899,
"current_c": 3118537,
"current_n": 55507790,
"current_s": 3683735,
"voltage_a": -754486,
"voltage_b": -745905,
"voltage_c": -768669
},
"angles": {
"angle0": -10091,
"angle1": -10096,
"angle2": -10099
},
"powers": {
"totactive": {
"a": -15427176,
"b": -15431191,
"c": -15434854
},
"apparent": {
"a": 1383297,
"b": 1383213,
"c": 1383263
}
},
"energies": {
"totactive": {
"a": -56297,
"b": -56294,
"c": -56297
},
"apparent": {
"a": 146044,
"b": 146123,
"c": 146229
}
}
} This is my esphome sensor configuration: sensor:
- id: ade7880_device
platform: ade7880
irq0_pin:
number: GPIO13
irq1_pin:
number: GPIO5
reset_pin:
number: GPIO16
frequency: 60Hz
phase_a:
name: Phase A
voltage: Voltage
current: Current
active_power: Active Power
power_factor: Power Factor
forward_active_energy: Forward Active Energy
reverse_active_energy: Reverse Active Energy
calibration:
current: 3115853
voltage: -754486
power: -15427176
phase_angle: -10091
phase_b:
name: Phase B
voltage: Voltage
current: Current
active_power: Active Power
power_factor: Power Factor
forward_active_energy: Forward Active Energy
reverse_active_energy: Reverse Active Energy
calibration:
current: 3145899
voltage: -745905
power: -15431191
phase_angle: -10096
phase_c:
name: Phase C
voltage: Voltage
current: Current
active_power: Active Power
power_factor: Power Factor
forward_active_energy: Forward Active Energy
reverse_active_energy: Reverse Active Energy
calibration:
current: 3118537
voltage: -745905
power: -15434854
phase_angle: -10099
neutral:
name: Neutral
current: Current
calibration:
current: 55507790 |
Thanks for the report! I'm investigating this now, it appears that the 3EM calibration data may be the 'raw' values from the I2C bus and not the documented values from the datasheet. I'd already dealt with that for the current sensor calibration, but I'll check it for the others too. |
I‘ve already disabled the checks and now I‘m getting correct power values. So it seems the calibration values are valid and must not be converted. 😀
… Am 21.10.2023 um 14:11 schrieb Kevin P. Fleming ***@***.***>:
Thanks for the report! I'm investigating this now, it appears that the 3EM calibration data may be the 'raw' values from the I2C bus and not the documented values from the datasheet. I'd already dealt with that for the current sensor calibration, but I'll check it for the others too.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
|
Yes, that's what I suspected. It's not clear how the Shelly firmware is deriving these calibration values as they do not align with what the ADE7880 datasheet indicates, but since the Tasmota firmware blindly accepts them and writes them to the chip (and that produces the expected results), this component could do the same. I'll rework the code to not care about the interpretation of the calibration data at all. |
All done; the three PRs have all been updated to accept any integer value for the calibration registers. |
@kpfleming I get a compilation error for the neutral channel:
If I comment out the neutral: block it compiles and installs fine, though voltage is 0. edit: voltage is fine, I got my phases mixed up |
The calibration constant config entries recently changed; |
|
Well, that certainly looks correct :-) Can you run an |
Ahh... never mind. I just reproduced with the updated PR branch. I'll fix it now. |
The PR branch has been fixed and CI tests now pass, your config should compile properly. Thanks for the report, I didn't catch this locally as I don't use the 'neutral' phase monitoring. |
Describe the problem you have/What new integration you would like
I have a Shelly 3PM 3-phase energy monitor: https://shelly.cloud/products/shelly-3em-smart-home-automation-energy-meter/
Inside the product is an ESP8266 SoC and a ADE7880 power monitoring chip.
I’d like to put ESPhome firmware on my Shelly 3PM for two reasons:
Therefore I see an added value in having an ADE7880 component in ESPhome, next to the existing ADE7953 (used in the single-phase Shelly PM) -> https://esphome.io/components/sensor/ade7953.html
Please describe your use case for this integration and alternatives you've tried:
use case: being able to do 3-phase energy monitoring
Additional context
I started developing a ADE7880 component, based on the existing ADE7953 component and taking into account the ADE7880 datasheet specifications. The majority of the work is done and is available in a fork of the esphome repository:
https://github.com/michaelpiron/esphome/tree/dev/esphome/components/ade7880
However, some outstanding issues remain at this moment, for which I would need some help:
furthermore: in the Tasmota Github community, people also raised the idea of having a Tasmota component for the ADE7880: arendst/Tasmota#13515
So there are also other people interested in having an ADE7880 integration.
The text was updated successfully, but these errors were encountered: