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