Page 3 of 3

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Tue May 02, 2023 8:15 am
by jcf
I discovered a bug in the library:

Code: Select all

@property
    def shunt_voltage(self):
        """The shunt voltage (between V+ and V-) in Volts (so +-.327V)"""    # no, +-80mV!
        value = _to_signed(self._read_register(_REG_SHUNTVOLTAGE))
        # The least signficant bit is 10uV which is 0.00001 volts
        # NO!! It is 2.5uV
        # return value * 0.00001
        return value * 0.0000025
Chris defined the shunt voltage LSB as 10uV, but the datasheet says 2.5uV.
Unfortunately my results are still wrong after this correction (by a factor 5 for current and power)

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Tue May 02, 2023 8:54 am
by chrisb2
Can you tell me where in the datasheet for the ina219 (https://www.ti.com/lit/ds/symlink/ina219.pdf) you saw 2.5uV? I see 10uV in the Electrical Characteristics table on page 5 where it say 10uV in the DC Accuracy section.

Chris

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Tue May 02, 2023 9:01 am
by chrisb2
Probably you should raise an issue against my library (https://github.com/chrisb2/pyb_ina219/issues) if believe its wrong, rarther that further discussion in this old topic in a deprecated forum.

Chris

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Tue May 02, 2023 9:38 am
by jcf
Hi Chris,
on page 16 you have a table where a resolution of 2.5uV is mentioned for the shunt register.
Also on page 24 they say Full scale = 81.92mV and LSB = 2.5uV
I do not see where you find 10uV on p.5.

Anyway, this datasheet is a mess! Totally confusing!
Probably you should raise an issue against my library (https://github.com/chrisb2/pyb_ina219/issues) if believe its wrong, rarther that further discussion in this old topic in a deprecated forum.
Hmmm... I have never done this. I'll see if I find out how to do it.
By the way, I like the old forum more than the new one.

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Tue May 02, 2023 9:47 am
by jcf
Oh, I'm sorry, I noticed just now that I have added some confusion to this discussion.
I found this topic when looking for an INA226 lib. And I found yours, Chris.
Somewhere under this topic there is a mention of the 226, I mentioned it too in my post.
But you, Chris, spoke of the 219, I think?

Everything I posted is in relation to the INA226, also the bug I found.
Maybe I should have started a new topic...

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Tue May 02, 2023 11:23 pm
by scruss
jcf wrote:
Tue May 02, 2023 9:47 am
Maybe I should have started a new topic...
best on GitHub Discussions, since this forum is moribund

Re: Micropython library for the TI INA219 voltage/current sensor

Posted: Fri May 05, 2023 6:39 am
by jcf
I have started a thread INA226 on the Github forum