From 625f74026cf2fc23866874e363da007643132d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20K=C3=B6pferl?= Date: Fri, 19 Jun 2020 16:46:10 +0200 Subject: [PATCH] umbenannt --- install/install.sh | 3 ++- src/temp+feucht-DHT22.py | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/temp+feucht-DHT22.py diff --git a/install/install.sh b/install/install.sh index 41b7683..3e806f9 100644 --- a/install/install.sh +++ b/install/install.sh @@ -20,10 +20,11 @@ sudo apt-get upgrade # wir brauchen python3 sudo apt install python3 # wir brauchen pip3 -#nö: sudo apt-get install python3-pip +sudo apt-get install python3-pip #Nö: sudo pip3 install --upgrade setuptools # Run the following command to install the Raspberry PI GPIO library: #Nö pip3 install RPI.GPIO #pip3 install adafruit-blinka +sudo pip3 install Adafruit_DHT diff --git a/src/temp+feucht-DHT22.py b/src/temp+feucht-DHT22.py new file mode 100644 index 0000000..8162846 --- /dev/null +++ b/src/temp+feucht-DHT22.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# Author: Robert Köpferl +# Skript, um Sensoren des Typs AD2302 auszulesen und die umgerechneten +# Temperatur und Feuchte-Werte zu pushen + +import sys + +import Adafruit_DHT + + +# Einfach alle Sensoren der Reihe nach auslesen + +sensor = [ +{'Name': 'Bienen0_o', 'Pin': 24, 'Ziel': 'B0-o'}, +{'Name': 'Bienen0_u', 'Pin': 26, 'Ziel': 'B0-u'}, +{'Name': 'Bienen1_o', 'Pin': 32, 'Ziel': 'B1-o'}, +{'Name': 'Bienen1_u', 'Pin': 36, 'Ziel': 'B1-u'}, +{'Name': 'Bienen2_o', 'Pin': 38, 'Ziel': 'B2-o'}, +{'Name': 'Bienen2_u', 'Pin': 40, 'Ziel': 'B2-u'}, +] + +* GPIO8 (24) (Bienen0) - Sensor A +* GPIO7 (26) (Bienen0) - Sensor B +* GPIO12 (32) (Bienen1) - Sensor A +* GPIO16 (36) (Bienen1) - Sensor B +* GPIO20 (38) (Bienen2) - Sensor A +* GPIO21 (40) (Bienen2) - Sensor B + +# Try to grab a sensor reading. Use the read_retry method which will retry up +# to 15 times to get a sensor reading (waiting 2 seconds between each retry). +humidity, temperature = Adafruit_DHT.read(sensor, pin) + + + +# Note that sometimes you won't get a reading and +# the results will be null (because Linux can't +# guarantee the timing of calls to read the sensor). +# If this happens try again! +if humidity is not None and temperature is not None: + print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity)) +else: + print('Failed to get reading. Try again!') + sys.exit(1)