MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-DHT22

    Scheduled Pinned Locked Moved Utilities
    27 Posts 9 Posters 9.1k Views 9 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BKeyportB Offline
      BKeyport Module Developer @JohnGalt
      last edited by

      @JohnGalt I had no trouble with the Adafruit libraries on Pi4. It should be working just fine - Take a look around https://forums.adafruit.com/ - there might be fixes or something available.

      The "E" in "Javascript" stands for "Easy"

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        JohnGalt @BKeyport
        last edited by

        @BKeyport thanks for the response. It looks like my issue is actually with the Linux 12 / bookworm version of Raspbian I installed when rebuilding my MagicMirror, as opposed to the R-Pi 4 hardware.

        In reading the Adafruit forums here: https://forums.adafruit.com/viewtopic.php?p=938344&hilit=Adafruit_Python_DHT#p938344 I find the official Adafruit response to someone with the same issues is that “DHT22 really sucks to use on linux” and … “you will be a lot happier just using the DHT20 and friends”, with a reference to an Adafruit web article at https://learn.adafruit.com/modern-replacements-for-dht11-dht22-sensors/overview.

        In short, the advice is to just buy all new sensors for your Raspberry Pi installs. The OP pointed out that while he acknowledges the newer sensors may indeed be better, that " I spent a good amount of money buying and building, and for all of that to go away with an update really stinks! :( ".

        I agree with him since I have probably five (5) DHT 11/22 sensors working on R-Pis, and while it looks like he found a way to upgrade all pip libraries and get it working again, it also appears to only be a matter of time until another update or upgrade of something breaks the system.

        Again thanks for pointing me in the right direction.

        BKeyportB 1 Reply Last reply Reply Quote 0
        • BKeyportB Offline
          BKeyport Module Developer @JohnGalt
          last edited by

          @JohnGalt I’m betting LadyAda and co are working on a fix all the same. They’re big on keeping old hardware working.

          The "E" in "Javascript" stands for "Easy"

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            JohnGalt @BKeyport
            last edited by

            @BKeyport - That has been my general impression of Adafruit, and for the sake of general continuity, I do hope that is the case. All that said, the situation with the sensor libraries has been a mess for years - with my personal favorite gripe being libraries being deprecated without clear messaging on the website hosting the old, together with new libraries with very similar names but different functionality. For the life of me I cannot understand why simply incrementing the version numbering wouldn’t have accomplished what was needed [accompanied of course, by clear messaging…].

            Meanwhile I have ordered and received some DHT20 sensors, and will soon begin standing some of those up. This has entailed first building a development instance to work on, as I find the MagicMirror system to be fragile, and I want to minimize downtime on the production instance. As of yesterday I do have the dev instance running and am trying to iron out a couple of wrinkles, like tracking down why and how the default calendar module on the new dev instance doesn’t display recurring appointments the same as on the existing [production] instance. Seeing as I literally copied and pasted the configuration code from the old to the new, I would think it would perform the same.

            Anyway - thanks again for the input and the guidance, as always.

            1 Reply Last reply Reply Quote 0
            • M Offline
              Michi0904
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • J Offline
                Jimmy1502
                last edited by

                Hello, im quite new to the MagicMirror and I only have basic Programming Knowledge. I tried using ur Module and i strictly followed ur guide, but it doesnt work. The module itself is loading even th icons, but there are no numbers visible. I tried to check the library but it doesnt work.
                Is it a Problem on my side or a Problem with the adafruit library?

                Thx for your help.

                1 Reply Last reply Reply Quote 0
                • bugsounetB bugsounet referenced this topic on
                • L Offline
                  lif
                  last edited by

                  I have installed the module but get the following when I try to run your test ‘python3 AdafruitDHT.py 22 26’

                  I know the DHT-22 works on GPIO pin 26
                  ~/Adafruit_Python_DHT/examples $ sudo python3 AdafruitDHT.py 22 26
                  Traceback (most recent call last):
                  File “/home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py”, line 41, in
                  humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  File “/usr/local/lib/python3.11/dist-packages/Adafruit_DHT-1.4.0-py3.11-linux-aarch64.egg/Adafruit_DHT/common.py”, line 94, in read_retry
                  humidity, temperature = read(sensor, pin, platform)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  File “/usr/local/lib/python3.11/dist-packages/Adafruit_DHT-1.4.0-py3.11-linux-aarch64.egg/Adafruit_DHT/common.py”, line 80, in read
                  platform = get_platform()
                  ^^^^^^^^^^^^^^
                  File “/usr/local/lib/python3.11/dist-packages/Adafruit_DHT-1.4.0-py3.11-linux-aarch64.egg/Adafruit_DHT/common.py”, line 63, in get_platform
                  raise RuntimeError(‘Unknown platform.’)
                  RuntimeError: Unknown platform.

                  Any thoughts?

                  BKeyportB 1 Reply Last reply Reply Quote 0
                  • BKeyportB Offline
                    BKeyport Module Developer @lif
                    last edited by

                    @lif It’s requiring tools no longer available, so dead module. Use something else.

                    https://github.com/Tom-Hirschberger/MMM-Temperature is what I used when I had a module hooked up to it.

                    The "E" in "Javascript" stands for "Easy"

                    L 1 Reply Last reply Reply Quote 1
                    • L Offline
                      lif @BKeyport
                      last edited by

                      @BKeyport said in MMM-DHT22:

                      @lif It’s requiring tools no longer available, so dead module. Use something else.

                      https://github.com/Tom-Hirschberger/MMM-Temperature is what I used when I had a module hooked up to it.

                      Thanks, I’ve given it a try but get an error in the last stage of the installation

                      ~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                      
                      Traceback (most recent call last):
                        File "/home/pi/MagicMirror/modules/MMM-Temperature/scripts/./dht22", line 6, in <module>
                          import board
                        File "/home/pi/MagicMirror/modules/MMM-Temperature/scripts/py-venv/lib/python3.11/site-packages/board.py", line 51, in <module>
                          from adafruit_blinka.board.raspberrypi.raspi_40pin import *
                        File "/home/pi/MagicMirror/modules/MMM-Temperature/scripts/py-venv/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_40pin.py", line 6, in <module>
                          from adafruit_blinka.microcontroller.bcm283x import pin
                        File "/home/pi/MagicMirror/modules/MMM-Temperature/scripts/py-venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 7, in <module>
                          from adafruit_blinka.microcontroller.generic_linux.rpi_gpio_pin import Pin
                        File "/home/pi/MagicMirror/modules/MMM-Temperature/scripts/py-venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/rpi_gpio_pin.py", line 6, in <module>
                          from RPi import GPIO
                      ModuleNotFoundError: No module named 'RPi'
                      
                      
                      BKeyportB L 2 Replies Last reply Reply Quote 0
                      • BKeyportB Offline
                        BKeyport Module Developer @lif
                        last edited by

                        @lif I’m not sure on that, @wishmaster270 (Tom) would know more.

                        The "E" in "Javascript" stands for "Easy"

                        1 Reply Last reply Reply Quote 0
                        • L Offline
                          lif @lif
                          last edited by

                          Thanks, not the end of the world if I can’t use it.

                          wishmaster270W 1 Reply Last reply Reply Quote 0
                          • wishmaster270W Offline
                            wishmaster270 Module Developer @lif
                            last edited by

                            @lif Hi. Great you want to try one of my modules.

                            Can you try installing a additional python system package with

                            sudo apt install python3-rpi-lgpio
                            

                            I tried the scripts on my newly installed system with Bookworm and everything worked as expected.
                            Maybe the missing package had been installed with something else I installed on my system.

                            L 1 Reply Last reply Reply Quote 0
                            • L Offline
                              lif @wishmaster270
                              last edited by

                              @wishmaster270 said in MMM-DHT22:

                              @lif Hi. Great you want to try one of my modules.

                              Can you try installing a additional python system package with

                              sudo apt install python3-rpi-lgpio
                              

                              I tried the scripts on my newly installed system with Bookworm and everything worked as expected.
                              Maybe the missing package had been installed with something else I installed on my system.

                              Thanks, that was already installed

                              sudo apt install python3-rpi-lgpio
                              Reading package lists... Done
                              Building dependency tree... Done
                              Reading state information... Done
                              python3-rpi-lgpio is already the newest version (0.6-0~rpt1).
                              0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
                              
                              

                              This is on Bookworm

                              wishmaster270W 1 Reply Last reply Reply Quote 0
                              • wishmaster270W Offline
                                wishmaster270 Module Developer @lif
                                last edited by

                                @lif
                                That’s strange…Can you try to start with a new, fresh virtual python environment and install the needed libs again?

                                Remove old virtual environment:

                                rm -rf /home/pi/MagicMirror/modules/MMM-Temperature/scripts/py-venv
                                

                                Install the needed system libs:

                                sudo apt -y update && sudo apt -y install python3-venv libgpiod2
                                

                                Re-Create the virtual environment:

                                cd ~/MagicMirror/modules/MMM-Temperature/scripts
                                ./venvWrapper.py --verbose --venv-name py-venv --create
                                

                                Re-Install the libs:

                                cd ~/MagicMirror/modules/MMM-Temperature/scripts
                                ./venvWrapper.py --venv-name py-venv --install-libs adafruit-circuitpython-dht
                                

                                Run the test again:

                                cd ~/MagicMirror/modules/MMM-Temperature/scripts
                                ./venvWrapper.py --venv-name py-venv --run ./dht22
                                

                                If it fails again. Can you please provide the output of

                                cd ~/MagicMirror/modules/MMM-Temperature/scripts
                                source py-venv/bin/activate
                                pip freeze
                                deactivate
                                

                                The output should look something like:

                                Adafruit-Blinka==8.66.1
                                Adafruit-Blinka-Raspberry-Pi5-Neopixel==1.0.0rc2
                                adafruit-circuitpython-busdevice==5.2.13
                                adafruit-circuitpython-connectionmanager==3.1.5
                                adafruit-circuitpython-dht==4.0.9
                                adafruit-circuitpython-requests==4.1.13
                                adafruit-circuitpython-typing==1.12.2
                                Adafruit-PlatformDetect==3.83.2
                                Adafruit-PureIO==1.1.11
                                binho-host-adapter==0.1.6
                                lgpio==0.2.2.0
                                pyftdi==0.57.1
                                pyserial==3.5
                                pyusb==1.3.1
                                rpi-ws281x==5.0.0
                                RPi.GPIO==0.7.1
                                sysv-ipc==1.1.0
                                typing_extensions==4.15.0
                                
                                S 1 Reply Last reply Reply Quote 0
                                • S Offline
                                  sdetweil @wishmaster270
                                  last edited by

                                  @wishmaster270 AND you must enable the virtual env in the script if pm2 starts MagicMirror

                                  Sam

                                  How to add modules

                                  learning how to use browser developers window for css changes

                                  wishmaster270W 1 Reply Last reply Reply Quote 0
                                  • wishmaster270W Offline
                                    wishmaster270 Module Developer @sdetweil
                                    last edited by

                                    @sdetweil Hi sam. My wrapper script will use the python binary in the virtual environment folder. This way the environment will be activated automatically.

                                    S 1 Reply Last reply Reply Quote 0
                                    • S Offline
                                      sdetweil @wishmaster270
                                      last edited by

                                      @wishmaster270 cool, you have the venv in the module folder

                                      Sam

                                      How to add modules

                                      learning how to use browser developers window for css changes

                                      1 Reply Last reply Reply Quote 0
                                      • L Offline
                                        lif
                                        last edited by

                                        @wishmaster270 said in MMM-DHT22:

                                        source py-venv/bin/activate

                                        Same failure on install.

                                        from RPi import GPIO
                                        ModuleNotFoundError: No module named 'RPi'
                                        ```, 
                                        
                                        The output of pip freeze is ```
                                        MagicMirror/modules/MMM-Temperature/scripts $ source py-venv/bin/activate
                                        (py-venv) pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ pip freeze
                                        Adafruit-Blinka==8.66.2
                                        adafruit-circuitpython-busdevice==5.2.13
                                        adafruit-circuitpython-connectionmanager==3.1.5
                                        adafruit-circuitpython-dht==4.0.9
                                        adafruit-circuitpython-requests==4.1.13
                                        adafruit-circuitpython-typing==1.12.2
                                        Adafruit-PlatformDetect==3.84.0
                                        Adafruit-PureIO==1.1.11
                                        binho-host-adapter==0.1.6
                                        pyftdi==0.57.1
                                        pyserial==3.5
                                        pyusb==1.3.1
                                        sysv-ipc==1.1.0
                                        typing_extensions==4.15.0
                                        (py-venv) pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ deactivate
                                        pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ 
                                        

                                        The only difference from yours is mine is missing the second line.

                                        Hope this helps

                                        1 Reply Last reply Reply Quote 0
                                        • L Offline
                                          lif
                                          last edited by

                                          Hi,

                                          I’ve gone through your procedure again and this time it works.

                                          The only difference is that I run a python3 script to control screen blanking using a PIR before starting Magic Mirror, this time I didn’t start that script.

                                          With the PIR script and MagicMirror running I get:

                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 23.5, "humidity": 53.7, "temperature_f": 74.30000000000001, "error": false}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 23.5, "humidity": 53.7, "temperature_f": 74.30000000000001, "error": false}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 0.0, "humidity": 0.0, "temperature_f": 32.0, "error": true}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 23.6, "humidity": 53.5, "temperature_f": 74.48, "error": false}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 0.0, "humidity": 0.0, "temperature_f": 32.0, "error": true}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 23.7, "humidity": 53.3, "temperature_f": 74.66, "error": false}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ ./venvWrapper.py --venv-name py-venv --run ./dht22
                                          {"temperature_c": 23.8, "humidity": 53.2, "temperature_f": 74.84, "error": false}
                                          pi@mm:~/MagicMirror/modules/MMM-Temperature/scripts $ 
                                          
                                          

                                          I can live with that.

                                          Thanks for all your help

                                          1 Reply Last reply Reply Quote 0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 1
                                          • 2
                                          • 1 / 2
                                          • First post
                                            Last post
                                          Enjoying MagicMirror? Please consider a donation!
                                          MagicMirror created by Michael Teeuw.
                                          Forum managed by Sam, technical setup by Karsten.
                                          This forum is using NodeBB as its core | Contributors
                                          Contact | Privacy Policy