esphome / esphome/feature-requests

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

Open
#1,087 8 comments 3 reactions 0 assignees View on GitHub
component: atm90e32 Type: Power Meter
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

_**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/](url)

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:
- platform: wifi_signal
name: ${disp_name} WiFi
update_interval: 60s

- platform: atm90e32
cs_pin: 5

phase_a:
voltage:
name: ${disp_name} Volts A
id: ic1Volts
accuracy_decimals: 1
current:
name: ${disp_name} CT1 Amps
id: ct1Amps

power:
name: ${disp_name} CT1 Watts
id: ct1Watts
filters:
- multiply: -1
gain_voltage: ${voltage_cal}
gain_ct: ${current_cal}

phase_b:
current:
name: ${disp_name} CT2 Amps
id: ct2Amps
power:
name: ${disp_name} CT2 Watts
id: ct2Watts
filters:
- multiply: -1
gain_voltage: ${voltage_cal}
gain_ct: ${current_cal}

phase_c:
current:
name: ${disp_name} CT3 Amps
id: ct3Amps
power:
name: ${disp_name} CT3 Watts
id: ct3Watts
filters:
- multiply: -1
gain_voltage: ${voltage_cal}
gain_ct: ${current_cal}
frequency:
name: ${disp_name} Freq A
line_frequency: 50Hz
gain_pga: 1X
update_interval: ${update_time}

- platform: atm90e32
cs_pin: 4
phase_a:

current:
name: ${disp_name} CT4 Amps
id: ct4Amps
power:
name: ${disp_name} CT4 Watts
id: ct4Watts
gain_voltage: ${voltage_cal}
gain_ct: ${current_cal}

phase_b:
current:
name: ${disp_name} CT5 Amps
id: ct5Amps
power:
name: ${disp_name} CT5 Watts
id: ct5Watts
gain_voltage: ${voltage_cal}
gain_ct: ${current_cal}

phase_c:
current:
name: ${disp_name} CT6 Amps
id: ct6Amps
power:
name: ${disp_name} CT6 Watts
id: ct6Watts
filters:
- multiply: -1
gain_voltage: ${voltage_cal}
gain_ct: ${current_cal}
frequency:
name: ${disp_name} Freq B
line_frequency: 50Hz
gain_pga: 1X
update_interval: ${update_time}

- platform: total_daily_energy
name: ${disp_name} Total kWh
power_id: ct1Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh

- platform: template
name: ${disp_name} Loft Amps
id: loftAmps
lambda: return id(ct1Amps).state - id(ct3Amps).state ;
accuracy_decimals: 2
unit_of_measurement: A
icon: "mdi:flash"
update_interval: ${update_time}

- platform: template
name: ${disp_name} Loft Watts
id: loftWatts
lambda: return id(ct1Watts).state - id(ct3Watts).state ;
accuracy_decimals: 1
unit_of_measurement: W
icon: "mdi:flash-circle"
update_interval: ${update_time}

switch:
- platform: restart
name: ${disp_name} Restart
time:
- platform: sntp
id: sntp_time
`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the ATM90e32 ESPHome platform configuration shown in the issue, focusing on the two sensor instances using CS pins 5 and 4 and their update_interval settings. Done means measurements from separate chips are published together closely enough that the template sensors calculating values across CT channels use readings from the same point in time.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.