but while I'm trying to run the example code
Code: Select all
from ina219 import INA219, DeviceRangeError
from time import sleep
SHUNT_OHMS = 0.1
MAX_EXPECTED_AMPS = 2.0
ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
ina.configure(ina.RANGE_16V)
def read_ina219():
try:
print('Bus Voltage: {0:0.2f}V'.format(ina.voltage()))
print('Bus Current: {0:0.2f}mA'.format(ina.current()))
print('Power: {0:0.2f}mW'.format(ina.power()))
print('Shunt Voltage: {0:0.2f}mV\n'.format(ina.shunt_voltage()))
except DeviceRangeError as e:
# Current out of device range with specified shunt resister
print(e)
while 1:
read_ina219()
sleep(1)
Code: Select all
sudo python3 Documents/VoltTest.py
Traceback (most recent call last):
File "Documents/VoltTest.py", line 1, in <module>
from ina219 import INA219, DeviceRangeError
ImportError: bad magic number in 'ina219': b'\x03\xf3\r\n'
pi@raspberrypi:~ $ sudo python Documents/VoltTest.py
Traceback (most recent call last):
File "Documents/VoltTest.py", line 1, in <module>
from ina219 import INA219, DeviceRangeError
File "/home/pi/Documents/ina219.py", line 1, in <module>
""" This library supports the INA219 current and power monitor
ImportError: cannot import name INA219
what could be the problem ?
Thanks ,
** this is without any connection to my other post https://www.raspberrypi.org/forums/view ... 0#p1561230