Simple test

Ensure your device works with this simple test.

examples/ina219_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import time

from board import SCL, SDA
import busio

import adafruit_ina219

i2c_bus = busio.I2C(SCL, SDA)

ina219 = adafruit_ina219.INA219(i2c_bus)

print("ina219 test")

while True:
    print("Bus Voltage:   {} V".format(ina219.bus_voltage))
    print("Shunt Voltage: {} mV".format(ina219.shunt_voltage / 1000))
    print("Load Voltage:  {} V".format(ina219.bus_voltage + ina219.shunt_voltage))
    print("Current:       {} mA".format(ina219.current))
    print("")

    time.sleep(2)