CircuitSetup / Split-Single-Phase-Energy-Meter

Split Single-phase Energy Meter
https://www.crowdsupply.com/circuitsetup/split-single-phase-energy-meter
MIT License
261 stars 57 forks source link

Clarification on ESPHome configuration #76

Closed wilsongoode closed 1 year ago

wilsongoode commented 1 year ago

I bought the kit with 2x 200A SCTs in order to monitor the whole house (I'm in the US with split single phase). I have Home Assistant already set up and several other devices configured through ESPHome, so I was hoping to do the same with this kit.

I found the example ESPHome file here: Software/examples/HA-ESPHome_energy_meter_detailed_power.yaml

Reading through the calibration for the CTs I have become confused as to which values to actually use for current_cal, gain_ct, and gain_pga. The example configuration linked above also contains this text describing a multiplication of the current and power values that is not applied by default:

# The max value for current that the meter can output is 65.535. If you expect to measure current over 65A, 
# divide the gain_ct by 2 (120A CT) or 4 (200A CT) and multiply the current and power values by 2 or 4 by uncommenting the filter below
#        filters:
#          - multiply: 2

Reading through other issues in this repo for information about appropriate configuration I found #64 and #43.

Pull request #72 also relates to 200A CTs.

On the ESPHome page for the ATM90E32 it recommends:

Here are common current calibration values for the Split Single Phase Energy Meter when gain_pga is set to 4X:
- 200A/100mA SCT-024: 12597

These various sources seem to conflict, hence my confusion.

At the end of the day I'd like to be able to:

  1. Monitor whole-home energy usage in Home Assistant
  2. Manage the software wirelessly with ESPHome's dashboard

So far, I have flashed the compiled ESPHome firmware to the device and set it up to connect to my network. I have not installed the CT clamps inside the breaker box.

Is there any risk to moving forward with the hardware install without the software calibration values being set appropriately? What values should be used for configuring current_cal, gain_ct, and gain_pga?

Please let me know if there is more information I can provide that would make it easier for you to help me. Thanks!

wilsongoode commented 1 year ago

@CircuitSetup I have installed the system and am reading positive volts and amps for both CTs, but the power factor is negative for both. I installed the CTs following the directions here (for one voltage reading). Does this mean the mini-plugs were wired incorrectly?

wilsongoode commented 1 year ago

Here's what I have so far. I calibrated against a space heater attached to a smart plug that could give me the load in watts and tuned the configuration until things lined up.

I multiplied by -1 (or -4) to flip the sign of the power factor, reactive power, and power readings.

substitutions:
# Change the disp_name to something you want  
  disp_name: Home Energy Meter
# Interval of how often the power is updated
  update_time: 10s
# Current transformer calibrations:
# 80A/26.6mA SCT-010: 39571
# 100A/50mA SCT-013: 26315
# 120A/40ma SCT-016: 39473 - default kit CT
# 200A/100mA SCT-024: 26315
  # current_cal: '26315'
  # current_cal: '12597'
  current_cal: '13157'
# AC Transformer voltage calibration 9VAC Jameco 157041: 37106
# For Meters >= v1.4 rev3: 3920
  voltage_cal: '3920'

esphome:
  name: energy-meter
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # manual_ip:
  #   static_ip: !secret ip_eh_nrgnode_2chan32
  #   gateway: !secret ip_gateway
  #   subnet: !secret ip_subnet
  #   dns1: !secret ip_dns1

# Enable if you want to send this data to an MQTT broker
# mqtt:
#  broker: !secret mqtt_broker
#  username: !secret mqtt_user
#  password: !secret mqtt_pass

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80

spi:
  clk_pin: 18
  miso_pin: 19
  mosi_pin: 23

sensor:
  - platform: wifi_signal
    name: ${disp_name} WiFi Signal
    update_interval: 60s
  - platform: atm90e32
    cs_pin: 5
    phase_a:
      voltage:
        name: ${disp_name} Volts
        accuracy_decimals: 1
        unit_of_measurement: V
        device_class: voltage
      current:
        name: ${disp_name} CT1 Amps
        id: "ct1Amps"
        unit_of_measurement: A
        device_class: current
# The max value for current that the meter can output is 65.535. If you expect to measure current over 65A, 
# divide the gain_ct by 2 (120A CT) or 4 (200A CT) and multiply the current and power values by 2 or 4 by uncommenting the filter below
        filters:
         - multiply: 4
      power:
        name: ${disp_name} CT1 Watts
        accuracy_decimals: 1
        id: "ct1Watts"
        unit_of_measurement: W
        device_class: power
        filters: # negative here because CT was reading negative values for power, power factor, etc (but not current)
         - multiply: -4
      reactive_power:
        name: ${disp_name} CT1 Reactive Power
        accuracy_decimals: 1
        id: "ct1Reactive"
        unit_of_measurement: VAR
        device_class: reactive_power
        filters:
         - multiply: -4
      power_factor:
        name: ${disp_name} CT1 Power Factor
        device_class: power_factor
        filters: # added to invert power_factor
          - multiply: -1
      gain_voltage: ${voltage_cal}
      gain_ct: ${current_cal}
    phase_c:
      current:
        name: ${disp_name} CT2 Amps
        id: "ct2Amps"
        unit_of_measurement: A
        device_class: current
# The max value for current that the meter can output is 65.535. If you expect to measure current over 65A, 
# divide the gain_ct by 2 (120A CT) or 4 (200A CT) and multiply the current and power values by 2 or 4 by uncommenting the filter below
        filters:
         - multiply: 4
      power:
        name: ${disp_name} CT2 Watts
        accuracy_decimals: 1
        id: "ct2Watts"
        unit_of_measurement: W
        device_class: power
        filters: # negative here because CT was reading negative values for power, power factor, etc (but not current)
         - multiply: -4
      reactive_power:
        name: ${disp_name} CT2 Reactive Power
        accuracy_decimals: 1
        id: "ct2Reactive"
        unit_of_measurement: VAR
        device_class: reactive_power
        filters:
         - multiply: -4
      power_factor:
        name: ${disp_name} CT2 Power Factor
        device_class: power_factor
        filters: # added to invert power_factor
          - multiply: -1
      gain_voltage: ${voltage_cal}
      gain_ct: ${current_cal}
    frequency:
      name: ${disp_name} Freq
      unit_of_measurement: Hz
      device_class: frequency
    chip_temperature:
      name: ${disp_name} Chip Temp
      unit_of_measurement: °C
      device_class: temperature
    line_frequency: 60Hz
    # gain_pga: 4X
    gain_pga: 1X
    update_interval: ${update_time}

  - platform: template
    name: ${disp_name} Total Amps
    id: "totalAmps"
    lambda: return id(ct1Amps).state + id(ct2Amps).state;
    accuracy_decimals: 2
    unit_of_measurement: A
    device_class: current
    update_interval: ${update_time}  

  - platform: template
    name: ${disp_name} Total Watts
    id: "totalWatts"
    lambda: return id(ct1Watts).state + id(ct2Watts).state;
    accuracy_decimals: 0
    unit_of_measurement: W
    device_class: power
    update_interval: ${update_time}

  - platform: template
    name: ${disp_name} Total Reactive Power
    id: "totalReactivePower"
    lambda: return id(ct1Reactive).state + id(ct2Reactive).state;
    accuracy_decimals: 0
    unit_of_measurement: VAR
    device_class: reactive_power
    update_interval: ${update_time}

  - platform: total_daily_energy
    name: ${disp_name} Total kWh
    power_id: totalWatts
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing

time:
  - platform: sntp
    id: sntp_time    

switch:
  - platform: restart
    name: ${disp_name} Restart     
CircuitSetup commented 1 year ago

If you're getting a negative value with power factor, then both CTs should be flipped around. Then take out all of the - multiply: filters as they should now be positive. If they are still negative then there is something else going on.