#Beispielscript von adafruit (bearbeitet: nicht benötigte Zeilen entfernt und Schreiben in externe .txt Datei hinzugefügt) import time #Zeit import board #CircuitPython, welches Board genutzt wird (Adafruit) import adafruit_dht #DHT-Bibliothek (Adafruit) #Data-Pin für DHT, pulseio==False, da nicht CircuitPython kompatibel dhtDevice = adafruit_dht.DHT22(board.D4, use_pulseio=False) try: while True: try: temperature_c = dhtDevice.temperature #Temperatur in Variable speichern with open("/home/*/*/*/tempc.txt", "w") as f: f.write("{:.1f}".format(temperature_c)) #.txt schreibend öffnen, formatierten Wert schreiben und .txt schließen time.sleep(0.5) except RuntimeError as error: #da häufig Error, einfach ignorieren pass except Exception as error: pass except KeyboardInterrupt: dhtDevice.exit()