Skip to content

Commit

Permalink
python demo done
Browse files Browse the repository at this point in the history
  • Loading branch information
jveverka committed Apr 2, 2022
1 parent 5d715b3 commit 9081599
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions rpi-voltage-current/ads1115.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
# Create differential input between channel 0 and 1
#chan = AnalogIn(ads, ADS.P0, ADS.P1)

print("{:>5}\t{:>5}".format('raw', 'v'))
print("{:>5}\t{:>5}".format('raw', 'voltage'))

while True:
print("CH0: {:>5}\t{:>5.3f}".format(chan0.value, chan0.voltage))
print("CH1: {:>5}\t{:>5.3f}".format(chan1.value, chan1.voltage))
print("CH0: {:>5}\t{:>5.3f} V".format(chan0.value, chan0.voltage))
print("CH1: {:>5}\t{:>5.3f} V".format(chan1.value, chan1.voltage))
time.sleep(0.5)
6 changes: 4 additions & 2 deletions rpi-voltage-current/pcf8591t.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

bus = smbus.SMBus(1)

print("{:>5}\t{:>5}".format('raw', 'voltage'))

while True:
bus.write_byte(address,A0)
value0 = bus.read_byte(address)
Expand All @@ -18,7 +20,7 @@
value1 = bus.read_byte(address)
voltage1 = ( 3.3 / 255 ) * value1

print("raw: " + str(value0) + " voltage: " + str(round(voltage0,3)) + " V")
print("raw: " + str(value1) + " voltage: " + str(round(voltage1,3)) + " V")
print("CH0: {:>5}\t{:>5.3f} V".format(value0, voltage0))
print("CH1: {:>5}\t{:>5.3f} V".format(value1, voltage1))

time.sleep(0.5)

0 comments on commit 9081599

Please sign in to comment.