I am trying to get readings from a DHT11 sensor (temperature and humidity). I installed the library like so:

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

Then I tested it out by trying (in python) to import Adafruit_DHT and this worked.

Then I tried running t, h = Adafruit_DHT.read_retry(11,3) and it keeps returning None, None. My DHT11 sensor comes on a board with a +, -, and out wires and I have a raspberry pi B+ I put the plus into a power pin (1), the minus into a ground pin (6), and the out wire into a gpio pin (3).

Anyone have any ideas why it is not working?

EDIT: I tried, as per joan's suggestion, used different software and the sensor works however I still have not been able to get any python code to work.

3 Answers 3


May I suggest you try some other software which will work provided you have connected the DHT11 correctly.

Try my DHTXXD software. It requires the pigpio daemon to be running (e.g. sudo pigpiod).

The DHT11 (and other DHT models) require accurate timing of pulses a few tens of microseconds long. pigpio is one way of getting accurate times.

  • Hi @joan, thanks for the reply! I tried your software and it works. I need python code (not c code) so I guess I will try this example and hopefully that will work Jun 27, 2017 at 17:46
  • Trying that python example did not work. It outputs 0,0 for temp and humidity readings with every try. Any ideas? Jun 27, 2017 at 18:01

This is more than a year late, but in case somebody visits this question, here is what I had success with:

  1. I am using Velleman's VMA311, which is a DHT11 with a 10kohm pull-up resistor
  2. I am using Pi 3 B+ - the 1-Wire pin is 7 (GPIO4) and you have to enable it (the easiest is thru the UI or thru terminal: sudo raspi-config select the "5. Interfacing Options", "P7 1-Wire" and then "<Yes>", finally restart)
  3. I connected the sensor's:
    • "-" to GND (pin 6)
    • "+" to 3V3 (pin 1)
    • "S" (signal) to GPIO4 (pin 7)
  4. Finally save the following script to a file and execute: python temp-hum.py
    import sys
    import Adafruit_DHT

    sensor = Adafruit_DHT.DHT11
    pin = 4

    while True:
        humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
        print 'Temp: {0:0.1f} C  Humidity: {1:0.1f} %'.format(temperature, humidity)

Useful information about the 1-wire configuration can be found at pinout.xyz


Ensure that the pin number you feed into read_retry is the GPIO pin number not the board pin number. For example, on my pi, GPIO 17 corresponds to board number 11.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.