This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
INA219 directly on i2c of Pi without ESP8266
#1
I decided to order an INA219 board and to connect it directly to the pi, and not use an ESP8266 or Arduino to send the values to the Pi, but connect it directly to I2c / SDA and SDL. Hardware works and when I run the following script I get the readings:

Code:
#!/usr/bin/env python

import logging
from ina219 import INA219

SHUNT_OHMS = 0.01
MAX_EXPECTED_AMPS = 10


def read():
    ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, log_level=logging.INFO)
    ina.configure(ina.RANGE_16V, ina.GAIN_AUTO)

    print("Bus Voltage    : %.3f V" % ina.voltage())
    print("Bus Current    : %.3f mA" % ina.current())
    print("Supply Voltage : %.3f V" % ina.supply_voltage())
    print("Shunt voltage  : %.3f mV" % ina.shunt_voltage())
    print("Power          : %.3f mW" % ina.power())


if __name__ == "__main__":
    read()

Readings:


Code:
2020-02-06 17:25:28,198 - INFO - INA219 gain set to 0.16V
2020-02-06 17:25:28,200 - INFO - INA219 calibrate called with: bus max volts: 16V, max shunt volts: 0.16V, max expected amps: 10.000A
2020-02-06 17:25:28,201 - INFO - INA219 max possible current: 16.000A
2020-02-06 17:25:28,201 - INFO - INA219 max expected current: 10.000A
2020-02-06 17:25:28,202 - INFO - INA219 current LSB: 6.250e-05 A/bit
2020-02-06 17:25:28,202 - INFO - INA219 power LSB: 1.250e-03 W/bit
2020-02-06 17:25:28,203 - INFO - INA219 max current before overflow: 2.0480A
2020-02-06 17:25:28,204 - INFO - INA219 max shunt voltage before overflow: 20.4800mV
2020-02-06 17:25:28,205 - INFO - INA219 calibration: 0xfffe (65534)
Bus Voltage    : 12.464 V
Bus Current    : 108.003 mA
Supply Voltage : 12.453 V
Shunt voltage  : 1.140 mV
Power          : 1542.547 mW


So, the board works.

I can't however for the life of me get these values into SignalK.  The current available tools scripts for INA219 seem to be designed for usage with the ESP8266. What script do I use to use the INA219 directly on i2C of the pi?

Hope someone can help.

Regards,

Jamos
Reply


Messages In This Thread
INA219 directly on i2c of Pi without ESP8266 - by jamos.tan@gmail.com - 2020-02-06, 05:39 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)