INA219 python library

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
cmcd2820
 
Posts: 16
Joined: Wed Dec 26, 2012 1:23 am

INA219 python library

Post by cmcd2820 »

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.

User avatar
static
 
Posts: 188
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

Post by static »

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.

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

Re: INA219 python library

Post by cmcd2820 »

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.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 python library

Post by adafruit_support_bill »

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
cmcd2820
 
Posts: 16
Joined: Wed Dec 26, 2012 1:23 am

Re: INA219 python library

Post by cmcd2820 »

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?

User avatar
static
 
Posts: 188
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

Post by static »

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.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 python library

Post by adafruit_support_bill »

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
static
 
Posts: 188
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

Post by static »

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.

User avatar
scottjw
 
Posts: 1
Joined: Wed Feb 20, 2013 1:53 pm

Re: INA219 python library

Post by scottjw »

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

User avatar
static
 
Posts: 188
Joined: Thu Dec 23, 2010 6:21 pm

Re: INA219 python library

Post by static »

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.

karlos
 
Posts: 3
Joined: Mon May 13, 2013 10:28 pm

Re: INA219 python library

Post by karlos »

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.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: INA219 python library

Post by adafruit_support_mike »

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.

karlos
 
Posts: 3
Joined: Mon May 13, 2013 10:28 pm

Re: INA219 python library

Post by karlos »

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.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: INA219 python library

Post by adafruit_support_mike »

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.

karlos
 
Posts: 3
Joined: Mon May 13, 2013 10:28 pm

Re: INA219 python library

Post by karlos »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”