butterbot
Goto Top

OrangePi Zero LTS - DHT22 - Python

Moin Moin,

vielleicht ist die Frage hier falsch, aber da das Forum so extrem gut ist, dachte ich mir, ich frage mal.

Und zwar bin ich gerade dabei einige Sensoren mit einem OrangePi Zero LTS zu verbinden.
Einfache Sachen wie ein magnetischen Tür-schließ-Kontakt kriege ich zum laufen, ist ja nur if pin high..... und mehr nicht.

Nun habe ich aber auch ein paar Temperatur / Feuchtigkeits Sensoren, um genau zu sein DHT22 Module.
Diese funktionieren unter Raspberry Pi meistens ohne Probleme (wenn dann eher Hardware bedingt, Alterung usw.) aber bei dem Orange Pi kriege ich diese nicht zum laufen, da pip3 die benötigte Lib nicht installieren kann.

root@orangepizero:~# pip3 install Adafruit_DHT
Collecting Adafruit_DHT
  Using cached Adafruit_DHT-1.4.0.tar.gz (15 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: Adafruit_DHT
  Building wheel for Adafruit_DHT (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      Could not detect if running on the Raspberry Pi or Beaglebone Black.  If this failure is unexpected, you can run again with --force-pi or --force-bbb parameter to force using the Raspberry Pi or Beaglebone Black respectively.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for Adafruit_DHT
  Running setup.py clean for Adafruit_DHT
Failed to build Adafruit_DHT
ERROR: Could not build wheels for Adafruit_DHT, which is required to install pyproject.toml-based projects
root@orangepizero:~# 

Er sagt halt, dass das ganze für Raspberry Pi's oder Beaglebone Black's gemacht wurde und sonst die option "--force-pi" etc. genutzt werden soll.
Die Option "--force-pi" kennt der OrangePi aber nicht, wahrscheinlich weil es kein Pi ist.

Ich hatte auch schon probiert das ganze mit dem Projekt von GitHub zu installieren, lief aber auch nicht.

root@orangepizero:~# cd Adafruit_Python_DHT/
root@orangepizero:~/Adafruit_Python_DHT# python3 setup.py install
Could not detect if running on the Raspberry Pi or Beaglebone Black.  If this failure is unexpected, you can run again with --force-pi or --force-bbb parameter to force using the Raspberry Pi or Beaglebone Black respectively.
root@orangepizero:~/Adafruit_Python_DHT# python3 setup.py install --force-pi
running install
/usr/local/lib/python3.9/dist-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer, pypa/build or
        other standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
/usr/local/lib/python3.9/dist-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer, pypa/build or
        other standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
running bdist_egg
running egg_info
writing Adafruit_DHT.egg-info/PKG-INFO
writing dependency_links to Adafruit_DHT.egg-info/dependency_links.txt
writing top-level names to Adafruit_DHT.egg-info/top_level.txt
reading manifest file 'Adafruit_DHT.egg-info/SOURCES.txt'  
reading manifest template 'MANIFEST.in'  
adding license file 'LICENSE'  
writing manifest file 'Adafruit_DHT.egg-info/SOURCES.txt'  
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
running build_ext
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/platform_detect.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/Raspberry_Pi_2.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/Beaglebone_Black.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/common.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/__init__.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/Raspberry_Pi_Driver.cpython-39-arm-linux-gnueabihf.so -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/Raspberry_Pi.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-cpython-39/Adafruit_DHT/Test.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/platform_detect.py to platform_detect.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Raspberry_Pi_2.py to Raspberry_Pi_2.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Beaglebone_Black.py to Beaglebone_Black.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/common.py to common.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/__init__.py to __init__.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Raspberry_Pi.py to Raspberry_Pi.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Test.py to Test.cpython-39.pyc
creating stub loader for Adafruit_DHT/Raspberry_Pi_Driver.cpython-39-arm-linux-gnueabihf.so
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Raspberry_Pi_Driver.py to Raspberry_Pi_Driver.cpython-39.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
writing build/bdist.linux-armv7l/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
Adafruit_DHT.__pycache__.Raspberry_Pi_Driver.cpython-39: module references __file__
creating 'dist/Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg' and adding 'build/bdist.linux-armv7l/egg' to it  
removing 'build/bdist.linux-armv7l/egg' (and everything under it)  
Processing Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg
removing '/usr/lib/python3.9/site-packages/Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg' (and everything under it)  
creating /usr/lib/python3.9/site-packages/Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg
Extracting Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg to /usr/lib/python3.9/site-packages
Adafruit-DHT 1.4.0 is already the active version in easy-install.pth

Installed /usr/lib/python3.9/site-packages/Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg
Processing dependencies for Adafruit-DHT==1.4.0
Finished processing dependencies for Adafruit-DHT==1.4.0

Da kennt er dann aber die Option "--force-pi", hilft mir da aber auch nicht weiter, da er immer noch nicht die Lib kennt.

root@orangepizero:~/Adafruit_Python_DHT/examples# python3 AdafruitDHT.py 
Traceback (most recent call last):
  File "/root/Adafruit_Python_DHT/examples/AdafruitDHT.py", line 24, in <module>  
    import Adafruit_DHT
ModuleNotFoundError: No module named 'Adafruit_DHT'  

Kennt sich jemand damit aus und kann mir helfen?

Liebe Grüße

Content-ID: 6939439615

Url: https://administrator.de/contentid/6939439615

Ausgedruckt am: 24.11.2024 um 10:11 Uhr

marinux
marinux 28.04.2023 um 01:29:02 Uhr
Goto Top
Probiere mal die CircuitPython Library

pip3 install adafruit-circuitpython-dht


https://github.com/adafruit/Adafruit_Python_DHT ist deprecated!
ButterBot
ButterBot 28.04.2023 aktualisiert um 08:27:59 Uhr
Goto Top
Zitat von @marinux:

Probiere mal die CircuitPython Library

pip3 install adafruit-circuitpython-dht


https://github.com/adafruit/Adafruit_Python_DHT ist deprecated!

Danke für die Idee, aber leider funktioniert das auch nicht.


root@orangepizero:~/Test# python3 dht22.py 
ImportError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/Test/dht22.py", line 2, in <module>  
    import adafruit_dht
  File "/root/Test/project-name/.venv/lib/python3.9/site-packages/adafruit_dht.py", line 32, in <module>  
    from digitalio import DigitalInOut, Pull, Direction
  File "/root/Test/project-name/.venv/lib/python3.9/site-packages/digitalio.py", line 29, in <module>  
    from adafruit_blinka.microcontroller.allwinner.h3.pin import Pin
  File "/root/Test/project-name/.venv/lib/python3.9/site-packages/adafruit_blinka/microcontroller/allwinner/h3/pin.py", line 5, in <module>  
    from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
  File "/root/Test/project-name/.venv/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py", line 8, in <module>  
    raise ImportError(
ImportError: libgpiod Python bindings not found, please install and try again! See https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/libgpiod.sh

Ich werde den OrangePi nachher mal neu aufsetzen, vielleicht hilft das
marinux
marinux 28.04.2023 um 09:50:40 Uhr
Goto Top
Du scheinst nicht die notwendigen Libraries installiert zu haben.

pip3 install gpiod

Hast du mal https://learn.adafruit.com/circuitpython-on-orangepi-linux/overview gelesen?
ButterBot
ButterBot 30.04.2023 um 13:31:12 Uhr
Goto Top
Zitat von @marinux:

Du scheinst nicht die notwendigen Libraries installiert zu haben.

pip3 install gpiod

Hast du mal https://learn.adafruit.com/circuitpython-on-orangepi-linux/overview gelesen?

Danke für den Hinweis, normalerweise arbeite ich auf den Orange Pi's mit OPi.GPIO.

Ich habe gpiod mal installiert und die installation klappte auch ohne Probleme, nur kommt aber folgender Fehler raus:

root@orangepizero:~/Test# python3 dht22.py 
Traceback (most recent call last):
  File "/root/Test/dht22.py", line 16, in <module>  
    temperature = dht_device.temperature
  File "/usr/local/lib/python3.9/dist-packages/adafruit_dht.py", line 274, in temperature  
    self.measure()
  File "/usr/local/lib/python3.9/dist-packages/adafruit_dht.py", line 221, in measure  
    pulses = self._get_pulses_bitbang()
  File "/usr/local/lib/python3.9/dist-packages/adafruit_dht.py", line 163, in _get_pulses_bitbang  
    with DigitalInOut(self._pin) as dhtpin:
  File "/usr/local/lib/python3.9/dist-packages/digitalio.py", line 164, in __init__  
    self._pin = Pin(pin.id)
AttributeError: 'int' object has no attribute 'id'  

import adafruit_dht
import time
import paho.mqtt.client as paho
import OPi.GPIO as GPIO


GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

dht = 12

GPIO.setup (dht, GPIO.IN)

dht_device = adafruit_dht.DHT22(dht)

temperature = dht_device.temperature
humidity = dht_device.humidity