Hello, can someone program me a plugin?
I built a heated printer housing. The temperature is measured via a DHT22 sensor, if it is too low it is heated for 30 seconds with a cooling-down period of 120 seconds, otherwise my holder will become soft. At the moment I am doing this with a Python script, here the source code:
import Adafruit_DHT
import time
import RPi.GPIO as GPIO
import sys
sensor = Adafruit_DHT.DHT22
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
ein=30
aus=120
aktiv=" "
last=0
tmp=int(sys.argv[1])
pin = 5
try:
while True:
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
# print(humidity, temperature)
try:
float(temperature)
except TypeError:
# print("JA")
humidity=100
temperature=100
if (aktiv==" "):
if (last<time.time()-aus):
if (temperature<tmp-2):
GPIO.output(40, GPIO.HIGH)
aktiv="EIN"
last=time.time()
else:
if (temperature>tmp-2):
GPIO.output(40, GPIO.LOW)
aktiv=" "
last=time.time()
if (last<time.time()-ein):
GPIO.output(40, GPIO.LOW)
aktiv=" "
last=time.time()
print(aktiv, tmp, round(temperature,1), round(humidity,1))
time.sleep(5)
except KeyboardInterrupt:
GPIO.output(40, GPIO.LOW)