0

INA260 current sensor library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

INA260 current sensor library

by tronicgr on Mon May 01, 2017 11:14 pm

Hi,

I needed the INA260 for a project but couldn't find anywhere a arduino library for it. So i decided to write one myself. Well, not exactly from scratch, i used the Adafruit INA219 as base, replaced the new register locations and conversion calculations. Anyway, after a few hours the new library is ready and tested. Works great. Some functions are missing, but it can measure the voltage and the current perfectly. I used the TI's evaluation board for testing: https://youtu.be/8NWVv__e6lM

The library can be found here:

https://github.com/tronicgr/INA260-current-sensor

I wish Adafruit would start making a breakout for these INA260 sensors, they are amazing for what they can do. And of course i won't mind if parts or even the whole the library i shared above was used for the breakouts.

Its the least contribution i can do for Adafruit, whose breakout boards literaly helped so many times fast prototyping on my projects!

Thanks
Thanos

tronicgr
 
Posts: 76
Joined: Wed Feb 03, 2016 1:48 pm

Re: INA260 current sensor library

by adafruit_support_bill on Tue May 02, 2017 5:58 am

Thank you for the suggestion. I will forward it to the design team.

adafruit_support_bill
 
Posts: 81580
Joined: Sat Feb 07, 2009 10:11 am

Re: INA260 current sensor library

by tronicgr on Tue Oct 17, 2017 11:45 am

I just shared a new arduino library for a different battery current/gauge sensor that is perfect for portable applications.

https://github.com/tronicgr/MAX17055-cu ... uge-sensor


I hope that helps.

Thanks
Thanos

tronicgr
 
Posts: 76
Joined: Wed Feb 03, 2016 1:48 pm

Re: INA260 current sensor library

by adafruit_support_bill on Tue Oct 17, 2017 12:20 pm

Great! Thank you for sharing your code.

adafruit_support_bill
 
Posts: 81580
Joined: Sat Feb 07, 2009 10:11 am

Re: INA260 current sensor library

by eastpole on Fri May 03, 2019 11:36 am

Great suggestion for a product, Thanos. The INA260 breakout is now available from Adafruit:
https://www.adafruit.com/product/4226
Yaaaay! I'm going to wire up a solar panel and measure what it puts into a battery.

eastpole
 
Posts: 4
Joined: Sun Mar 24, 2013 10:11 pm

Re: INA260 current sensor library

by bartgrefte on Sat Jul 20, 2019 1:28 pm

How do you modify the example in the library to be able to use multiple INA260 breakout boards? Looks to me the library is specifically written for using the default address.

bartgrefte
 
Posts: 88
Joined: Thu Dec 13, 2007 10:01 am

Re: INA260 current sensor library

by adafruit_support_bill on Sat Jul 20, 2019 1:53 pm

The 'begin' function in the library takes an optional address. Just specify the alternate address for the second instance.

Code: Select all | TOGGLE FULL SIZE
  boolean begin(uint8_t i2c_addr=INA260_I2CADDR_DEFAULT, TwoWire *theWire = &Wire);

adafruit_support_bill
 
Posts: 81580
Joined: Sat Feb 07, 2009 10:11 am

Re: INA260 current sensor library

by bartgrefte on Mon Jul 22, 2019 7:21 am

adafruit_support_bill wrote:The 'begin' function in the library takes an optional address. Just specify the alternate address for the second instance.

Code: Select all | TOGGLE FULL SIZE
  boolean begin(uint8_t i2c_addr=INA260_I2CADDR_DEFAULT, TwoWire *theWire = &Wire);

I guess I need to change
Code: Select all | TOGGLE FULL SIZE
Adafruit_INA260 ina260 = Adafruit_INA260();
for that? https://learn.adafruit.com/adafruit-ina ... t?view=all doesn't show anything about this, the option of changing the I2C-address (those solder jumpers or whatever they are called) isn't even mentioned.

bartgrefte
 
Posts: 88
Joined: Thu Dec 13, 2007 10:01 am

Re: INA260 current sensor library

by adafruit_support_bill on Mon Jul 22, 2019 8:13 am

Not the constructor - the begin() function. Assuming that you create 2 instances: ina260_A and ina260_B, your setup code would be something like:

Code: Select all | TOGGLE FULL SIZE
if (!ina260_A.begin())
{
   Serial.println("Couldn't find INA260 chip - A");
   while (1);
}

if (!ina260_B.begin(0x41))
{
   Serial.println("Couldn't find INA260 chip - B");
   while (1);
}


Both address jumpers are pulled to GND by default. If you bridge them, they are pulled to VS. So bridging A0 gives you address 0x41.

See Table 2 on page 17 of the data sheet.
http://www.ti.com/lit/ds/symlink/ina260.pdf

adafruit_support_bill
 
Posts: 81580
Joined: Sat Feb 07, 2009 10:11 am

Re: INA260 current sensor library

by bartgrefte on Mon Jul 22, 2019 12:16 pm

Ah, thanks :), that got me going, now reading two INA260's on the same Arduino.

bartgrefte
 
Posts: 88
Joined: Thu Dec 13, 2007 10:01 am

Re: INA260 current sensor library

by JM_Tech on Wed Jul 24, 2019 6:37 am

I am bridging A0 as described here and I am still only getting address 0x40. Any example would be helpful as I have been struggling with this for hours now.

*****Scratch That******

I was 1 pin off and did not realize it... even after I checked with the meter... Facepalm moment

JM_Tech
 
Posts: 2
Joined: Wed May 22, 2019 10:57 am

Please be positive and constructive with your questions and comments.