latonita / esphome-ina228

Esphome component for digital power monitors INA228, INA229, INA237, INA238, INA239
9 stars 3 forks source link

Power value not inverting #1

Closed clomads closed 9 months ago

clomads commented 9 months ago

First of all thank you so much for building this. I've been working on hardware since last summer and I'm not much of a developer. I was looking to get someone to help me finish the work I had a friend do back then and decided to double check github and here this is. Wonderful work, and I think i'm gonna move from the INA237 to the INA238 in my next prototype.

Anyways, I'm getting great results so far, but the power value doesn't go negative when running in reverse, but shuntV and current do. I've included a screenshot.

Screenshot 2024-02-12 at 8 01 58 AM
latonita commented 9 months ago

Hi. Power can't become negative) if voltage is negative and current is negative, then P=UI it becomes positive)

BR, Anton


From: Chloe Madison-Ryan @.> Sent: Monday, February 12, 2024 5:50:12 PM To: latonita/esphome-ina228 @.> Cc: Subscribed @.***> Subject: [latonita/esphome-ina228] Power value not inverting (Issue #1)

First of all thank you so much for building this. I've been working on hardware since last summer and I'm not much of a developer. I was looking to get someone to help me finish the work I had a friend do back then and decided to double check github and here this is. Wonderful work, and I think i'm gonna move from the INA237 to the INA238 in my next prototype.

Anyways, I'm getting great results so far, but the power value doesn't go negative when running in reverse, but shuntV and current do. I've included a screenshot. Screenshot.2024-02-12.at.8.01.58.AM.png (view on web)https://github.com/latonita/esphome-ina228/assets/1334775/e9387cd4-ebc0-4613-bac8-30712f6cf4e9

— Reply to this email directly, view it on GitHubhttps://github.com/latonita/esphome-ina228/issues/1, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA6O66TTDARA2D2AHS6I77LYTJB4JAVCNFSM6AAAAABDFBWCUCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGEZTANJUGUYDINI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

clomads commented 9 months ago

bus voltage is still positive and that should be what it should be calculated against. in this case:

25.69687v * -17.13562012i = -440.331802593w

shunt voltage is just a reference to calculate current. if current is negative power should be negative, no?

kolins-cz commented 9 months ago

I believe there should be negative power. At least as an option. In solar power applications, negative current and power usually means discharging battery.

Naturally, you can't have power loss of -50W on resistor. But for me it would mean that power flows in opposite way.

Author of this component dealt with this topic like this:

image

https://github.com/syssi/esphome-jbd-bms

BMS Power is +- Charging and discharging power is always positive

latonita commented 9 months ago

Okay, I was too fast in judgment. As per datasheet this value is always positive.

"Calculated power output. Output value in watts. Unsigned representation. Positive value"

If you need negative sign you might use custom filter to multiply it by - 1 when needed

BR, Anton


From: kolins-cz @.> Sent: Monday, February 12, 2024 6:07:56 PM To: latonita/esphome-ina228 @.> Cc: Anton Viktorov @.>; Comment @.> Subject: Re: [latonita/esphome-ina228] Power value not inverting (Issue #1)

I believe there should be negative power. At least as an option. In solar power applications, negative current and power usually means discharging battery.

Naturally, you can't have power loss of -50W on resistor. But for me it would mean that power flows in opposite way.

Author of this component dealt with this topic like this:

image.png (view on web)https://github.com/latonita/esphome-ina228/assets/8409715/f5ecbbdf-97e0-4744-bc33-b23fa93bbf07

— Reply to this email directly, view it on GitHubhttps://github.com/latonita/esphome-ina228/issues/1#issuecomment-1939166842, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA6O66VYKBDT5IP3N4KSSVDYTJD6ZAVCNFSM6AAAAABDFBWCUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGE3DMOBUGI. You are receiving this because you commented.Message ID: @.***>

clomads commented 9 months ago

Fair enough, that should be no problem. Thanks for your help and thanks again for building this.

latonita commented 6 months ago

@kolins-cz @clomads hi, can you test last version on esphome PR https://github.com/esphome/feature-requests/issues/2549 ? i would be very thankful

clomads commented 6 months ago

hey @latonita this is working well at first look but the new required "model" entry is a bit confusing and I couldn't find any updated docs for it. When I use INA238, which the compiler seems happy with, the chip returns "238" which throws an error, but it still works. Changing to 238 or "238" it throws an error and doesn't compile.

Screenshot 2024-05-13 at 3 02 42 PM Screenshot 2024-05-13 at 2 33 23 PM

also, just wanted to mention while I'm here that I got accepted by Crowd Supply to do a funding campaign on my 500A shunt that I'll be releasing with your component. I truly appreciate the work you've done here. In case you wanna take a look, here's my docs so far: https://wiki.vdbx.io/products/pwrtool500

latonita commented 6 months ago

@clomads thanks for testing, apologies, i forgot to update docs. model shall be 'INA228' or other INA238 or. ... etc.

Great to hear about your progress! Keep up doing things!

latonita commented 6 months ago

@clomads can I have a full log with level = verbose please? my device is no longer with me , need to check thanks

latonita commented 6 months ago

hey @latonita this is working well at first look but the new required "model" entry is a bit confusing and I couldn't find any updated docs for it. When I use INA238, which the compiler seems happy with, the chip returns "238" which throws an error, but it still works. i think i found this minor glitch and fixed it. check latest ver.

clomads commented 6 months ago

Hey @latonita it's perfect!

Screenshot 2024-05-14 at 1 56 57 PM
kolins-cz commented 6 months ago

@kolins-cz @clomads hi, can you test last version on esphome PR esphome/feature-requests#2549 ? i would be very thankful

Hello, I have tested some version, hopefully the latest.

external_components:
  - source: github://syssi/esphome-jk-bms@main
  - source: github://syssi/esphome-jbd-bms@main
  - source: github://pr#6138
    components: [ina2xx_base, ina2xx_spi]
    refresh: 0s

I have added model: INA229 and everything seems to be working like before

I am still confused about what PR# to use from where and how. Let me know if I used wrong one.