|
|
|
"""hybridizedWtla.195 |
|
|
|
Automatically generated by Colab. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/1lOpPihOMUo0SqAGMae7YfxZamFwDQDZM |
|
""" |
|
|
|
import RPi.GPIO as GPIO |
|
import ADC0834 |
|
import LCD1602 |
|
import dht11 |
|
import time |
|
GPIO.setmode(GPIO.BCM) |
|
|
|
buzzPin=22 |
|
tempPin=26 |
|
buttonPin=24 |
|
|
|
myDHT=dht11.DHT11(pin=tempPin) |
|
GPIO.setup(buzzPin,GPIO.OUT) |
|
GPIO.output(buzzPin,GPIO.HIGH) |
|
ADV0834.setup() |
|
LCD1602.init(0x27,1) |
|
|
|
GPIO.setup(buttonPin,GPIO.IN.pull_up_down=GPIO.PUD_UP) |
|
buttonState=1 |
|
buttonStateOld=1 |
|
setMode=True |
|
buzzVal=85 |
|
|
|
try: |
|
while True: |
|
buttonState=GPIO.input(buttonPin) |
|
if buttonState==1 and buttonState |
|
setMode = not setMode |
|
print(buttonState) |
|
buttonStateOld=buttonState |
|
time.sleep(.2) |
|
if setMode==True: |
|
analogVal=ADC0834.getResult() |
|
buzzVal=int(analogVal(100/255)) |
|
LCD.write(0,0, 'Set Trip Temp:') |
|
LCD.write(0,1,str(buzzVal) |
|
time.sleep(.25) |
|
LCD.clear() |
|
GPIO.output(buzzPin,GPIO.HIGH) |
|
if setMode==False: |
|
result=myDHT.getResult(0) |
|
if result.is_valid(): |
|
tempC=result.temperature |
|
tempF=tempC*1.8+32 |
|
tempF=round(tempF,1) |
|
print(buzzVal) |
|
if tempF<buzzVal: |
|
GPIO.output(buzzPin,GPIO.HIGH) |
|
LCD1602.write(0,0, 'Temp: ') |
|
LCD1602.write(6,0,str(tempF)) |
|
LCD1602.write(0,1,'Humidity: ') |
|
LCD1602.write(10,1,str(hum)) |
|
LCD1602.write(14,1,'\') |
|
if tempF>=buzzVal: |
|
GPIO.output(buzzPin,GPIO.LOW) |
|
LCD1602.write(0,0,'Temp: ') |
|
LCD1602.write(6,0,str(tempF)) |
|
LCD1602.write(11,0,' F') |
|
LCD1602.write(0,1,'ALERT: Temp Reaching High Temp') |
|
time.sleep(.1) |
|
except KeyboardInterrupt: |
|
time.sleep(.2) |
|
GPIO.clenup() |