Currently I can read the temperature reading from a file for both sensor. import os import time
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
temp_sensor = '/sys/bus/w1/devices/28-0316004f1fff/w1_slave'
def temp_raw():
f = open(temp_sensor,'r')
lines = f.readlines()
f.close()
return lines
def read_temp():
lines = temp_raw()
while lines[0].strip()[-3:] != 'YES':
time.sleep(0.2)
lines = temp_raw()
temp_output = lines[1].find('t=')
if temp_output != -1:
temp_string = lines[1][temp_output+2:]
temp_c = float(temp_string)/1000.0
return temp_c
while True:
print(read_temp())
time.sleep(1)
Now I am trying to read two sensors at once but have no idea how to do it.
/sys/bus/w1/devices/28-0316004f1fff/w1_slave
and you will see how to do it.