pyb_ina219
pyb_ina219 copied to clipboard
Question about INA220 compatibility.
Hi, First great work, this is really useful, thank you.
I was wondering if this library could work for the INA220 ? I am not sure where to find the communication standards to see if the 219 and 220 are the same.
If you think there is a chance it could work, I don't mind buying some and doing the real world testing for you.
You can find the comms protocols described in "Writing to and Reading from the INAxxx" sections of https://www.ti.com/lit/ds/symlink/ina220.pdf and https://www.ti.com/lit/ds/symlink/ina219.pdf, they look very similar, registers look very similar as well.
So I suspect it might not take much to alter my library to work. I suggest you fork my library and see if you can get it to go without major change. If that is the case it may be possible to generalize my library to support both, perhaps with a base class and INA219 and INA220 sub-classes.
I recommend printing both data sheets and very carefully comparing the register definitions starting with the config one.
The first step is to verify you can see it on the i2c bus, this is what I use (you will need to check/adjust pins and possibly first arg to I2C()):
from machine import Pin, I2C
scl = Pin(5)
sda = Pin(18)
i2c = I2C(-1, scl, sda)
print(i2c.scan())
Have fun, Chris