Upload hybridizedwtla_195.py
Browse files- hybridizedwtla_195.py +72 -0
hybridizedwtla_195.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""hybridizedWtla.195
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1lOpPihOMUo0SqAGMae7YfxZamFwDQDZM
|
8 |
+
"""
|
9 |
+
|
10 |
+
import RPi.GPIO as GPIO
|
11 |
+
import ADC0834
|
12 |
+
import LCD1602
|
13 |
+
import dht11
|
14 |
+
import time
|
15 |
+
GPIO.setmode(GPIO.BCM)
|
16 |
+
|
17 |
+
buzzPin=22
|
18 |
+
tempPin=26
|
19 |
+
buttonPin=24
|
20 |
+
|
21 |
+
myDHT=dht11.DHT11(pin=tempPin)
|
22 |
+
GPIO.setup(buzzPin,GPIO.OUT)
|
23 |
+
GPIO.output(buzzPin,GPIO.HIGH)
|
24 |
+
ADV0834.setup()
|
25 |
+
LCD1602.init(0x27,1)
|
26 |
+
|
27 |
+
GPIO.setup(buttonPin,GPIO.IN.pull_up_down=GPIO.PUD_UP)
|
28 |
+
buttonState=1
|
29 |
+
buttonStateOld=1
|
30 |
+
setMode=True
|
31 |
+
buzzVal=85
|
32 |
+
|
33 |
+
try:
|
34 |
+
while True:
|
35 |
+
buttonState=GPIO.input(buttonPin)
|
36 |
+
if buttonState==1 and buttonState
|
37 |
+
setMode = not setMode
|
38 |
+
print(buttonState)
|
39 |
+
buttonStateOld=buttonState
|
40 |
+
time.sleep(.2)
|
41 |
+
if setMode==True:
|
42 |
+
analogVal=ADC0834.getResult()
|
43 |
+
buzzVal=int(analogVal(100/255))
|
44 |
+
LCD.write(0,0, 'Set Trip Temp:')
|
45 |
+
LCD.write(0,1,str(buzzVal)
|
46 |
+
time.sleep(.25)
|
47 |
+
LCD.clear()
|
48 |
+
GPIO.output(buzzPin,GPIO.HIGH)
|
49 |
+
if setMode==False:
|
50 |
+
result=myDHT.getResult(0)
|
51 |
+
if result.is_valid():
|
52 |
+
tempC=result.temperature
|
53 |
+
tempF=tempC*1.8+32
|
54 |
+
tempF=round(tempF,1)
|
55 |
+
print(buzzVal)
|
56 |
+
if tempF<buzzVal:
|
57 |
+
GPIO.output(buzzPin,GPIO.HIGH)
|
58 |
+
LCD1602.write(0,0, 'Temp: ')
|
59 |
+
LCD1602.write(6,0,str(tempF))
|
60 |
+
LCD1602.write(0,1,'Humidity: ')
|
61 |
+
LCD1602.write(10,1,str(hum))
|
62 |
+
LCD1602.write(14,1,'\')
|
63 |
+
if tempF>=buzzVal:
|
64 |
+
GPIO.output(buzzPin,GPIO.LOW)
|
65 |
+
LCD1602.write(0,0,'Temp: ')
|
66 |
+
LCD1602.write(6,0,str(tempF))
|
67 |
+
LCD1602.write(11,0,' F')
|
68 |
+
LCD1602.write(0,1,'ALERT: Temp Reaching High Temp')
|
69 |
+
time.sleep(.1)
|
70 |
+
except KeyboardInterrupt:
|
71 |
+
time.sleep(.2)
|
72 |
+
GPIO.clenup()
|