diff --git a/test/Adafruit_Python_DHT b/test/Adafruit_Python_DHT new file mode 160000 index 0000000..da8cddf --- /dev/null +++ b/test/Adafruit_Python_DHT @@ -0,0 +1 @@ +Subproject commit da8cddf7fb629c1ef4f046ca44f42523c9cf2d11 diff --git a/test/dht11/Adafruit_Python_DHT b/test/dht11/Adafruit_Python_DHT new file mode 160000 index 0000000..da8cddf --- /dev/null +++ b/test/dht11/Adafruit_Python_DHT @@ -0,0 +1 @@ +Subproject commit da8cddf7fb629c1ef4f046ca44f42523c9cf2d11 diff --git a/test/dht11/test1.py b/test/dht11/test1.py new file mode 100644 index 0000000..3d4b4c2 --- /dev/null +++ b/test/dht11/test1.py @@ -0,0 +1,87 @@ +import RPi.GPIO as GPIO +import time + +def bin2dec(string_num): + return str(int(string_num, 2)) + +data = [] + +GPIO.setmode(GPIO.BCM) + +GPIO.setup(26,GPIO.OUT) +GPIO.output(26,GPIO.HIGH) +time.sleep(0.025) +GPIO.output(26,GPIO.LOW) +time.sleep(0.02) + +GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +for i in range(0,500): + data.append(GPIO.input(26)) + +bit_count = 0 +tmp = 0 +count = 0 +HumidityBit = "" +TemperatureBit = "" +crc = "" + +try: + while data[count] == 1: + tmp = 1 + count = count + 1 + + for i in range(0, 32): + bit_count = 0 + + while data[count] == 0: + tmp = 1 + count = count + 1 + + while data[count] == 1: + bit_count = bit_count + 1 + count = count + 1 + + if bit_count > 3: + if i>=0 and i<8: + HumidityBit = HumidityBit + "1" + if i>=16 and i<24: + TemperatureBit = TemperatureBit + "1" + else: + if i>=0 and i<8: + HumidityBit = HumidityBit + "0" + if i>=16 and i<24: + TemperatureBit = TemperatureBit + "0" + +except: + print "ERR_RANGE" + exit(0) + +try: + for i in range(0, 8): + bit_count = 0 + + while data[count] == 0: + tmp = 1 + count = count + 1 + + while data[count] == 1: + bit_count = bit_count + 1 + count = count + 1 + + if bit_count > 3: + crc = crc + "1" + else: + crc = crc + "0" +except: + print "ERR_RANGE" + exit(0) + +Humidity = bin2dec(HumidityBit) +Temperature = bin2dec(TemperatureBit) + +if int(Humidity) + int(Temperature) - int(bin2dec(crc)) == 0: + print "Humidity:"+ Humidity +"%" + print "Temperature:"+ Temperature +"C" +else: + print "ERR_CRC" diff --git a/test/gpio_test.py b/test/gpio_test.py new file mode 100644 index 0000000..4850519 --- /dev/null +++ b/test/gpio_test.py @@ -0,0 +1,9 @@ +import RPi.GPIO as GPIO +GPIO.setmode(GPIO.BCM); +pin=0; +while pin<=40: + GPIO.setup(pin, GPIO.IN); + print("Pin {0}; Value {1};".format(pin,GPIO.input(pin))); + pin += 1; +GPIO.cleanup(); + diff --git a/test/pir.py b/test/pir.py new file mode 100644 index 0000000..9a0dae0 --- /dev/null +++ b/test/pir.py @@ -0,0 +1,20 @@ +import RPi.GPIO as GPIO +import time + +SENSOR_PIN = 22 + +GPIO.setmode(GPIO.BCM) +GPIO.setup(SENSOR_PIN, GPIO.IN) + +def mein_callback(channel): + # Hier kann alternativ eine Anwendung/Befehl etc. gestartet werden. + print('Es gab eine Bewegung!') + +try: + GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING, +callback=mein_callback) + while True: + time.sleep(100) +except KeyboardInterrupt: + print("Beende...") +GPIO.cleanup()