2

The 'kookye' DHT11 tutorial suggests connecting to GPIO14 (TXD) at pin 8. An rpi3B+ and a relay board uses the GPIO14 for programming firmwware per the table:

PIN    GPIO   CLASS      RELAY BOARD FUNCTION 
3,5    2,3    SDA,SCL    I2C commands
7      4      GPCLK0     Interrupt Handler
8,10   14,15  TXD,RXD    Firmware Programming 

The Circuit basics tutorial indicates configuring GPIO-4 (GPCLK0) Pin-7:

enter image description here

QUESTIONS

  • Can a common GPIO (i.e. GPIO-17) be configured to receive DHT11 data?

  • Which GPIOs can be configured to receive DHT11 data?

enter image description here

TEST PROCEDURE

  1. Enter this at the command prompt to download the library:

    git clone https://github.com/adafruit/Adafruit_Python_DHT.git

  2. Change directories with:

    cd Adafruit_Python_DHT

  3. Now enter this:

    sudo apt-get install build-essential python-dev

  4. Then install the library with:

    sudo python setup.py install

  5. Invoke python

    sudo python # failure to sudo results in the execution failure below

and issue commands:

import sys; import Adafruit_DHT

humidity, temperature = Adafruit_DHT.read_retry(11, 26) #GPIO-26 on pin-37

ERROR MESSAGES CAUSED BY NOT USING sudo: Retry with GPIO (26) and not PIN (37)

humidity, temperature = Adafruit_DHT.read_retry(11, 26)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "Adafruit_DHT/common.py", line 55, in get_platform
    from . import Raspberry_Pi_2
  File "Adafruit_DHT/Raspberry_Pi_2.py", line 22, in <module>
    from . import Raspberry_Pi_2_Driver as driver
ImportError: cannot import name Raspberry_Pi_2_Driver

UNUSUAL TEST RESULTS:

[19:28:24] openhabian@openhab:~/Adafruit_Python_DHT$ sudo ./examples/AdafruitDHT.py 11 26
Temp=7.0*  Humidity=55.0%
[19:28:47] openhabian@openhab:~/Adafruit_Python_DHT$ sudo ./examples/AdafruitDHT.py 11 26
Temp=7.0*  Humidity=55.0%
[19:29:13] openhabian@openhab:~/Adafruit_Python_DHT$ sudo ./examples/AdafruitDHT.py 11 26
Temp=7.0*  Humidity=56.0%
[19:29:21] openhabian@openhab:~/Adafruit_Python_DHT$ cd ..
[19:32:51] openhabian@openhab:~$ sudo ./Adafruit_Python_DHT/examples/AdafruitDHT.py 11 26
Temp=3.0*  Humidity=**165.0%**
[19:33:02] openhabian@openhab:~$ sudo ./Adafruit_Python_DHT/examples/AdafruitDHT.py 11 26
Temp=7.0*  Humidity=55.0%
10
  • (1) YES, you can use GPIO17, if you won't consider using it for SPI1 later: imgur.com/PSwTXaK, (2) ALL Rpi GPIO pins can be used to receive DHT11 data, but actually you don't just use a GPIO pin toreceive data firom DHT11, if I remember correctly, the same GPIO pin is to send command signals to DHT11. But I forgot the details, perhaps I should search my old posts to refresh my memory. I tend to think that the I2C data pin might be a good choice, for the following reasons: (1) it have a strong pull up of 1k8. which means less noisy, longer distance, (2) ... forgot!, / to continue, ...
    – tlfong01
    Feb 13 '20 at 3:04
  • (3) Actually MCP23017 (or similar IOX devices) GPIO pins (more details later) is better, for a couple of reasons: (1) Newbie proof, because DHT11 kills the middle guy first, and if you see green smokes coming out, you can quickly pull the plug! :)
    – tlfong01
    Feb 13 '20 at 3:07
  • But Lada Ada says her old library your are using is depreciated, and suggests you to try her new CircuitPython library.
    – tlfong01
    Feb 13 '20 at 3:26
  • 1
    If you have a good tutorial link that you recommend to Adafruit's CircuitPython Libary, please consider posting it somewhere either as a comment or preferably as an answer. I was able to read DHT11 sensor data with the procedure above in teh OP. Thank you
    – gatorback
    Feb 13 '20 at 4:50
  • I didn't catch you. Did you mean you can use the kookye tutorial python program to read DHT11, but no luck with the AdaFruit tutorial? BTW, even you find the Circuit Python library for DHT11, you cannot use directly with Rpi. You still need to find another hacker to kindly convert the CircuitPython to Rpi python, because Rpi cannot install CP interpreter and run CP program smoothly. I did spend time in playing with MicroPython (MP), with PyBoard and BBC MicroBit and found is very compatible with CP (actually CP came from MP), and found it OK for newbies and small projects. A long story, :(
    – tlfong01
    Feb 13 '20 at 5:10
1

Any GPIO on the expansion header may be used to receive data from the DHT11 with the possible exception of GPIO 2 and 3 (pins 3 and 5). GPIO 2 and 3 have 1k8 hard wired pull-ups to 3V3 which may interfere with the proper operation of the DHT11.

It would make sense to avoid GPIO which have specialised functionality like the I2C, SPI, and UART GPIO (as you may need those GPIO for another project later on).

1
  • Thank you for replying. I was able to read temperature and humidity from the sensor. Using sudo is required to invoke python for this exercise
    – gatorback
    Feb 13 '20 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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