21a727b00112ff634819551f37d30c94c2e80054
6 from time
import strftime
8 os
.system('modprobe w1-gpio')
9 os
.system('modprobe w1-therm')
11 base_dir
= '/sys/bus/w1/devices/'
12 device_folder
= glob
.glob(base_dir
+ '28*')[0]
13 device_file
= device_folder
+ '/w1_slave'
16 f
= open(device_file
, 'r')
22 lines
= read_temp_raw()
23 while lines
[0].strip()[-3:] != 'YES':
25 lines
= read_temp_raw()
26 equals_pos
= lines
[1].find('t=')
28 temp_string
= lines
[1][equals_pos
+2:]
29 temp_c
= float(temp_string
) / 1000.0
30 temp_f
= temp_c
* 9.0 / 5.0 + 32.0
31 temp_c_2dec
= f
"{temp_c:.5f}" # https://stackoverflow.com/a/15263885/10850071
32 #return temp_c, temp_f
36 nowTimeIso8601
= strftime("%Y%m%dT%H%M%S%z")
37 nowTimeUE
= strftime("%s")
39 print(str(nowTimeIso8601
) + ',' + str(nowTimeUE
) + ',' + str(nowTemp
))