Micropython library for the TI INA219 voltage/current sensor
Re: Micropython library for the TI INA219 voltage/current sensor
Hello everyone,
and thank you all for your help (and sorry for the long time of being quiet). I've had to deal with a few work and study issues which did consume most of my time and/or motivation.
I've managed to adapt https://github.com/robert-hh/INA219 to work with my INA226. I have yet to figure out the calibration of values, but so far it looks promising - measured and computed values are not too far off of what my DMM tell me. So far I have only modified the calibration routine for 32V and 2A, but will change the rest soon accordingly.
@Roberthh: I have no experience in publishing modified libraries or such, what do I need to add or delete in my version of your library so I fulfill licenses? I do want to make it available to the public, but I also do not want to violate any licensing.
As I see it, I'd need to include credits to you in the header, as well as keep the existing "MIT License" header, and the "Adafruit" stuff too?
Greetings
Chris
and thank you all for your help (and sorry for the long time of being quiet). I've had to deal with a few work and study issues which did consume most of my time and/or motivation.
I've managed to adapt https://github.com/robert-hh/INA219 to work with my INA226. I have yet to figure out the calibration of values, but so far it looks promising - measured and computed values are not too far off of what my DMM tell me. So far I have only modified the calibration routine for 32V and 2A, but will change the rest soon accordingly.
@Roberthh: I have no experience in publishing modified libraries or such, what do I need to add or delete in my version of your library so I fulfill licenses? I do want to make it available to the public, but I also do not want to violate any licensing.
As I see it, I'd need to include credits to you in the header, as well as keep the existing "MIT License" header, and the "Adafruit" stuff too?
Greetings
Chris
Re: Micropython library for the TI INA219 voltage/current sensor
Hi @elschopi, glad that it's working and that I could help. Looking at my drivers file, it seems to need some edit. Especially the hardware and software dependencies are not vaild.
About licensing: You have to copy/keep the header of file. And you have to include the first Authors copyright note. Do you not have to include me. I just changed the I2C access method, and that's just tiny change, way less than the work you have to adapt it to a INA226 device.
About licensing: You have to copy/keep the header of file. And you have to include the first Authors copyright note. Do you not have to include me. I just changed the I2C access method, and that's just tiny change, way less than the work you have to adapt it to a INA226 device.
Re: Micropython library for the TI INA219 voltage/current sensor
Thanks again for your help =)
I'm in the middle of re-arranging the config register values, after I just figured out the differences. Interestingly, even though the differences are quite significant, it works even with the config register values for the INA219 device.
As soon as I have implemented these changes (and tested them), I'll be able to release the library into the wild
Maybe I can put together a small helper tool in Google sheets or something like that for the configuration register.
Anyhow, I'm learning very much from this, which I am very happy about. I've never been too involved with anything software-ish, so programming concepts and bit/byte operations are not exactly my best field I'm more a hardware / circuit-design kind of guy.
Thanks everyone, and a nice rest of the sunday (which here is a rainday)
Best regards
Chris
I'm in the middle of re-arranging the config register values, after I just figured out the differences. Interestingly, even though the differences are quite significant, it works even with the config register values for the INA219 device.
As soon as I have implemented these changes (and tested them), I'll be able to release the library into the wild
Maybe I can put together a small helper tool in Google sheets or something like that for the configuration register.
Anyhow, I'm learning very much from this, which I am very happy about. I've never been too involved with anything software-ish, so programming concepts and bit/byte operations are not exactly my best field I'm more a hardware / circuit-design kind of guy.
Thanks everyone, and a nice rest of the sunday (which here is a rainday)
Best regards
Chris
Re: Micropython library for the TI INA219 voltage/current sensor
Hello everyone,
I've managed to put it all together and am now proudly serving it on github under
https://github.com/elschopi/TI_INA226_micropython
I have a Google spreadsheet prepared for calculations and stuff, if anyone's interested - link is in the github readme.
Please feel free to educate me where and how I've done stupid things, as I'm not too experienced with this
Have a great day, and thanks to all for the great support
Best regards
Chris
I've managed to put it all together and am now proudly serving it on github under
https://github.com/elschopi/TI_INA226_micropython
I have a Google spreadsheet prepared for calculations and stuff, if anyone's interested - link is in the github readme.
Please feel free to educate me where and how I've done stupid things, as I'm not too experienced with this
Have a great day, and thanks to all for the great support
Best regards
Chris
Re: Micropython library for the TI INA219 voltage/current sensor
Hello Chris,
the driver looks fine. One comment: I just removed from my driver these lines at the header:
They simply do not apply. You copied these too, and in your driver they fit even worse.
the driver looks fine. One comment: I just removed from my driver these lines at the header:
Code: Select all
Implementation Notes
--------------------
**Hardware:**
* `Adafruit INA219 High Side DC Current Sensor Breakout
<https://www.adafruit.com/product/904>`_
* `Adafruit INA219 FeatherWing <https://www.adafruit.com/product/3650>`_
**Software and Dependencies:**
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
* Adafruit's Bus Device library:
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Re: Micropython library for the TI INA219 voltage/current sensor
Hello Robert,
thanks for the feedback. I've removed these lines now, too.
Best regards,
Chris
thanks for the feedback. I've removed these lines now, too.
Best regards,
Chris
Re: Micropython library for the TI INA219 voltage/current sensor
my dears, I am searching for INA260 library for Pico (micropython) but no success
I am assuming the libs you are mentioning here for other INAs are not compatible, right?
any hint please what to adjust in the existing libraries to have INA260 working on my Pico?
thank you
I am assuming the libs you are mentioning here for other INAs are not compatible, right?
any hint please what to adjust in the existing libraries to have INA260 working on my Pico?
thank you
Re: Micropython library for the TI INA219 voltage/current sensor
Seems like one option would be Circuitpython which has a ina260 library see:
https://learn.adafruit.com/getting-star ... cuitpython
https://learn.adafruit.com/adafruit-ina ... cuitpython
Chris
https://learn.adafruit.com/getting-star ... cuitpython
https://learn.adafruit.com/adafruit-ina ... cuitpython
Chris
Re: Micropython library for the TI INA219 voltage/current sensor
Hi Chris,
thanks a lot for the INA226 driver, and especially for the example in the code.
If I had seen that at the beginning I could have progressed much faster!
The datasheet is a pain to read, very confusing, mixing register values and electrical values, neglecting the units etc.
Once I had discovered your example, I got my chip to work.
thanks a lot for the INA226 driver, and especially for the example in the code.
If I had seen that at the beginning I could have progressed much faster!
The datasheet is a pain to read, very confusing, mixing register values and electrical values, neglecting the units etc.
Once I had discovered your example, I got my chip to work.
Re: Micropython library for the TI INA219 voltage/current sensor
Now as I wanted to document my work I noticed that I had done an error when calculating the Calibration value.
I have Rs = 0.002 Ohm and Imax = 15A.
That gives 0.5mA (rounded) for Current_LSB and 12.5mW for Power_LSB.
From that I deduce CAL = 5.12mV / (Current_LSB) = 5.12/ (0.5 * 0.002) = 5120
With this value I get wrong results for current and power.
The day before I had not paid attention and used a value of 25600 for the CAL, and this wrong value gave me the right results.
Strange, isn't it!?
I have Rs = 0.002 Ohm and Imax = 15A.
That gives 0.5mA (rounded) for Current_LSB and 12.5mW for Power_LSB.
From that I deduce CAL = 5.12mV / (Current_LSB) = 5.12/ (0.5 * 0.002) = 5120
With this value I get wrong results for current and power.
The day before I had not paid attention and used a value of 25600 for the CAL, and this wrong value gave me the right results.
Strange, isn't it!?