From 5278985170df209681f4415a0a44823dfe692f81 Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Tue, 6 Jan 2026 11:22:11 +0100 Subject: [PATCH] =?UTF-8?q?erster=20lauff=C3=A4higer=20Versuch.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .python-version | 1 + main.py | 21 +++++++++++++++++++++ pyproject.toml | 10 ++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .python-version create mode 100644 main.py create mode 100644 pyproject.toml diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/main.py b/main.py new file mode 100644 index 0000000..07d3531 --- /dev/null +++ b/main.py @@ -0,0 +1,21 @@ +import adafruit_dht +import time +import board +def main(): + dht_device = adafruit_dht.DHT22(board.D4) + + while True: + try: + temperature_c = dht_device.temperature + temperature_f = temperature_c * (9 / 5) + 32 + humidity = dht_device.humidity + + print("Temp:{:.1f} C / {:.1f} F Humidity: {}%".format(temperature_c, temperature_f, humidity)) + except RuntimeError as err: + print(err.args[0]) + + time.sleep(2.0) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..91254f5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[project] +name = "dht22" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "adafruit-circuitpython-dht>=4.0.10", + "lgpio>=0.2.2.0", +]