Coder Social home page Coder Social logo

rsaikali / dht22-mqtt Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 3.0 59 KB

Python script to get temperature and humidity measures from a DHT22 sensor published to a MQTT (message queue) broker.

License: Apache License 2.0

Dockerfile 31.24% Python 64.06% Shell 4.70%
raspberrypi dht22 mqtt docker

dht22-mqtt's People

Contributors

cyberdoc avatar rsaikali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dht22-mqtt's Issues

ModuleNotFoundError: No module named 'adafruit_dht'

Hi,
I´ve followed the instructions to start to use this script and send Temp. and Humidity towards my HA server...
But I´ve got this error when I try to run it. This is the log with the steps followed:

`pi@rasppi:/etc/rpimonitor $ sudo apt-get update
Des:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15,0 kB]
Obj:2 http://archive.raspberrypi.org/debian bullseye InRelease
Obj:3 http://giteduberger.fr rpimonitor/ InRelease
Des:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13,2 MB]
Descargados 13,2 MB en 40s (330 kB/s)
Update rpimonitor Packages Status
Leyendo lista de paquetes... Hecho

pi@rasppi:/etc/rpimonitor $ sudo apt-get install --no-install-recommends -y libgpiod2 gcc build-essential
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Leyendo la información de estado... Hecho
build-essential ya está en su versión más reciente (12.9).
gcc ya está en su versión más reciente (4:10.2.1-1+rpi1).
fijado gcc como instalado manualmente.
libgpiod2 ya está en su versión más reciente (1.6.2-1+rpi1).
El paquete indicado a continuación se instaló de forma automática y ya no es necesario.
libfuse2
Utilice «sudo apt autoremove» para eliminarlo.
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 1 no actualizados.
pi@rasppi:/etc/rpimonitor $ git clone https://github.com/rsaikali/dht22-mqtt.git
Clonando en 'dht22-mqtt'...
remote: Enumerating objects: 218, done.
remote: Counting objects: 100% (218/218), done.
remote: Compressing objects: 100% (136/136), done.
remote: Total 218 (delta 96), reused 131 (delta 42), pack-reused 0
Recibiendo objetos: 100% (218/218), 34.83 KiB | 178.00 KiB/s, listo.
Resolviendo deltas: 100% (96/96), listo.
pi@rasppi:/etc/rpimonitor $ cd dht22-mqtt

pi@rasppi:/etc/rpimonitor/dht22-mqtt $ sudo pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting Adafruit-Blinka==4.1.0
Downloading https://www.piwheels.org/simple/adafruit-blinka/Adafruit_Blinka-4.1.0-py3-none-any.whl (90 kB)
|████████████████████████████████| 90 kB 619 kB/s
Collecting adafruit-circuitpython-dht==3.2.6
Downloading https://www.piwheels.org/simple/adafruit-circuitpython-dht/adafruit_circuitpython_dht-3.2.6-py3-none-any.whl (7.0 kB)
Collecting Adafruit-PlatformDetect==2.4.0
Downloading https://www.piwheels.org/simple/adafruit-platformdetect/Adafruit_PlatformDetect-2.4.0-py3-none-any.whl (13 kB)
Collecting Adafruit-PureIO==1.0.4
Downloading https://www.piwheels.org/simple/adafruit-pureio/Adafruit_PureIO-1.0.4-py3-none-any.whl (7.5 kB)
Collecting paho-mqtt==1.5.0
Downloading https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.5.0-py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 574 kB/s
Collecting psutil==5.7.0
Downloading https://www.piwheels.org/simple/psutil/psutil-5.7.0-cp39-cp39-linux_armv6l.whl (265 kB)
|████████████████████████████████| 265 kB 599 kB/s
Collecting pyftdi==0.44.2
Downloading https://www.piwheels.org/simple/pyftdi/pyftdi-0.44.2-py35-none-any.whl (113 kB)
|████████████████████████████████| 113 kB 948 kB/s
Collecting pyserial==3.4
Downloading https://www.piwheels.org/simple/pyserial/pyserial-3.4-py2.py3-none-any.whl (193 kB)
|████████████████████████████████| 193 kB 897 kB/s
Collecting pyusb==1.0.2
Downloading https://www.piwheels.org/simple/pyusb/pyusb-1.0.2-py3-none-any.whl (57 kB)
|████████████████████████████████| 57 kB 506 kB/s
Requirement already satisfied: RPi.GPIO==0.7.0 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 10)) (0.7.0)
Collecting spidev==3.4
Downloading https://www.piwheels.org/simple/spidev/spidev-3.4-cp39-cp39-linux_armv6l.whl (38 kB)
Collecting sysv-ipc==1.0.1
Downloading https://www.piwheels.org/simple/sysv-ipc/sysv_ipc-1.0.1-cp39-cp39-linux_armv6l.whl (63 kB)
|████████████████████████████████| 63 kB 265 kB/s
Requirement already satisfied: rpi-ws281x>=4.0.0 in /usr/local/lib/python3.9/dist-packages (from Adafruit-Blinka==4.1.0->-r requirements.txt (line 1)) (4.3.2)
Installing collected packages: pyusb, pyserial, sysv-ipc, spidev, pyftdi, Adafruit-PureIO, Adafruit-PlatformDetect, Adafruit-Blinka, psutil, paho-mqtt, adafruit-circuitpython-dht
Attempting uninstall: pyusb
Found existing installation: pyusb 1.2.1
Uninstalling pyusb-1.2.1:
Successfully uninstalled pyusb-1.2.1
Attempting uninstall: pyserial
Found existing installation: pyserial 3.5b0
Not uninstalling pyserial at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pyserial'. No files were found to uninstall.
Attempting uninstall: sysv-ipc
Found existing installation: sysv-ipc 1.1.0
Uninstalling sysv-ipc-1.1.0:
Successfully uninstalled sysv-ipc-1.1.0
Attempting uninstall: spidev
Found existing installation: spidev 3.5
Not uninstalling spidev at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'spidev'. No files were found to uninstall.
Attempting uninstall: pyftdi
Found existing installation: pyftdi 0.53.3
Uninstalling pyftdi-0.53.3:
Successfully uninstalled pyftdi-0.53.3
Attempting uninstall: Adafruit-PureIO
Found existing installation: Adafruit-PureIO 1.1.9
Uninstalling Adafruit-PureIO-1.1.9:
Successfully uninstalled Adafruit-PureIO-1.1.9
Attempting uninstall: Adafruit-PlatformDetect
Found existing installation: Adafruit-PlatformDetect 3.19.5
Uninstalling Adafruit-PlatformDetect-3.19.5:
Successfully uninstalled Adafruit-PlatformDetect-3.19.5
Attempting uninstall: Adafruit-Blinka
Found existing installation: Adafruit-Blinka 6.20.4
Uninstalling Adafruit-Blinka-6.20.4:
Successfully uninstalled Adafruit-Blinka-6.20.4
Attempting uninstall: psutil
Found existing installation: psutil 5.8.0
Not uninstalling psutil at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'psutil'. No files were found to uninstall.
Attempting uninstall: paho-mqtt
Found existing installation: paho-mqtt 1.6.1
Uninstalling paho-mqtt-1.6.1:
Successfully uninstalled paho-mqtt-1.6.1
Attempting uninstall: adafruit-circuitpython-dht
Found existing installation: adafruit-circuitpython-dht 3.7.1
Uninstalling adafruit-circuitpython-dht-3.7.1:
Successfully uninstalled adafruit-circuitpython-dht-3.7.1
Successfully installed Adafruit-Blinka-4.1.0 Adafruit-PlatformDetect-2.4.0 Adafruit-PureIO-1.0.4 adafruit-circuitpython-dht-3.2.6 paho-mqtt-1.5.0 psutil-5.7.0 pyftdi-0.44.2 pyserial-3.4 pyusb-1.0.2 spidev-3.4 sysv-ipc-1.0.1
pi@rasppi:/etc/rpimonitor/dht22-mqtt $ ls -la
`

