CircuitSetup Energy Meter de5b30 Negative Values

Hello,
Im having an issue getting proper measurements from my CircuitSetup Energy Meter de5b30 using 2x 120A/40mA Current Transformer YHDC SCT-016

When i had it on my desk measuring a lamp, it appeared correct (compared to my hand held amp clamp).
However now installed in my service panel, i am getting wild negative watt readings. (current reading looks good and accurate to what i expect 1737.6w)

Even though my amps appear to me measured correctly.

Then when creating a helper to show in KWh, im receiving negative items.

Any assistance or direction to another topic/resource is greatly appreciated.

energy-meter-de5b30.yaml for reference

# CircuitSetup 6 Channel Energy Meter Main Board example config
# See all options at https://esphome.io/components/sensor/atm90e32.html

substitutions:
# Change the disp_name to something you want
  disp_name: esphome-web-de5b30
  friendly_name: "CircuitSetup Energy Meter"
# Interval of how often the power data is updated
  update_time: 10s

# Change current_cal to the corresponding CT's that you're using
# If different CTs per current channel, remove or change "${current_cal}" from 
# "gain_ct" below and replace with the CT calibration number respectively
# Current Transformers:
#  20A/25mA SCT-006: 11143
#  30A/1V SCT-013-030: 8650
#  50A/1V SCT-013-050: 15420
#  50A/16.6mA SCT-010: 41334
#  80A/26.6mA SCT-010: 41660
#  100A/50ma SCT-013-000: 27518
#  120A/40mA: SCT-016: 41787
#  200A/100mA SCT-024: 27518
#  200A/50mA SCT-024: 55036
  current_cal_ct1: '27518'
  current_cal_ct2: '27518'
  current_cal_ct3: '27518'
  current_cal_ct4: '27518'
  current_cal_ct5: '27518'
  current_cal_ct6: '27518'
# This only needs to be changed if you're using something other than the  
# Jameco 9VAC Transformer: 
  voltage_cal1: '7305'
  voltage_cal2: '7305'

# WHEN CALIBRATION IS ENABLED, calculated values for offset and gain stored in memory take priority over config values
# to save calculated calibration values, copy them from the logs to your config
# then use the clear buttons to clear the calibration values from memory
  offset_calibration: "true"
  gain_calibration: "true"

  main_meter_name1: Meter 1-3
  main_meter_name2: Meter 4-6
  main_meter_id1: meter_main1
  main_meter_id2: meter_main2
  ct1_name: CT1
  ct2_name: CT2
  ct3_name: CT3
  ct4_name: CT4
  ct5_name: CT5
  ct6_name: CT6

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: !secret ip_eh_nrgnode
    gateway: 192.168.88.1
    subnet: 255.255.255.0
#    dns1: !secret ip_dns1

packages:
  common: github://CircuitSetup/Expandable-6-Channel-ESP32-Energy-Meter/Software/ESPHome/6chan_common.yaml

sensor:
#IC1
####
  - platform: atm90e32
    cs_pin: 5
    id: ${main_meter_id1}
    phase_a:
      voltage:
        name: Voltage 1
        id: ic1Volts
        accuracy_decimals: 1
      current:
        name: ${ct1_name} Amps
        id: ct1Amps
# 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
      power:
        name: ${ct1_name} Watts
        id: ct1Watts
