Dear All,
I would like to ask your help to fix this issue:
-using B+ ina219 on i2c works fine, no issue
-using Pi2 + ina219 I have the following error:
./ina219_cacti.py
Traceback (most recent call last):
File "./ina219_cacti.py", line 3, in <module>
from Subfact_ina219 import INA219
File "/opt/templog/python/Subfact_ina219.py", line 5, in <module>
from Adafruit_I2C import Adafruit_I2C
File "/opt/templog/python/Adafruit_I2C.py", line 10, in <module>
class Adafruit_I2C :
File "/opt/templog/python/Adafruit_I2C.py", line 24, in Adafruit_I2C
def __init__(self, address, bus=smbus.SMBus(1 if getPiRevision() > 1 else 0), debug=False):
IOError: [Errno 2] No such file or directory
The i2cdetect shows all my sensors, including ina219 on #40, all other sensors like am2321, blp180 works fine.
I just started to learn linux/pi/python, so sorry...maybe you can see the reason, im not
thank you in advance for you support!
G
INA219 python library
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- tdicola
- Posts: 1074
- Joined: Thu Oct 17, 2013 9:11 pm
Re: INA219 python library
Thanks for checking out the INA219! Usually that error means there's a problem accessing the I2C bus, like perhaps the wrong bus number is being picked. To help troubleshoot a little more do you mind pasting the full code that you're running? This will help check what libraries it's using and how the bus is being opened. It looks like something might getting confused and trying to open a device like /dev/i2c1 when it means to open /dev/i2c0 or vice-versa. Thanks!
- tdicola
- Posts: 1074
- Joined: Thu Oct 17, 2013 9:11 pm
Re: INA219 python library
Oh actually I was searching around a little bit and I think are you using this github repo's code? https://github.com/scottjw/subfact_pi_ina219 It looks like the repo there has an old copy of the Adafruit I2C interface and might be causing your problem. What if you grab the latest Adafruit_I2C.py file from its Adafruit github home here: https://github.com/adafruit/Adafruit-Ra ... uit_I2C.py Copy that in and replace the Adafruit_I2C.py file in the directory from that github repo/your code. This newer version has a few fixes to catch different Raspberry Pi revisions and I2C buses. Give that a shot and let me know if replacing the file helps, thanks!
- harshang87
- Posts: 1
- Joined: Tue Jul 21, 2015 9:09 am
Re: INA219 python library
Hi Guys,
I am using the adafruit ina219 breakout board with raspberry pi. I am using the code as on: https://github.com/scottjw/subfact_pi_i ... _ina219.py
But the current and voltage values are incorrect.
I am using the default resistor and I am using the exact code as on the above page without any modifications, It doenst wotk for me.
I get bus voltage as 0 always and shunt v of 7.1mv and current to be 71ma when the real voltage is 12.9v and 0.3amps.
Can someone please help me?
Many thanks.
I am using the adafruit ina219 breakout board with raspberry pi. I am using the code as on: https://github.com/scottjw/subfact_pi_i ... _ina219.py
But the current and voltage values are incorrect.
I am using the default resistor and I am using the exact code as on the above page without any modifications, It doenst wotk for me.
I get bus voltage as 0 always and shunt v of 7.1mv and current to be 71ma when the real voltage is 12.9v and 0.3amps.
Can someone please help me?
Many thanks.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: INA219 python library
Post a photo showing your hardware and connections and we'll take a look. 800x600 images usually work best.
- aoaaa
- Posts: 2
- Joined: Fri Jan 22, 2016 11:52 am
Re: INA219 python library
Hi Guys,
Also I am using the Adafruit ina219 breakout board but with Raspberry Pi 2 Model B (1 GB RAM).
I am using the code as on: https://github.com/scottjw/subfact_pi_i ... _ina219.py but i'm encountering incorrect values.
I tried to power in a smartphone power supply (5V 1 A) end I got different values.
Could you help me?
Please, I need it for the project of my final exam!
Also I am using the Adafruit ina219 breakout board but with Raspberry Pi 2 Model B (1 GB RAM).
I am using the code as on: https://github.com/scottjw/subfact_pi_i ... _ina219.py but i'm encountering incorrect values.
I tried to power in a smartphone power supply (5V 1 A) end I got different values.
Could you help me?
Please, I need it for the project of my final exam!
- Attachments
-
- voltage sensor.png (50.82 KiB) Viewed 2116 times
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: INA219 python library
Unfortunately there's a hardware problem.
The INA219 uses an I2C signal called the 'repeated start' to set the address for read operations. The controlling device has to emit a write command to set the address of the register it wants, then emit a start, and a generic read command.
The problem is that the RasPi's microprocessor doesn't support repeated starts. It's not compliant with the I2C spec in that regard, and the RasPI I2C modules don't provide any convenient way to work around the lack.
The simplest and most complete solution is to put a microcontroller between the RasPi and any devices like the INA219, let the microcontroller handle communication with the sensor, and have the RasPi communicate with the microcontroller through the Serial connection.
The INA219 uses an I2C signal called the 'repeated start' to set the address for read operations. The controlling device has to emit a write command to set the address of the register it wants, then emit a start, and a generic read command.
The problem is that the RasPi's microprocessor doesn't support repeated starts. It's not compliant with the I2C spec in that regard, and the RasPI I2C modules don't provide any convenient way to work around the lack.
The simplest and most complete solution is to put a microcontroller between the RasPi and any devices like the INA219, let the microcontroller handle communication with the sensor, and have the RasPi communicate with the microcontroller through the Serial connection.
- aoaaa
- Posts: 2
- Joined: Fri Jan 22, 2016 11:52 am
Re: INA219 python library
Thanks for the answer but I don't understand...
The problem is about my INA219 or it concerns all INA219 chips?
Why are faraday's measurements good?
Thanks
The problem is about my INA219 or it concerns all INA219 chips?
Why are faraday's measurements good?
Thanks
- je11nsn
- Posts: 9
- Joined: Wed Feb 17, 2016 11:16 am
Re: INA219 python library
wondering if anyone can help me out here!
I am trying to use the code provided from scottjw on my raspberrypi for the ina219 however I am getting the following error
Inport error: no module named Subfact_ina219 import INA219
any help would be greatly appreciated
I am trying to use the code provided from scottjw on my raspberrypi for the ina219 however I am getting the following error
Inport error: no module named Subfact_ina219 import INA219
any help would be greatly appreciated
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: INA219 python library
@aoaaa: Sometimes you can get a good reading despite the I2C problem, but not always. You can take multiple readings and discard the ones that return zero or near-zero values. You probably won't be able to eliminate them without using a microcontroller though.
@je11nsn: Did you download the whole repository from Github, or just the first file? The Subfact_ina219 module is defined in another file in the same directory.
@je11nsn: Did you download the whole repository from Github, or just the first file? The Subfact_ina219 module is defined in another file in the same directory.
- boguiyu
- Posts: 7
- Joined: Tue May 10, 2016 4:23 pm
Re: INA219 python library
I followed the previous comments and try to make it work. However, it seems like the i2c is not working. I already enabled it on my Pi. Here is my wire connection and the error. Anyone can help me?
Thanks!
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: INA219 python library
You need to solder the header pins into the INA219 PCB. They don't make a useful connection unless they're soldered.
-
- Posts: 24
- Joined: Sun May 15, 2016 9:12 pm
Re: INA219 python library
i have this exact sensor up and running on my BBB using the same python script you are trying to get to work,
i tried upgrading from debian 7.9 to the new debian 8.3 and had the same issue, it appears that the second 12c buss is enabled by default thus replacing bus1 and moving every thing over to bus2... so be sure this is not your issue...
not sure what OS your using but if its debian 8.3 (jessie) you need to make sure your using the correct 12c buss.. on BBB there are 3 i2c buss's
hope this helps
i tried upgrading from debian 7.9 to the new debian 8.3 and had the same issue, it appears that the second 12c buss is enabled by default thus replacing bus1 and moving every thing over to bus2... so be sure this is not your issue...
not sure what OS your using but if its debian 8.3 (jessie) you need to make sure your using the correct 12c buss.. on BBB there are 3 i2c buss's
hope this helps
- boguiyu
- Posts: 7
- Joined: Tue May 10, 2016 4:23 pm
Re: INA219 python library
Thanks! I will try.BANNED wrote:i have this exact sensor up and running on my BBB using the same python script you are trying to get to work,
i tried upgrading from debian 7.9 to the new debian 8.3 and had the same issue, it appears that the second 12c buss is enabled by default thus replacing bus1 and moving every thing over to bus2... so be sure this is not your issue...
not sure what OS your using but if its debian 8.3 (jessie) you need to make sure your using the correct 12c buss.. on BBB there are 3 i2c buss's
hope this helps
- boguiyu
- Posts: 7
- Joined: Tue May 10, 2016 4:23 pm
Re: INA219 python library
Thanks! I will solder it tomorrow!adafruit_support_mike wrote:You need to solder the header pins into the INA219 PCB. They don't make a useful connection unless they're soldered.
Please be positive and constructive with your questions and comments.