Once finished all the installation steps... I´ve edited the script dht22-mqtt.py and run it and get the error:

pi@rasppi:/etc/rpimonitor/dht22-mqtt $ python ./dht22-mqtt.py Traceback (most recent call last): File "/etc/rpimonitor/dht22-mqtt/./dht22-mqtt.py", line 6, in <module> import adafruit_dht ModuleNotFoundError: No module named 'adafruit_dht'

I´ve making some investigations regarding that module;

pi@rasppi:/etc/rpimonitor/dht22-mqtt $ sudo find / -name Adafruit* /etc/Adafruit_Python_DHT /etc/Adafruit_Python_DHT/dist/Adafruit_DHT-1.4.0-py3.9-linux-armv6l.egg /etc/Adafruit_Python_DHT/Adafruit_DHT.egg-info /etc/Adafruit_Python_DHT/build/lib.linux-armv6l-3.9/Adafruit_DHT /etc/Adafruit_Python_DHT/examples/AdafruitDHT.py /etc/Adafruit_Python_DHT/Adafruit_DHT /etc/mqtt-io/lib/python3.9/site-packages/Adafruit_DHT-1.4.0.egg-info /etc/mqtt-io/lib/python3.9/site-packages/Adafruit_DHT /etc/rpimonitor/Adafruit_Python_DHT-1.4.0 /etc/rpimonitor/Adafruit_Python_DHT-1.4.0/dist/Adafruit_DHT-1.4.0-py2.7-linux-armv6l.egg /etc/rpimonitor/Adafruit_Python_DHT-1.4.0/Adafruit_DHT.egg-info /etc/rpimonitor/Adafruit_Python_DHT-1.4.0/build/lib.linux-armv6l-2.7/Adafruit_DHT /etc/rpimonitor/Adafruit_Python_DHT-1.4.0/examples/AdafruitDHT.py /etc/rpimonitor/Adafruit_Python_DHT-1.4.0/Adafruit_DHT find: ‘/run/user/1000/gvfs’: Permiso denegado /root/.cache/pip/wheels/72/3e/03/21f854577a4a1e0456fa4e3112173c891e72ea5b2d19405526/Adafruit_Python_DHT-1.4.0-cp39-cp39-linux_armv6l.whl /usr/local/lib/python3.9/dist-packages/Adafruit_Blinka-4.1.0.dist-info /usr/local/lib/python3.9/dist-packages/Adafruit_Python_DHT-1.4.0.dist-info /usr/local/lib/python3.9/dist-packages/Adafruit_PureIO-1.0.4.dist-info /usr/local/lib/python3.9/dist-packages/Adafruit_PureIO /usr/local/lib/python3.9/dist-packages/Adafruit_PlatformDetect-2.4.0.dist-info /usr/local/lib/python3.9/dist-packages/Adafruit_DHT-1.4.0-py3.9-linux-armv6l.egg /usr/local/lib/python3.9/dist-packages/Adafruit_DHT-1.4.0-py3.9-linux-armv6l.egg/Adafruit_DHT /usr/local/lib/python3.9/dist-packages/Adafruit_DHT
Using this one: Adafruit_DHT for the import module I don´t see errors related to that:
import Adafruit_DHT

