esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
416 stars 26 forks source link

ATM90e32 Platform - Sensors on Separate Chips not Updating/Publishing at the Same Time. So Calculated Sensor Values are Incorrect. #1087

Open Teleportist opened 3 years ago

Teleportist commented 3 years ago

Describe the problem you have/What new integration you would like

ATM90e32 ESPHome platform.

I am using the ATM90E32AS based board from CircuitSetup to monitor power on 6 circuits. https://circuitsetup.us/product/expandable-6-channel-esp32-energy-meter/

The 2 Microchip ATM90E32AS are measuring input current from 3 separate channels each. Unfortunately it seems the data from each chip is published at different times.~ 20 seconds or so apart. This means that if I need to include a virtual/calculated sensor, based on measurements from channels on separate chips there is a chance the readings will no be aligned, so producing an incorrect result.

REQUEST IS: An option to synchronise the output from form both chips, to force them to publish at the same time.

Please describe your use case for this integration and alternatives you've tried:

EXAMPLE: Hopefully the below screen grab from Grafana will clearly show the issue. https://user-images.githubusercontent.com/61894621/103577465-caf0b680-4ecc-11eb-8027-a8f88060f09d.png

'Total' (CT1) = Incoming cable from the electricity grid 'Ground & 1st Floors' (CT6) = Cable into primary fuse board '2nd Floor' (calculated) = Total(CT1) - Ground & 1st Floors (CT6)*

*Should be what my secondary fuse board, for the 2nd floor, is consuming.

As you can see, the calculated '2nd Floor' sensor (purple) is reporting negative values, because the 'Total' sensor (green) is lagging behind the 'Ground & 1st Floors' sensor. For the calculation to be accurate the readings should be from the same point in time.

So if CT1 is 300W when it updates, but CT6 hasn't updated from it's last value, of say 500W, my calculated sensor will be -200W (300W-500W). Then after CT6 updates just after with the new value of 200W, so the calculated sensor value should have been 100W (300W-200W). But now it's too late.

I don't have a spare channel to actually clamp on to the cable into the secondary fuse board, which services the second floor.

I have since moved both CT clamps on to the same chip, which has fixed the issue, but I'm planning to buy further boards, to add more channels, where again the 2 new chips would publish out of step with those on the other board, as well as each other.

Additional context

Here's my YAML,

`substitutions: disp_name: PowMon6C update_time: 60s current_cal: '28304' voltage_cal: '13611'

esphome: name: power_mon_6c platform: ESP32 board: nodemcu-32s

wifi: ssid: !secret wifi_ssid password: !secret wifi_password

logger:

mqtt: broker: !secret mqtt_broker username: !secret mqtt_user password: !secret mqtt_password

ota: password: !secret ota_password

web_server: port: 80

spi: clk_pin: 18 miso_pin: 19 mosi_pin: 23

sensor:

switch:

Teleportist commented 2 years ago

Just checking in, after a year, to bump this in the hope it gets assigned. Thanks

CircuitSetup commented 2 years ago

You may want to try changing the update_interval for the meter to less than the template calculation. This way, the update is staggered a bit.

You may also want to look at why CT6 is reading negative though. I see you put a multiply -1 in there - was it reading negative most of the time, previously? This looks like the CT is backwards on the wire, which would be giving you an incorrect power factor reading, calculating an incorrect power (watts) in the meter.

Cougar commented 1 year ago

I'm thinking if it is possible to disable normal updates (with update_interval: 0 ?) and then run script with timer using lambdas to call ATM90E32Component::update() for both ICs sequentially? This could be quite easy to implement I guess.

RamyaDidde commented 8 months ago

hi,

i am using ATM90E32 IC, i am facing issue while reading Kwh from APenergyT register. Can anyone tell how to read Kwh and any calibration register to improve Kwh. Thanks in advance.

CircuitSetup commented 8 months ago

hi,

i am using ATM90E32 IC, i am facing issue while reading Kwh from APenergyT register. Can anyone tell how to read Kwh and any calibration register to improve Kwh. Thanks in advance.

I assume you're using the instructions for the config file here: https://esphome.io/components/sensor/atm90e32#active-energy ?

Each phase must be read, as APenergyT (the total register) is not used in ESPHome.

Also, the output is in watt hours. So when these registers are read, and the data is stored, the time between reads must be taken into account since they are accumulation registers

CircuitSetup commented 8 months ago

I'm thinking if it is possible to disable normal updates (with update_interval: 0 ?) and then run script with timer using lambdas to call ATM90E32Component::update() for both ICs sequentially? This could be quite easy to implement I guess.

There's an update coming that mitigates time between reading the registers and publishing. https://github.com/esphome/esphome/pull/5670

RamyaDidde commented 8 months ago

Hi,

Thanks for your reply. I am not using this ESP HOME: https://esphome.io/components/sensor/atm90e32#active-energy

I am using this example code of ATM90E32. https://github.com/CircuitSetup/ATM90E32

I am using the APenergyT register to read energy. But I am not getting the proper output while reading. I am using the reference energy meter for comparison. The comparison is far different from ATM90E32 and the reference energy meter.

Thanks Ramya

On Tue, Feb 13, 2024 at 10:07 PM John @.***> wrote:

hi,

i am using ATM90E32 IC, i am facing issue while reading Kwh from APenergyT register. Can anyone tell how to read Kwh and any calibration register to improve Kwh. Thanks in advance.

I assume you're using the instructions for the config file here: https://esphome.io/components/sensor/atm90e32#active-energy ?

Each phase must be read, as APenergyT (the total register) is not used in ESPHome.

Also, the output is in watt hours. So when these registers are read, and the data is stored, the time between reads must be taken into account since they are accumulation registers

— Reply to this email directly, view it on GitHub https://github.com/esphome/feature-requests/issues/1087#issuecomment-1941969943, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDNG3FJP65RNJRZKLSYFGRTYTOJGDAVCNFSM4WCMRCJ2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJUGE4TMOJZGQZQ . You are receiving this because you commented.Message ID: @.***>

CircuitSetup commented 8 months ago

Hi, Thanks for your reply. I am not using this ESP HOME: https://esphome.io/components/sensor/atm90e32#active-energy I am using this example code of ATM90E32. https://github.com/CircuitSetup/ATM90E32 I am using the APenergyT register to read energy. But I am not getting the proper output while reading. I am using the reference energy meter for comparison. The comparison is far different from ATM90E32 and the reference energy meter. Thanks Ramya

Okay, this repo is for ESPHome. Please open an issue in the CircuitSetup repo