forked from alanbjohnston/CubeSatSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readallcurrents.py
65 lines (52 loc) · 1.75 KB
/
readallcurrents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from time import sleep
from ina219 import INA219
ina1 = INA219(shunt_ohms=0.1,
max_expected_amps = 0.6,
address=0x40)
ina1.configure(voltage_range=ina1.RANGE_16V,
gain=ina1.GAIN_AUTO,
bus_adc=ina1.ADC_128SAMP,
shunt_adc=ina1.ADC_128SAMP)
ina2 = INA219(shunt_ohms=0.1,
max_expected_amps = 0.6,
address=0x41)
ina2.configure(voltage_range=ina2.RANGE_16V,
gain=ina2.GAIN_AUTO,
bus_adc=ina2.ADC_128SAMP,
shunt_adc=ina2.ADC_128SAMP)
ina3 = INA219(shunt_ohms=0.1,
max_expected_amps = 0.6,
address=0x44)
ina3.configure(voltage_range=ina3.RANGE_16V,
gain=ina3.GAIN_AUTO,
bus_adc=ina3.ADC_128SAMP,
shunt_adc=ina3.ADC_128SAMP)
ina4 = INA219(shunt_ohms=0.1,
max_expected_amps = 0.6,
address=0x45)
ina4.configure(voltage_range=ina4.RANGE_16V,
gain=ina4.GAIN_AUTO,
bus_adc=ina4.ADC_128SAMP,
shunt_adc=ina4.ADC_128SAMP)
while 1:
v1 = ina1.voltage()
i1 = ina1.current()
p1 = ina1.power()
print('1 {0:0.1f}V {1:0.1f}mA'.format(v1, i1))
print('{0:0.1f} Watts\n\n'.format(p1/1000))
v2 = ina2.voltage()
i2 = ina2.current()
p2 = ina2.power()
print('2 {0:0.1f}V {1:0.1f}mA'.format(v2, i2))
print('{0:0.1f} Watts\n\n'.format(p2/1000))
v3 = ina3.voltage()
i3 = ina3.current()
p3 = ina3.power()
print('3 {0:0.1f}V {1:0.1f}mA'.format(v3, i3))
print('{0:0.1f} Watts\n\n'.format(p3/1000))
v4 = ina4.voltage()
i4 = ina4.current()
p4 = ina4.power()
print('4 {0:0.1f}V {1:0.1f}mA'.format(v4, i4))
print('{0:0.1f} Watts\n\n\n'.format(p4/1000))
sleep(1)