chrisb2 / pi_ina219

This Python library supports the INA219 voltage, current and power monitor from Texas Instruments with a Raspberry Pi using the I2C bus. The intent of the library is to make it easy to use the quite complex functionality of this sensor.
MIT License
114 stars 34 forks source link

addressing i2c bus numbers > 1 #9

Closed eXodus1440 closed 6 years ago

eXodus1440 commented 6 years ago

Hi Chris,

I've been attempting to use your library with an Intel UpSquared and ran into an issue with the Intel's bus numbering system - their GPIO bus is 5 rather than the RPi default (assuming 1)

I made the following changes to ina219.py get it working on my project

def __init__(self, shunt_ohms, max_expected_amps=None, busnum=None, address=__ADDRESS, log_level=logging.ERROR): self._i2c = I2C.get_i2c_device(address=address, busnum=busnum)

Cheers, Steve

chrisb2 commented 6 years ago

That looks like a good change, can you submit a Pull Request? This should not affect RPi since if None is passed as busnum to get_i2c_device() this method tries to determine default of the board, see I2C.

thanks, Chris

eXodus1440 commented 6 years ago

Will do, will be later in the week tho

Cheers, Steve

On 29 Apr 2018, at 05:12, Chris Borrill notifications@github.com<mailto:notifications@github.com> wrote:

That looks like a good change, can you submit a Pull Request? This should not affect RPi since if None is passed as busnum to get_i2c_device() this method tries to determine default of the board, see I2Chttps://github.com/adafruit/Adafruit_Python_GPIO/blob/c543d1df9c0a71bafb9f0a1f9dceecd79a920e74/Adafruit_GPIO/I2C.py#L64.

thanks, Chris

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/chrisb2/pi_ina219/issues/9#issuecomment-385224316, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABOkZ7yqv5drnPK27IsuQUn5Ds3aOewSks5ttT26gaJpZM4TrjhF.

eXodus1440 commented 6 years ago

Hi Chris,

I'm trying to submit the PR but it's saying I don't have permissions, any ideas?

Just in case I was doing something silly, I also followed the below: https://yangsu.github.io/pull-request-tutorial/

Regards, Steve

chrisb2 commented 6 years ago

Do you mean you cannot create the PR?

Chris

On Thu, 17 May 2018, 8:27 AM Steve Bauer, notifications@github.com wrote:

Hi Chris,

I'm trying to submit the PR but it's saying I don't have permissions, any ideas?

Just in case I was doing something silly, I also followed the below: https://yangsu.github.io/pull-request-tutorial/

Regards, Steve

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chrisb2/pi_ina219/issues/9#issuecomment-389654412, or mute the thread https://github.com/notifications/unsubscribe-auth/AC8dV_W34AG-_a6a-ZhYln_G0cZTm7Edks5tzIuzgaJpZM4TrjhF .

chrisb2 commented 6 years ago

Assuming you forked my repo you would do "New pull request", add a comment about your submission, then do " Create pull request"

On Thu, 17 May 2018, 12:59 PM Chris Borrill, chris.borrill@gmail.com wrote:

Do you mean you cannot create the PR?

Chris

On Thu, 17 May 2018, 8:27 AM Steve Bauer, notifications@github.com wrote:

Hi Chris,

I'm trying to submit the PR but it's saying I don't have permissions, any ideas?

Just in case I was doing something silly, I also followed the below: https://yangsu.github.io/pull-request-tutorial/

Regards, Steve

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chrisb2/pi_ina219/issues/9#issuecomment-389654412, or mute the thread https://github.com/notifications/unsubscribe-auth/AC8dV_W34AG-_a6a-ZhYln_G0cZTm7Edks5tzIuzgaJpZM4TrjhF .

chrisb2 commented 6 years ago

Version 1.2.0 containing this improvement has been upload to pypi: pi-ina219