INA icon indicating copy to clipboard operation
INA copied to clipboard

Power does not show negative values.

Open Oleg-Sob opened this issue 3 years ago • 4 comments

Why INA226 with negative current readings, the power shows positive values. Should be negative too.

333

Please tell me how can I fix this.

Oleg-Sob avatar Jan 16 '22 14:01 Oleg-Sob

How are you calculating "Power"? Are you using "getBusMicroWatts()"?

SV-Zanshin avatar Jan 16 '22 15:01 SV-Zanshin

I output to Home Assistant with a script via EspHome.

i2c: sda: D2 scl: D1

sensor:

  • platform: ina226 address: 0x40 shunt_resistance: 0.0005 ohm current: name: "INA226_1 Current" accuracy_decimals: 1 power: name: "INA226_1 Power" accuracy_decimals: 0 filters:
    • lambda: return x*2.047; bus_voltage: name: "INA226_1 Bus Voltage" filters:
    • lambda: return x*2.047; shunt_voltage: name: "INA226_1 Shunt Voltage" accuracy_decimals: 0 filters:
    • lambda: return x*107800; max_current: 100A update_interval: 10s

It may be possible to correct the formula so that Power has a negative value. I use with shunt 100A 75mV.

Oleg-Sob avatar Jan 16 '22 15:01 Oleg-Sob

I have never used Home Assist or EspHome so I'm not sure what that script does. How does it calculate power?

SV-Zanshin avatar Jan 16 '22 15:01 SV-Zanshin

I've updated the "getBusMicroWatts()" function to return negative Watts, but I don't know if that is the function you are using.

SV-Zanshin avatar Jan 16 '22 15:01 SV-Zanshin