Published: 27.08.2018
Copyright by Joy-IT
7
Temperature Sensor
def
TemperaturAuswertung
():
lines = TemperaturMessung()
while
lines[
0
].strip()[
-
3
:] != 'YES':
time.sleep(
0.2
)
lines = TemperaturMessung()
equals_pos = lines[
1
].find('t=')
if
equals_pos !=
-
1
:
temp_string = lines[
1
][equ
2
:]
temp_c =
float
(temp_string) /
1000.0
return
temp_c
# main loop
# The measured temperature is sent to the console between the individual measurements
# is a pause whose length can be set with the variable "sleeptime
try
:
while
True
:
'
---------------------------------------
'
"Temperatur:", TemperaturAuswertung(), "°C"
time.sleep(sleeptime)
except
KeyboardInterrupt
:
GPIO.cleanup()