Instructions
KY-015 Combi-Sensor Temperature+Humidity
try:
while(1):
# Measurement will be started and the result will be written into the variables
humid, temper = Adafruit_DHT.read_retry(DHTSensor, GPIO_Pin)
print("-----------------------------------------------------------------")
if humid is not None and temper is not None:
# The result will be shown at the console
print('temperature = {0:0.1f}°C | rel. humidity = {1:0.1f}%'.format(temper, humid))
# Because of the OS, the Raspberry Pi has problems with realtime measurements.
# It is possible that, because of timing problems, the communication fails.
# a message will be displayed - the result will be shown at next try.
else:
print('Error while reading - please wait for the next try!')
print("-----------------------------------------------------------------")
print("")
time.sleep(sleeptime)
# Scavenging work after the end of the program
except KeyboardInterrupt:
GPIO.cleanup()
Please notice, the sensor will only get a new measurement value after 2 seconds. Because of
that it is better to use it for long period measurements.
Connections Raspberry Pi:
GND = GND [Pin 06]
+V = 3,3V [Pin 01]
Signal = GPIO23 [Pin 16]
Example download
KY-015-RPi_Kombi-Sensor_Temperatur_Feuchtigkeit
To start with the command:
sudo python KY-015-RPi_Kombi-Sensor_Temperatur_Feuchtigkeit.py
Export: 16.06.2017 Copyright by Joy-IT - Published under CC BY-NC-SA 3.0 Page 64 of 214










