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
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:I just looked back at the photos and saw the Adafruit logo on the board in your photo.. I'm guessing you got it from one of our resellers?

If so, how long have you had it? Our return/replacement period is 30 days, and I think most of our resellers offer the same terms.
Hi mike, thank you for helping. Just another question, I had bought a new ina219 and it worked. As I am new to both raspberry pi and ina219, what steps should I take in order to read the current and voltage?

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

Re: INA219 python library

Post by adafruit_support_mike »

We don't have a RasPi library for the INA219, but the first couple of pages in this thread have links to a version which a member of the community ported: https://github.com/scottjw/subfact_pi_ina219

It has an example script that will show you how to work with the library and the INA219. I think there are also code listings in some of the previous postings in this thread.

User avatar
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:We don't have a RasPi library for the INA219, but the first couple of pages in this thread have links to a version which a member of the community ported: https://github.com/scottjw/subfact_pi_ina219

It has an example script that will show you how to work with the library and the INA219. I think there are also code listings in some of the previous postings in this thread.
Hi mike, I had tried the code in https://github.com/scottjw/subfact_pi_ina219 and run without changing anything. However, syntax error was shown in ina219_example.py and I couldn't find the error. Do I have to modified anything in any of the file before I run??

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

Re: INA219 python library

Post by adafruit_support_mike »

What was the error message?

User avatar
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:What was the error message?
Here is the error.
Attachments
ERROR.JPG
ERROR.JPG (565.44 KiB) Viewed 870 times

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

Re: INA219 python library

Post by adafruit_support_mike »

The error is saying that Python doesn't like a character in the file.

Did you download the files from Github as a zipfile, or did you copy/paste the text?

User avatar
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:The error is saying that Python doesn't like a character in the file.

Did you download the files from Github as a zipfile, or did you copy/paste the text?
I copy and paste it from Github.

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

Re: INA219 python library

Post by adafruit_support_mike »

In that case, you probably got some unexpected characters along the way.

Download the zipfile and extract it to get clean/accurate copies of all the files.

User avatar
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:In that case, you probably got some unexpected characters along the way.

Download the zipfile and extract it to get clean/accurate copies of all the files.
Thanks mike!!! Now I can read it. I had tried measured it with and without a 1.5V AA battery. However, the result turn up less than 1V. Also, the bus voltage did not change at all. Is this the result I should get or is there some error in the coding??
Attachments
rsz_img_0815.jpg
rsz_img_0815.jpg (390.38 KiB) Viewed 821 times

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

Re: INA219 python library

Post by adafruit_support_mike »

The code could be using an incorrect scale factor, but check the battery voltage with a multimeter while it's connected to the INA219 to make sure the value is different.

User avatar
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:The code could be using an incorrect scale factor, but check the battery voltage with a multimeter while it's connected to the INA219 to make sure the value is different.
The values i measured for the bus voltage remains the same. So is it because of the incorrect scale factor? If so, how do i identify the error?

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

Re: INA219 python library

Post by adafruit_support_mike »

If the multimeter reading is the same as the one coming from the INA219, we can assume that both are reasonably accurate.

User avatar
Anna553
 
Posts: 11
Joined: Thu May 28, 2015 10:47 pm

Re: INA219 python library

Post by Anna553 »

adafruit_support_mike wrote:If the multimeter reading is the same as the one coming from the INA219, we can assume that both are reasonably accurate.
Yea, but my multimeter read differently from the ina219. Also. the bus voltage display is incorrectly as the bus voltage remain the same whether it is connected or not connected with a battery.

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

Re: INA219 python library

Post by adafruit_support_mike »

What value do you get from the multimeter?

User avatar
marks3
 
Posts: 52
Joined: Fri Oct 12, 2012 1:07 pm

Re: INA219 python library

Post by marks3 »

This python library works very reliably on my Pi B (Revision 0003). But I get spurious Voltage (bus and shunt) results on a Pi 2 (Revision: China).

However the current results are very accurate and stable. I am measuring the supply to the Pi and Pi 2 in both cases and running the example code from the GitHub link.
I see current draw of about 330 mA on both units.

Has anyone seen problems on the Pi 2. It seems easy to reproduce but I don't have the talent to debug.

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

Return to “General Project help”