DHT11 trouble - 0° all time long

Hello guys,

I tried many times to connect my DHT11 temperature sensor to my octoprint.
I downloaded and installed the library but the sensor stays at 0°.
I think it's not detected by octoprint ...!

Please help me !

Hello @Nicolas_Gaffino!

There is a note on the Enclosure plugin github site:

  • For the DHT11, DHT22 and AM2302 follow this steps:

Wire the sensor following the wiring diagram on the pictures on thingiverse, you can use any GPIO pin.

For DHT11 and DHT22 sensors, don't forget to connect a 4.7K - 10K resistor from the data pin to VCC. Also, be aware that DHT sensors some times can not work reliably on linux, this is a limitation of reading DHT sensors from Linux--there's no guarantee the program will be given enough priority and time by the Linux kernel to reliably read the sensor. Another common issue is the power supply. you need a constant and good 3.3V, sometimes a underpowered raspberry pi will not have a solid 3.3V power supply, so you could try powering the sensor with 5V and using a level shifter on the read pin.

You need to install Adafruit library to use the temperature sensor on raspberry pi.

Open raspberry pi terminal and type:

cd ~
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get update
sudo apt-get install build-essential python-dev python-openssl
sudo python setup.py install

Note: All libraries need to be installed on raspberry pi system python not octoprint virtual environment.

You can test the library by using:

cd examples
sudo ./AdafruitDHT.py 2302 4

Note that the first argument is the temperature sensor (11, 22, or 2302), and the second argument is the GPIO that the sensor was connected.

Thank you,

here is the problem : setuptool

Hi Nicolas,

could you please explain, what you did to solve the problem?!
I have the same problems with my AM2302-Sensor. I'm a beginner and not able to understand what you did and what you show in the screenshot.

When I test the sensor in the Linux Octopi Console with "sudo ./AdafruitDHT.py 2302 4" all values are shown correctly: Temperature and humidity. But in Octoprint there are always 0°C an 0%.

Thank you and greetings,
Zeely

It seems that the enclosure plugin has trouble reading from the sensor driver.
I've implemented it into Top Temp and it works fine.

@Nicolas_Gaffino I have the same problem with DHT22, after this i buy Si7021.
I advise you to use the Si7021, is easier.

@Zeely have you try to use SUDO for the commands? And you have to set passwordless for SUDO see here: click me (tip from @Ewald_Ikemann :wink:)

2 Likes

Hi....In the event that you set your "circle whereas" esteem to something more sensible rather than "0", like maybe your actual target esteem then it'll escape. Also, you're running at 20Mhz. I haven't utilized the DHT11 but I don't think it'll take exceptionally long to test. Hence it'll circle exceptionally rapidly undoubtedly (speculating numerous, numerous thousands of times per moment) and you'll before long surpass the Uint extend of your variable "x". It'll begin checking all over once more from each time it comes to it's restrain so this implies that your tally "on the off chance that" it get away your circle will be incorrect. I do not know your aiming application but do you truly got to test so rapidly? Maybe consider counting a delay in your loop?

https://www.7pcb.com/

I had the same problem. For some reason the getDHTTemp.py import is not correct compared to the Adafruit_DHT requirement. Here is the code that worked for me :

import sys
import time
import Adafruit_DHT

sensor_args =   {
                    '11': Adafruit_DHT.DHT11,
                    '22': Adafruit_DHT.DHT22,
                    '2302': Adafruit_DHT.DHT22
                }

if len(sys.argv) == 3 and sys.argv[1] in sensor_args:
    sensor = sensor_args[sys.argv[1]]
    pin = sys.argv[2]

else:
    sys.exit(1)

max_retries = 3
retry_count = 0
while retry_count <= max_retries:
    try:
        humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

        if humidity is not None and temperature is not None:
            print('{0:0.1f} | {1:0.1f}'.format(temperature, humidity))
            sys.exit(1)
    except RuntimeError as e:
        time.sleep(2)
        retry_count += 1
        continue

    time.sleep(1)
    retry_count += 1

print('-1 | -1')
sys.exit(1)