Micropython library for the TI INA219 voltage/current sensor

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

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

Post by jcf » Tue May 02, 2023 8:15 am

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)

chrisb2
Posts: 28
Joined: Sat Apr 01, 2017 4:19 am

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

Post by chrisb2 » Tue May 02, 2023 8:54 am

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

chrisb2
Posts: 28
Joined: Sat Apr 01, 2017 4:19 am

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

Post by chrisb2 » Tue May 02, 2023 9:01 am

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

User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

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

Post by jcf » Tue May 02, 2023 9:38 am

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.

User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

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

Post by jcf » Tue May 02, 2023 9:47 am

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...

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

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

Post by scruss » Tue May 02, 2023 11:23 pm

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

User avatar
jcf
Posts: 60
Joined: Wed Mar 03, 2021 11:14 am

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

Post by jcf » Fri May 05, 2023 6:39 am

I have started a thread INA226 on the Github forum

Post Reply