ich habe bereits einen Code der mir im Terminal die Temperatur und die Luftfeuchtigkeit ausgibt DHT11.py:
Code: Alles auswählen
import time
import board
import adafruit_dht
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT11(board.D17)
# you can pass DHT22 use_pulseio=False if you wouldn't like to use pulseio.
# This may be necessary on a Linux single board computer like the Raspberry Pi,
# but it will not work in CircuitPython.
# dhtDevice = adafruit_dht.DHT22(board.D18, use_pulseio=False)
while True:
try:
# Print the values to the serial port
temperature = dhtDevice.temperature
humidity = dhtDevice.humidity
print(
"Temperatur: {:.1f} C Lufteuchtigkeit: {}% ".format(
temperature, humidity
)
)
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
dhtDevice.exit()
raise error
time.sleep(2.0)
Ausgabe sieht wie folgt aus: Jetzt möchte ich diese beiden Werte auch in OpenHAB2 in der Basis UI anzeigen lassen.
Ich weiß, dass ich aus den Ausgaben Items und Things erzeugen muss. Aber ich weiß nicht wie....
Die Sitempap kriege ich hin. Aber den Rest leider nicht.
Kann mir da jemand behilflich sein?
Vielen Dank vorab,
Viele Grüße,
Lukas