Gravity: I2C Digital Wattmeter

1. The URL https://wiki.dfrobot.com/Gravity%3A%20I2C%20Digital%20Wattmeter%20SKU%3A%20SEN0291#target_6 has a link in the Raspberry Pi Tutorial to github that is wrong - it takes you to AS3935
2. But instead if I follow the instructions further down it has the correct link - so it suggests to
[email protected]:~ $ git clone https://github.com/DFRobot/DFRobot_INA219.git
Which works.... but the remaining instructions dont work....
[email protected]: $ cd ~/DFRobot_INA219/RaspberryPi/Python/example
[email protected]:~/DFRobot_INA219/RaspberryPi/Python/example $ python getVoltageCurrentPower.py
Because the directory structure has now changed... and someone can not spell Raspberry and decided to use a directory called Respberry
3. So I have got past all of this but I am still having problems....
If I run the example within the sample directory - it works fine... If I try to run the same code in a different directory, it does not work as it cannot find the library....
ie.
[email protected]:~/DFRobot_INA219/Python/RespberryPi/examples/get_voltage_current_power $ python get_voltage_current_power.py
Shunt Voltage : 136.00 mV
Bus Voltage : 5.077 V
Current : 136 mA
Power : 680 mW
(NOTE the new file structure and mis spelling - LOL)
SO same program in a different directory;
[email protected]:~/WaterTankLevel $ python get_voltage_current_power.py
Traceback (most recent call last):
File "get_voltage_current_power.py", line 16, in <module>
from DFRobot_INA219 import INA219
ImportError: No module named DFRobot_INA219
It appears the libraries are not getting installed to somewhere in the path / lib - so where should they be and how do i get them there !!!
Quality Assurance and Testing before releasing - eh!
Items 1, 2 and 3 still have not been fixed.
Running the example python code I get
DFRobot_INA219 I2C init fail
DFRobot_INA219 I2C init fail
DFRobot_INA219 I2C init fail
DFRobot_INA219 I2C init fail
until I do an “i2cdetect -y 1” on another terminal … and then I get:
DFRobot_INA219 I2C init fail
Shunt Voltage: 67.0mV, Bus Voltage: 4.953V, Current: 68.0mA, Power: 320.0mW
Shunt Voltage: 67.0mV, Bus Voltage: 4.957V, Current: 70.0mA, Power: 360.0mW
Shunt Voltage: 68.0mV, Bus Voltage: 4.953V, Current: 66.0mA, Power: 320.0mW
The INA219 module is currently measuring power going into a DFRobot Solar Power manager 5V's USB IN port from a USB phone charger … so the figures seem reasonable … but why do I have to do the i2cdetect first ?
The same code copied into another program (which checks a few sensors) also needs the i2cdetect, but then gives an error:
DFRobot_INA219 I2C init fail
DFRobot_INA219 I2C init fail
Traceback (most recent call last):
File "/home/pi/python/greenhouse2.py", line 182, in <module>
ina.linear_cal(ina219_reading_mA, ext_meter_reading_mA)
File "/home/pi/python/DFRobot_INA219.py", line 101, in linear_cal
self._write_register(self._INA219_REG_CALIBRATION, self.cal_value)
File "/home/pi/python/DFRobot_INA219.py", line 111, in _write_register
self.i2cbus.write_i2c_block_data(self.i2c_addr, register, [value >> 8, value & 0xff])
OSError: [Errno 5] Input/output error
