No video

Raspberry Pi DHT11 DHT22 Temperature and Humidity Sensor

Support this Channel on Patreon:
/ thegeekpub
In this video, we're going to cover how to use the DHT11 or DHT22 Temperature and Humidity Sensor with the Rapberry Pi.
Detailed article and wiring diagrams here:
www.thegeekpub...
Sensor Wiki:
www.thegeekpub...
Parts List for Project:
* Raspberry Pi 3: amzn.to/2VMYfvJ
* DHT11 Sensor Only: amzn.to/2YAPQbS
* DHT22 Sensor Only: amzn.to/2VPNaKD
* DHT11 Module: amzn.to/2YAPQbS
* DHT22 Module: amzn.to/2LSukhb
* 10K Ohm Resistor: amzn.to/2LRie89
* Raspberry Pi Breakout Cable: amzn.to/2WbwjRM
* Breadboard and Wires: amzn.to/2LTEGxe
Visit the Murray² Forum:
murray2.com/
Find us on Social Media:
/ thegeekpub
/ thegeekpub
/ thegeekpub

Пікірлер: 90

  • @anniyangX
    @anniyangX4 жыл бұрын

    import Adafruit_DHT import time DHT_SENSOR = Adafruit_DHT.DHT11 DHT_PIN = 4 while True: humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN) if humidity is not None and temperature is not None: print("Temp={0:0.1f}C Humidity={1:0.1f}%".format(temperature, humidity)) else: print("Sensor failure. Check wiring."); time.sleep(3);

  • @MMOToaster

    @MMOToaster

    4 жыл бұрын

    Thank you, you're awesome.

  • @abdesh3262

    @abdesh3262

    2 жыл бұрын

    this code for hat bro ?

  • @TheGeekPub
    @TheGeekPub5 жыл бұрын

    If you need to track the temperature of a project using a Raspberry Pi, the DHT11 and DHT22 temperature and humidity combo sensor is the perfect choice!

  • @essenar7535

    @essenar7535

    3 жыл бұрын

    I have an error hope someone can help me out. I keep getting the message 'Sensor failure check wiring. Possible causes that I have ruled out: 1. Wires are in perfect working condition 2. Power supply is more than sufficient. (Red light does come on) 3. Checked the connections in every way possible 4. Program must be working because the error message is printed correctly. 5. This is an original raspberry not a cheap version The thing which is weird is that from the multiple attempts it has sometimes worked. Its a 1 in 20 chance. And it only gives one reading before returning to the same error. Is my sensor fried. Its brand new but the only explanation I can think of. Please advise. Thank you.

  • @minecraftchest1

    @minecraftchest1

    3 жыл бұрын

    @@essenar7535 May be a bad from the factory part. Edit: I saw another comment that explains a one line change to make it work.

  • @essenar7535

    @essenar7535

    3 жыл бұрын

    @@minecraftchest1 Thanks for the reply. It's was a defective part. 45 minutes of debugging proved it.

  • @nathaniel7778

    @nathaniel7778

    11 ай бұрын

    Could this also be used as a camera overlay?

  • @ratiabuladze5837
    @ratiabuladze58374 жыл бұрын

    Just subscribed I’m a young electrical engineer and this helped me so much thank you

  • @matthiaswandel
    @matthiaswandel5 жыл бұрын

    Cool. I ordered some of these a few weeks back. Still waiting for them to arrive (slow boat from China)

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    Oh I can't wait to see what you'll be using these for!

  • @azimmustufabaldiwala5833
    @azimmustufabaldiwala583312 күн бұрын

    Nice and Simple, Thank-you!

  • @foxhallww311
    @foxhallww3115 жыл бұрын

    I’m a network engineer too. You are a completely higher level then me. I fix things caused by user error in a daily basis.

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    Anyone can learn this stuff! :-)

  • @foxhallww311

    @foxhallww311

    5 жыл бұрын

    TheGeekPub true. I know basic coding but I don’t have the time to dive in with my media business and day time job.

  • @bulkhead
    @bulkhead5 жыл бұрын

    This is the perfect addition to a homemade wood kiln.

  • @watsthislifefor
    @watsthislifefor3 жыл бұрын

    This code does not work on a Raspberry Pi4. How can we get it to work on the Pi4?

  • @patricklaakak9458
    @patricklaakak94583 жыл бұрын

    Thank you; you just save my summer class.

  • @kinyo666
    @kinyo666Ай бұрын

    You inverted the wires VCC and GND at 1:20. The red wire should be plugged into the right pin. At the end of the video you will see the correct wiring.

  • @lewiqe
    @lewiqe3 жыл бұрын

    Don't understand it . The labels on the sensor marked: GND, Data, VCC .In the video you connect with the black cable the vcc with gnd and with red the gnd to 5V. (sensor pin to Rasp.pin)

  • @Lukas-gn5yf

    @Lukas-gn5yf

    3 жыл бұрын

    Ikr

  • @naoeuroi7233
    @naoeuroi72334 жыл бұрын

    I always get Sensor Failure. Check Wiring, I have check the wires the led in the module is glowing. But output from the sensor cannot bt obtain. Any suggestions.

  • @ukaszsikoraa1414

    @ukaszsikoraa1414

    4 жыл бұрын

    I have the same problem

  • @JovaCoder

    @JovaCoder

    4 жыл бұрын

    @Ryan Atack same here. Has anyone figured this issue out?

  • @jaahtastick

    @jaahtastick

    3 жыл бұрын

    same here, complete mess. cant get it to work

  • @lklmmedia4715

    @lklmmedia4715

    3 жыл бұрын

    Not sure if this is still relevant for you - but some models of the 3 pin Module have the VCC and Digital pin reversed. www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-the-raspberry-pi/

  • @caginbektas
    @caginbektas2 жыл бұрын

    Excellent tutorial, clean and basic, thank you! I was wondering what if we do the data communication using wi-fi or bluetooth modules -to remove the cable dependency- would it make sense? Tbh, I am searching for this need and could not find a good tutor like you so far, keeping an eye on the channel :P

  • @talarikarun
    @talarikarun3 жыл бұрын

    iam unable read humid and temperature values with my Pi 4 , instead iam getting continuos none values ( using new DHT11 and Pi 4 )

  • @jatinsathe4662
    @jatinsathe46623 жыл бұрын

    Easy to understand

  • @allan3376
    @allan33762 жыл бұрын

    Since its all wire-connected, why is there a 65 feet distance limits?

  • @TheGeekPub

    @TheGeekPub

    2 жыл бұрын

    Wire too is a resistor. The longer it is the higher the resistance.

  • @ivko5673
    @ivko56736 ай бұрын

    Why resistors aren't in use here? thanks

  • @eddiejhong
    @eddiejhong5 жыл бұрын

    @TheGeekPub Please add a comment in the code and an annotation to the video. IMPORTANT NOTE FOR DHT22 If you're using a DHT22, the Python code will be slightly different. You will have to specify that the DHT_SENSOR is DHT22 rather than DHT11: ``` DHT_SENSOR = Adafruit_DHT.DHT22 # Specifies that you're using DHT22 rather than DHT11 ``` Otherwise, you won't get any readings.

  • @thebestnerd4444

    @thebestnerd4444

    3 жыл бұрын

    thanks. i was having this problem.

  • @dbishop9085

    @dbishop9085

    10 ай бұрын

    thank you as well. saved me some time im sure.. this would be useful as an edit in the video

  • @alesjaterka2155
    @alesjaterka21553 жыл бұрын

    Hi, is there a way to connect another few DHT11 to the port? Like another 5 or more? Thanks.

  • @dtn2529
    @dtn25292 жыл бұрын

    The DHT22 sensor enables temperature measurement in the range of -40 to 80°Celsius Does your program accept this? I.e it also shows negative temperatures?

  • @tylerwilliams4958
    @tylerwilliams49582 жыл бұрын

    Could I use this to keep track of temp/ humidity of area around a mining rig?

  • @ShawarioX
    @ShawarioX5 жыл бұрын

    Great video, Mike! Mike, do you plan on doing more woodworking project videos?

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    Absolutely!

  • @osamaasad4833
    @osamaasad48334 жыл бұрын

    Can you make a project on how to use the CCS811/BME280 (Qwiic) Environmental Combo

  • @christopherungar3515
    @christopherungar35153 жыл бұрын

    Great Video! How do I access to this sensor in other python projects (IDLE)? What coding do I have to use?

  • @TheJacklwilliams

    @TheJacklwilliams

    3 жыл бұрын

    Chris, I just watched it because I'm building a sensor app for a small data closet. Now keep in mind, noobie hardware guy, but years in IT. If I read you correctly, much like I'm going to. Aka, get the core code he uses to get the temp, set your sleep time. Now, you've got the data, printing to terminal is just an example. What do I do next? Well in my case I'll take this code, take the temperatures and write them too a log so I have a record. Next and the reason I'm doing this, is I'll check that temp. If it exceeds a set ratio (my ac went out) say 65 F, then I'll generate an alarm and send out email and text messaging to the management team that they need to check the data closet cooling, etc.... I also intend to add an LCD so if your in the closet, the temp is displayed at a glance.

  • @robertsteel3563
    @robertsteel35635 жыл бұрын

    ok now i need the SAME VIDEO but it uses a picaxe 14M2

  • @jaryniespeneli3074
    @jaryniespeneli30742 жыл бұрын

    its showing none at some point why is that happening ??

  • @emangalal5831
    @emangalal5831 Жыл бұрын

    How can i use Rpi 4 i can't find a library for it?

  • @neiltonna8737
    @neiltonna87374 жыл бұрын

    What is that black component with 3 pins attatched with the DHT11 please?

  • @Aluatis
    @Aluatis5 жыл бұрын

    Why are sudo’ing the nano command? Why does it need root?

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    It doesn’t but just in case someone has jacked up permissions the tutorial will still work for them.

  • @OliverCasasola
    @OliverCasasola3 жыл бұрын

    Can I can just plug the sensor with cables directly to the IOT? based in the selected IO ports?

  • @Lukas-gn5yf

    @Lukas-gn5yf

    3 жыл бұрын

    Sure

  • @hihohihoi1325
    @hihohihoi1325 Жыл бұрын

    Are there wireless sensor available ? Need to add the sensors in my fridge

  • @jimmydiaz1502

    @jimmydiaz1502

    6 ай бұрын

    Look at the hc05 hc06 serial Bluetooth modules, you'd need a battery and some sort of controller/translator between the dht11 and the hc06, I'd use an Arduino for simplicity

  • @dadud3
    @dadud35 жыл бұрын

    Say i work on a farm where we use remote temp sensors using radio transmitters and receivers/gateways to send them over a large distnance (0.25 mile-1 mile) and i wanted to upgrade our old phone call out alarm with an android app, how i could i adapt something like this into that system? I could send you more details if you feel like helping me out here. im kind of a pi-newbie but i want to see how easily it can be done.

  • @Miheer.Dodhia

    @Miheer.Dodhia

    5 жыл бұрын

    Hi Google mqtt. It's a protocol for sending iot data between devices and there are lots of android apps that can read mqtt messages. You'll need to install a mqtt server on the pi (think it's called mosquito).

  • @heartlessalice5801
    @heartlessalice58015 жыл бұрын

    It took me 3min to realiseit was an RPi tutorial and not an Arduino one (I know, i can be pretty dense when it's the morning ^^) Now I understand why it's seemed weird that he was using linux and python ^^

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    I have an Arduino version of this on the website: www.thegeekpub.com/16510/using-arduino-temperature-sensors-dht11-and-dht22/

  • @glenwoodb598
    @glenwoodb5985 жыл бұрын

    Is there a way to get temperatures from different locations with this or will I need multiple setups?

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    You'd just need multiple sensors on different GPIO pins. You can duplicate the first few lines of code as many times as you have free pins.

  • @matmaxmontalvomartinez421
    @matmaxmontalvomartinez4213 жыл бұрын

    If you wanted to add another value to measure, such as pressure, could i?

  • @Lukas-gn5yf

    @Lukas-gn5yf

    3 жыл бұрын

    This sensor probably cannot read pressure

  • @L.Stefan
    @L.Stefan4 жыл бұрын

    Am I the only one who noticed that When you connect the pins you say that the ground pin is on the right, but after connecting all three you do a closeup (1:35) and on the sensor it says GND on the left. How is it ? because I have a difficult time reading the datasheet because the GND and VCC pins seem to be swapped on some manufacturers !!

  • @TheGeekPub

    @TheGeekPub

    4 жыл бұрын

    It also depends on whether you are looking at the back or the front of the module. The pinouts are also listed on the back side.

  • @lubibubi6380
    @lubibubi63803 жыл бұрын

    i can´t download Adafriut and in the description is no link which can help me have someone an idea how to slove the problem

  • @adenojo8609

    @adenojo8609

    4 ай бұрын

    Did you ever find out the issue?

  • @foxhallww311
    @foxhallww3115 жыл бұрын

    First! Skynet bot

  • @Lukas-gn5yf
    @Lukas-gn5yf3 жыл бұрын

    Didnt you put the Power and ground pin in wrong?

  • @TheGeekPub

    @TheGeekPub

    3 жыл бұрын

    Not that I am aware of. If I had it would not have worked. Remember, not every manufacturer makes them the same.

  • @basmaal-ghali9174
    @basmaal-ghali91743 жыл бұрын

    from . import Beaglebone_Black_Driver as driver ImportError: cannot import name 'Beaglebone_Black_Driver' from 'Adafruit_DHT' (/usr/local/lib/python3.7/dist-pac please, how to solve this problem with my raspberry pi 4B!

  • @hussainirusham2925

    @hussainirusham2925

    3 жыл бұрын

    am having the same issue with a pi4 but same code works with pi3!!

  • @SprocketN

    @SprocketN

    3 жыл бұрын

    There is a fix I found on GitHub. I lost the link, so typing it here. The error seems to be that the platform_detect.py program doesn’t recognise a Pi4. Try - sudo nano /usr/local/lib/python3.7/dist-packages/Adafruit_DHT/platform_detect.py - scroll down to the bottom of the file and add an elif statement before the final else. elif match.group(1) == ‘BCM2711’: #Pi 4 Return 3 Enable I2C in interface preferences Then reboot Edit: when I tried this the error cleared but I still didn’t get readings. Kept getting sensor error message. Both temperature and pressure were None. Haven’t sorted it yet 🙁

  • @lint2023
    @lint20235 жыл бұрын

    Good stuff. Thanks. Maybe record audio at higher level. I had to crank the vol to hear it.

  • @tobyminerBTC

    @tobyminerBTC

    5 жыл бұрын

    I think its just you man. I can hear it fine.

  • @martinuspataloan7849
    @martinuspataloan7849 Жыл бұрын

    I need source code

  • @TheGeekPub

    @TheGeekPub

    Жыл бұрын

    Links in the description

  • @eLindemann
    @eLindemann2 жыл бұрын

    2:45 - Using sudo when it's not necessary is a dangerous habit to get into.

  • @TheGeekPub

    @TheGeekPub

    2 жыл бұрын

    Sure. On my corporate LAN. Not on my RPI that I wipe and erase 5 times a day.

  • @phillip6045
    @phillip60452 жыл бұрын

    My sensor returns sometimes Sonsor Error. lol

  • @minecraftchest1
    @minecraftchest13 жыл бұрын

    Why did you say to put sudo in front of nano? That runs the editor as root which is not necessary. Just have people verify that they are in their home directory instead.

  • @tobyminerBTC

    @tobyminerBTC

    3 жыл бұрын

    Spoken like someone who's NEVER done IT work. If you want to build an app, the last place you want to put it is in your home directory.

  • @minecraftchest1

    @minecraftchest1

    3 жыл бұрын

    @@tobyminerBTC My point was more along the lines of if you need root access, you should generally either use a different directory, or change the permissions.

  • @armanmallari8147
    @armanmallari81474 жыл бұрын

    ekis ka men!

  • @squalazzo
    @squalazzo5 жыл бұрын

    typo in title: Rapberry

  • @TheGeekPub

    @TheGeekPub

    5 жыл бұрын

    Fixed

  • @ARIANASMETANA
    @ARIANASMETANA Жыл бұрын

    what coding platform is he using to type and save the code in?

  • @TheGeekPub

    @TheGeekPub

    Жыл бұрын

    Arduino.

  • @Dogewatch69
    @Dogewatch692 жыл бұрын

    you lost me around the 2:20 Mark :'(