#        filters:
#          - multiply: 2
      power_factor:
        name: ${ct1_name} PF
      peak_current:
        name: ${ct1_name} Peak Current
      gain_voltage: ${voltage_cal1}
      gain_ct: ${current_cal_ct1}
      offset_voltage: 0
      offset_current: 0
      offset_active_power: 0
      offset_reactive_power: 0
    phase_b:
      current:
        name: ${ct2_name} Amps
        id: ct2Amps
      power:
        name: ${ct2_name} Watts
        id: ct2Watts
      power_factor:
        name: ${ct2_name} PF
      peak_current:
        name: ${ct2_name} Peak Current
      gain_voltage: ${voltage_cal1}
      gain_ct: ${current_cal_ct2}
      offset_voltage: 0
      offset_current: 0
      offset_active_power: 0
      offset_reactive_power: 0
    phase_c:
      current:
        name: ${ct3_name} Amps
        id: ct3Amps
      power:
        name: ${ct3_name} Watts
        id: ct3Watts
      power_factor:
        name: ${ct3_name} PF
      peak_current:
        name: ${ct3_name} Peak Current
      gain_voltage: ${voltage_cal1}
      gain_ct: ${current_cal_ct3}
      offset_voltage: 0
      offset_current: 0
      offset_active_power: 0
      offset_reactive_power: 0
    frequency:
      name: Frequency 1
    chip_temperature:
      name: ${main_meter_name1} Chip Temp
    line_frequency: 60Hz
    gain_pga: 1X
    update_interval: ${update_time}
    enable_offset_calibration: ${offset_calibration}
    enable_gain_calibration: ${gain_calibration}
#IC2
####
  - platform: atm90e32
    cs_pin: 4
    id: ${main_meter_id2}
    phase_a:
#this voltage is only needed if monitoring 2 voltages
#     voltage:
#       name: Voltage 2
#       id: ic2Volts
#       accuracy_decimals: 1
      current:
        name: ${ct4_name} Amps
        id: ct4Amps
      power:
        name: ${ct4_name} Watts
        id: ct4Watts
      power_factor:
        name: ${ct4_name} PF
      phase_angle:
        name: ${ct4_name} Phase Angle
      peak_current:
        name: ${ct4_name} Peak Current
      gain_voltage: ${voltage_cal2}
      gain_ct: ${current_cal_ct4}
      offset_voltage: 0
      offset_current: 0
      offset_active_power: 0
      offset_reactive_power: 0
    phase_b:
      current:
        name: ${ct5_name} Amps
        id: ct5Amps
      power:
        name: ${ct5_name} Watts
        id: ct5Watts
      power_factor:
        name: ${ct5_name} PF
      peak_current:
        name: ${ct5_name} Peak Current
      gain_voltage: ${voltage_cal2}
      gain_ct: ${current_cal_ct5}
      offset_voltage: 0
      offset_current: 0
      offset_active_power: 0
      offset_reactive_power: 0
    phase_c:
      current:
        name: ${ct6_name} Amps
        id: ct6Amps
      power:
        name: ${ct6_name} Watts
        id: ct6Watts
      power_factor:
        name: ${ct6_name} PF
      peak_current:
        name: ${ct6_name} Peak Current
      gain_voltage: ${voltage_cal2}
      gain_ct: ${current_cal_ct6}
      offset_voltage: 0
      offset_current: 0
      offset_active_power: 0
      offset_reactive_power: 0
#this is only needed if monitoring 2 voltages
#   frequency:
#     name: Frequency 2
    chip_temperature:
      name: ${main_meter_name2} Chip Temp
    line_frequency: 60Hz
    gain_pga: 1X
    update_interval: ${update_time}
    enable_offset_calibration: ${offset_calibration}
    enable_gain_calibration: ${gain_calibration}

#Total Amps
###########
  - platform: template
    name: ${friendly_name} Total Amps
    id: totalAmps
    lambda: return id(ct1Amps).state + id(ct2Amps).state + id(ct3Amps).state + id(ct4Amps).state + id(ct5Amps).state + id(ct6Amps).state ;
    accuracy_decimals: 2
    unit_of_measurement: A
    device_class: current
    update_interval: ${update_time}
#Total Watts
############
  - platform: template
    name: ${friendly_name} Total Watts
    id: totalWatts
    lambda: return id(ct1Watts).state + id(ct2Watts).state + id(ct3Watts).state + id(ct4Watts).state + id(ct5Watts).state + id(ct6Watts).state ;
    accuracy_decimals: 1
    unit_of_measurement: W
    device_class: power
    update_interval: ${update_time}