But I get another error that I can´t know what is talking about...

`pi@rasppi:/etc/rpimonitor/dht22-mqtt $ python ./dht22-mqtt.py
2022-02-19 14:03:58,968 [root] DEBUG ################################################################################
2022-02-19 14:03:58,972 [root] DEBUG # DHT22_PIN=4
2022-02-19 14:03:58,977 [root] DEBUG # DHT22_CHECK_EVERY=1
2022-02-19 14:03:58,981 [root] DEBUG # MQTT_SERVICE_HOST='192.168.10.15'
2022-02-19 14:03:58,990 [root] DEBUG # MQTT_SERVICE_PORT=1883
2022-02-19 14:03:58,999 [root] DEBUG # MQTT_SERVICE_USER=None
2022-02-19 14:03:59,003 [root] DEBUG # MQTT_SERVICE_PASSWORD=None
2022-02-19 14:03:59,008 [root] DEBUG # MQTT_SERVICE_TOPIC='blueroom/sensor'
2022-02-19 14:03:59,019 [root] DEBUG # MQTT_CLIENT_ID=None
2022-02-19 14:03:59,023 [root] DEBUG ################################################################################
Traceback (most recent call last):
File "/etc/rpimonitor/dht22-mqtt/./dht22-mqtt.py", line 46, in
dht22_sensor = Adafruit_DHT.DHT22(DHT22_PIN)
TypeError: 'int' object is not callable

Find attached the script in case you want to review it.

dht22-mqtt.txt
`
I´m using a Raspberry Pi (first version) with this OS version:
Linux rasppi 5.10.92+ #1514 Mon Jan 17 17:35:21 GMT 2022 armv6l GNU/Linux

Keep waiting your comments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.