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
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
4 жыл бұрын
Thank you, you're awesome.
@abdesh3262
2 жыл бұрын
this code for hat bro ?
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
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
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
3 жыл бұрын
@@minecraftchest1 Thanks for the reply. It's was a defective part. 45 minutes of debugging proved it.
@nathaniel7778
11 ай бұрын
Could this also be used as a camera overlay?
Just subscribed I’m a young electrical engineer and this helped me so much thank you
Cool. I ordered some of these a few weeks back. Still waiting for them to arrive (slow boat from China)
@TheGeekPub
5 жыл бұрын
Oh I can't wait to see what you'll be using these for!
Nice and Simple, Thank-you!
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
5 жыл бұрын
Anyone can learn this stuff! :-)
@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.
This is the perfect addition to a homemade wood kiln.
This code does not work on a Raspberry Pi4. How can we get it to work on the Pi4?
Thank you; you just save my summer class.
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.
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
3 жыл бұрын
Ikr
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
4 жыл бұрын
I have the same problem
@JovaCoder
4 жыл бұрын
@Ryan Atack same here. Has anyone figured this issue out?
@jaahtastick
3 жыл бұрын
same here, complete mess. cant get it to work
@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/
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
iam unable read humid and temperature values with my Pi 4 , instead iam getting continuos none values ( using new DHT11 and Pi 4 )
Easy to understand
Since its all wire-connected, why is there a 65 feet distance limits?
@TheGeekPub
2 жыл бұрын
Wire too is a resistor. The longer it is the higher the resistance.
Why resistors aren't in use here? thanks
@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
3 жыл бұрын
thanks. i was having this problem.
@dbishop9085
10 ай бұрын
thank you as well. saved me some time im sure.. this would be useful as an edit in the video
Hi, is there a way to connect another few DHT11 to the port? Like another 5 or more? Thanks.
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?
Could I use this to keep track of temp/ humidity of area around a mining rig?
Great video, Mike! Mike, do you plan on doing more woodworking project videos?
@TheGeekPub
5 жыл бұрын
Absolutely!
Can you make a project on how to use the CCS811/BME280 (Qwiic) Environmental Combo
Great Video! How do I access to this sensor in other python projects (IDLE)? What coding do I have to use?
@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.
ok now i need the SAME VIDEO but it uses a picaxe 14M2
its showing none at some point why is that happening ??
How can i use Rpi 4 i can't find a library for it?
What is that black component with 3 pins attatched with the DHT11 please?
Why are sudo’ing the nano command? Why does it need root?
@TheGeekPub
5 жыл бұрын
It doesn’t but just in case someone has jacked up permissions the tutorial will still work for them.
Can I can just plug the sensor with cables directly to the IOT? based in the selected IO ports?
@Lukas-gn5yf
3 жыл бұрын
Sure
Are there wireless sensor available ? Need to add the sensors in my fridge
@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
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
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).
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
5 жыл бұрын
I have an Arduino version of this on the website: www.thegeekpub.com/16510/using-arduino-temperature-sensors-dht11-and-dht22/
Is there a way to get temperatures from different locations with this or will I need multiple setups?
@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.
If you wanted to add another value to measure, such as pressure, could i?
@Lukas-gn5yf
3 жыл бұрын
This sensor probably cannot read pressure
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
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.
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
4 ай бұрын
Did you ever find out the issue?
First! Skynet bot
Didnt you put the Power and ground pin in wrong?
@TheGeekPub
3 жыл бұрын
Not that I am aware of. If I had it would not have worked. Remember, not every manufacturer makes them the same.
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
3 жыл бұрын
am having the same issue with a pi4 but same code works with pi3!!
@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 🙁
Good stuff. Thanks. Maybe record audio at higher level. I had to crank the vol to hear it.
@tobyminerBTC
5 жыл бұрын
I think its just you man. I can hear it fine.
I need source code
@TheGeekPub
Жыл бұрын
Links in the description
2:45 - Using sudo when it's not necessary is a dangerous habit to get into.
@TheGeekPub
2 жыл бұрын
Sure. On my corporate LAN. Not on my RPI that I wipe and erase 5 times a day.
My sensor returns sometimes Sonsor Error. lol
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
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
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.
ekis ka men!
typo in title: Rapberry
@TheGeekPub
5 жыл бұрын
Fixed
what coding platform is he using to type and save the code in?
@TheGeekPub
Жыл бұрын
Arduino.
you lost me around the 2:20 Mark :'(