#kWh
####
  - platform: total_daily_energy
    name: ${friendly_name} Total kWh
    power_id: totalWatts
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing

# Status Fields
###############
text_sensor:
  - platform: atm90e32
    id: ${main_meter_id1}
    phase_status:
      phase_a:
        name: "${ct1_name} Status"
      phase_b:
        name: "${ct2_name} Status"
      phase_c:
        name: "${ct3_name} Status"
    frequency_status:
      name: "Frequency Status 1"

  - platform: atm90e32
    id: ${main_meter_id2}
    phase_status:
      phase_a:
        name: "${ct4_name} Status"
      phase_b:
        name: "${ct5_name} Status"
      phase_c:
        name: "${ct6_name} Status"
#this is only needed if monitoring 2 voltages
#   freq_status:
#     name: "Frequency Status 2"

# Semi-automatic Calibration Buttons
####################################
button:
  - platform: atm90e32
    id: ${main_meter_id1}
    run_offset_calibration:
      name: "1. Run ${main_meter_name1} Offset Calibration"
    clear_offset_calibration:
      name: "z1. Clear ${main_meter_name1} Offset Calibration"
    run_power_offset_calibration:
      name: "2. Run ${main_meter_name1} Power Offset Calibration"
    clear_power_offset_calibration:
      name: "z2. Clear ${main_meter_name1} Power Offset Calibration"
    run_gain_calibration:
      name: "3. Run ${main_meter_name1} Gain Calibration"
    clear_gain_calibration:
      name: "z3. Clear ${main_meter_name1} Gain Calibration"

  - platform: atm90e32
    id: ${main_meter_id2}
    run_offset_calibration:
      name: "1. Run ${main_meter_name2} Offset Calibration"
    clear_offset_calibration:
      name: "z1. Clear ${main_meter_name2} Offset Calibration"
    run_power_offset_calibration:
      name: "2. Run ${main_meter_name2} Power Offset Calibration"
    clear_power_offset_calibration:
      name: "z2. Clear ${main_meter_name2} Power Offset Calibration"
    run_gain_calibration:
      name: "3. Run ${main_meter_name2} Gain Calibration"
    clear_gain_calibration:
      name: "z3. Clear ${main_meter_name2} Gain Calibration"

# V & I Calibration Reference Fields
####################################
# Use these to input a known value being measured by a CT or voltage transformer
number:
  - platform: atm90e32
    id: ${main_meter_id1}
    reference_voltage:
      # will copy to phase_b/c for calibration reference
      phase_a:
        name: "Ref Voltage 1"
    reference_current:
      phase_a:
        name: "${ct1_name} Ref Current"
      phase_b:
        name: "${ct2_name} Ref Current"
      phase_c:
        name: "${ct3_name} Ref Current"

  - platform: atm90e32
    id: ${main_meter_id2}
    reference_voltage:
      # needed to calibrate voltage registers even if not output
      phase_a:
        name: "Ref Voltage 2" 
    reference_current:
      phase_a:
        name: "${ct4_name} Ref Current"
      phase_b:
        name: "${ct5_name} Ref Current"
      phase_c:
        name: "${ct6_name} Ref Current"

Often negative values are because the clamp is the wrong way around. Which I think you can also change with a setting (if you don’t feel like getting into the panel again to flip it around).

But due to the magnitude, you might have something else going on as well. Perhaps mis-calibrated?

might want to read this issue on GitHub

1 Like

if all are negative turn the plug for the transformer over. The polarity between L1 and L2 are 180 degrees out of phase with each other.

This looks very close to what I’m seeing
Am I reading this right in that I just need to add the linked code into my .yaml and push to the device?

This is the YAML that you are including as a package:

it does use ESP-IDF so it seems like you should be able to use the external components as suggested (add to your YAML and recompile). You should try it and see what happens.

You might also need to reverse your CT so it reads positive normally.