Please be aware of all shipping deadlines before placing your order - we cannot guarantee orders will arrive before Christmas!

INA219 python library
Moderators: adafruit_support_bill, adafruit

INA219 python library

by cmcd2820 on Fri Jan 11, 2013 11:26 pm

Does anyone have a python library for using the INA219 High Side DC Current Breakout on the Raspberry PI? I can start trying to blow it up (playing with it), but didn't want to duplicate it if there was one out there somewhere.

cmcd2820
 
Posts: 16
Joined: Wed Dec 26, 2012 1:23 am

Re: INA219 python library

by Static on Sun Jan 13, 2013 4:23 pm

I've been looking for Raspberry Pi/Python libraries for about two months now. While I wasn't looking for the INA219, I've been grabbing everything that looked interesting. I don't see this in the work I did. I'll keep an eye out and let you know if I find something. I don't think it's in the Adafruit I2C Python Library, but I'm not sitting at my primary computer right now.
Static
 
Posts: 180
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

by cmcd2820 on Mon Jan 14, 2013 12:49 am

Thanks Static. I've looked at the Arduino library for it and it would just be calls to the correct registers, I think.... Just need to get that initial setup call to the board. I can play with the rest to get the values to a usable state. I'm also not sure on wiring the I2C bus. Do I run it parallel or is it a serial bus? When I plugged it in along with the 16x2 LCD, it kind of freaked out the I2C bus. Doing an I2C detect showed it on one address, and then on another, and then it showed several registers and the bus locked up until I pulled it.

cmcd2820
 
Posts: 16
Joined: Wed Dec 26, 2012 1:23 am

Re: INA219 python library

by adafruit_support_bill on Mon Jan 14, 2013 7:09 am

I2C devices connect in parallel on the bus using the same two wires. As long as the devices are at different addresses there should be no conflict. One thing to be careful of is mixing 3.3v and 5v devices on the same I2C bus. The Pi has 2 i2c buses - or you can use a bi-directional level shifter. http://www.adafruit.com/products/757
User avatar
adafruit_support_bill
 
Posts: 32638
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 python library

by cmcd2820 on Thu Jan 17, 2013 2:18 pm

Awesome. Hadn't thought to look at the 5v vs. 3v on both of them.

Is there any work being done on a python library for the INA219 for the Raspberry Pi?

cmcd2820
 
Posts: 16
Joined: Wed Dec 26, 2012 1:23 am

Re: INA219 python library

by Static on Sat Feb 09, 2013 9:00 am

Does the 512MB version of the Pi have two I2C buses? I thought the second bus was lost when the memory was increased.
If so, what are the "physics" of using the second bus? I'd love to be able to use two BMP085 sensors on the same board.
Static
 
Posts: 180
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

by adafruit_support_bill on Sun Feb 10, 2013 8:26 am

As I understand it, you can still enable more than one I2C bus, but only 2 GPIO pins have the requisite pullup resistors.
User avatar
adafruit_support_bill
 
Posts: 32638
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 python library

by Static on Fri Feb 15, 2013 10:58 pm

Shoot.
I would love to figure out how to do this. I've already wired my own external resistors into my bus. It would really help me to have two sets of identical sensors on the same board.
Static
 
Posts: 180
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

by ScottJW on Wed Feb 20, 2013 1:56 pm

I did a quick port of the Adafruit_INA219 Arduino library to python for the Pi. It is available on github here https://github.com/scottjw/subfact_pi_ina219
ScottJW
 
Posts: 1
Joined: Wed Feb 20, 2013 1:53 pm

Re: INA219 python library

by Static on Thu Feb 21, 2013 8:58 am

Looks good. I've got to get a new sensor. The donated one that I have doesn't appear to be working.
When I get it and add it to the gear, I'll shoot you a message.
Static
 
Posts: 180
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

by karlos on Mon May 13, 2013 10:37 pm

I'v been looking around for the simplest way a Pi can read the volts and current of a small 12v solar setup and output to Munin or the like.

I'm an IC board novice though. :roll: Is this breakout board simply connected directly into the pi gpio then connected too it from the battery or solar panel?

Then its just a matter of setting up python to read the result.
karlos
 
Posts: 3
Joined: Mon May 13, 2013 10:28 pm

Re: INA219 python library

by adafruit_support_mike on Wed May 15, 2013 5:04 pm

The INA219 will read the current and convert it to a digital signal your RasPi can use, but you'll need another device to read the voltage. The ADS1015 (http://www.adafruit.com/products/1083) reads voltage, and we have a RasPi library for it.

Both product pages have links to tutorials that will tell you how to connect the breakouts to your control board and talk to them:

http://learn.adafruit.com/adafruit-ina2 ... t/overview
http://learn.adafruit.com/adafruit-4-ch ... -breakouts

The tutorials are written for Arduino, but they'll give you the general idea of how to connect to a RasPi. If you need help, come on back and we'll get you going.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 11337
Joined: Thu Feb 11, 2010 2:51 pm

Re: INA219 python library

by karlos on Wed May 15, 2013 10:23 pm

Oh no another board!

Thanks for the reply as I was just about to order. But hang on that's a A to D converter you have linked too, no mention of voltage is on that page?

I'm lost... isn't high side voltage relevant?

you can just use the handy INA219B chip on this breakout to both measure both the high side voltage and DC current draw over I2C with 1% precision.
karlos
 
Posts: 3
Joined: Mon May 13, 2013 10:28 pm

Re: INA219 python library

by adafruit_support_mike on Thu May 16, 2013 9:24 pm

The ADS1015 isn't exactly a voltmeter but it's close. It takes an input voltage between 0 and 4.096v and returns a 12-bit integer whose smallest increment is equivlent to 1mV.

If the voltage you want to measure is less than about 4v, you can use the ADS1015's output directly. If the voltage you want to measure is larger than 4v, you can put a voltage divider between that and GND, measure the voltage at the middle of the divider, then scale that up to get the actual voltage.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 11337
Joined: Thu Feb 11, 2010 2:51 pm

Re: INA219 python library

by karlos on Fri May 17, 2013 2:00 am

Oh ok, Thanks, What does this voltage measure mean Bill?

you can just use the handy INA219B chip on this breakout to both measure both the high side voltage and DC current draw over I2C with 1% precision.
karlos
 
Posts: 3
Joined: Mon May 13, 2013 10:28 pm