-
Notifications
You must be signed in to change notification settings - Fork 0
/
case5.py
59 lines (42 loc) · 1.33 KB
/
case5.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
import os
import threading
import adafruit_dht
from board import *
from time import sleep
SENSOR_PIN_IN = D17
SENSOR_PIN_OUT = D27
dht22_in = adafruit_dht.DHT22(SENSOR_PIN_IN, use_pulseio=False)
dht22_out = adafruit_dht.DHT22(SENSOR_PIN_OUT, use_pulseio=False)
def mp3():
os.system("mpg321 healing.mp3")
def getValue():
os.system("python3 main.py")
def temper():
temp = True
while True:
try:
temperature_inside = dht22_in.temperature
temperature_outside = dht22_out.temperature
print(f"Outside Temperature= {temperature_outside:.1f}°C")
print(f"Inside Temperature= {temperature_inside:.1f}°C")
sleep(1)
if float(temperature_inside) > float(temperature_outside):
if temp:
os.system("python3 door_open.py")
temp = False
else:
temp = True
except (RuntimeError, TypeError, NameError):
pass
def mp3_thread():
thread=threading.Thread(target=mp3)
thread.daemon=True
thread.start()
def getValue_thread():
thread=threading.Thread(target=getValue)
thread.daemon=True
thread.start()
if __name__ == "__main__":
mp3_thread()
getValue_thread()
temper()