![]() |
Wiring DHT11 to Raspberry pi - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Wiring DHT11 to Raspberry pi (/thread-32378.html) |
Wiring DHT11 to Raspberry pi - hcccs - Feb-05-2021 I'm struggling with this simple setup with DHT11. I have wired in the 3-wire DHT11 sensor like this on my RP 2 model B version 1: Vcc > pin 2 (5V) Gnd > pin 9 (GND) Data > pin 7 (GPIO 4) and I keep getting "DHT sensor not found, check wiring" I couldn't find a symbol for the 3-wire sensor so disregard the 4th pin. I have installed the Adafruit_CircuitPython_DHT library. # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import adafruit_dht dhtDevice = adafruit_dht.DHT22(board.D4) while True: try: temperature_c = dhtDevice.temperature temperature_f = temperature_c * (9 / 5) + 32 humidity = dhtDevice.humidity print( "Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format( temperature_f, temperature_c, humidity ) ) except RuntimeError as error: # Errors happen fairly often, DHT's are hard to read, just keep going print(error.args[0]) time.sleep(2.0) continue except Exception as error: dhtDevice.exit() raise error time.sleep(2.0)
![]() I ran a debug on the code. The '<0x757727b0>' looks like some kind of address. Could it be something to check? It looks like it has found the sensor after all so why doesn't it work?
RE: Wiring DHT11 to Raspberry pi - Jeff900 - Feb-05-2021 And have you checked the wiring already? ![]() RE: Wiring DHT11 to Raspberry pi - Larz60+ - Feb-05-2021 using the pinout diagram here: https://pi4j.com/1.2/pins/model-2b-rev1.html diagram shows pin7 as GPIO 7, not GPIO 4 RE: Wiring DHT11 to Raspberry pi - hcccs - Feb-06-2021 (Feb-05-2021, 11:07 PM)Larz60+ Wrote: using the pinout diagram here: https://pi4j.com/1.2/pins/model-2b-rev1.html It's difficult to know what information you can trust. I used the pinout from https://pinout.xyz/# and it differs from the one you mentioned. I changed the IO number now to 4 but it's the same. I also tried running the DHT11 off 5V and 3.3 but it makes no difference. |