How to Set Up the DHT11 Humidity Sensor on the Raspberry Pi
HTML-код
- Опубликовано: 22 июл 2024
- How to Set Up the DHT11 Humidity Sensor on the Raspberry Pi
In this video, I'll show you how to set up the DHT11 humidity and temperature sensor on Raspberry Pi, and output the sensor readings to an SSH terminal or to an LCD display. I'll also provide example code for programming it with C and Python, and show you how to change between Celsius and Fahrenheit.
Get a DHT11 here: www.amazon.com/gp/product/B00...
All of the example programs and wiring diagrams can be found here: www.circuitbasics.com/how-to-...
Check out the Circuit Basics blog for articles and tutorials on the Raspberry Pi, Arduino and other DIY electronic projects! www.circuitbasics.com
Facebook: / circuitbasic
Twitter: / circuitbasics
Instagram: / circuitbasics Наука
Dude. This explanation is awesome. Nothing extra. Helped me a bunch. Thanks for uploading. Subscribed.
Hi, thank you for the video. Personally, I feel that the response time for temperature measurement is slow compared to that of the TC74, thus making it kind of inaccurate. However, the response time and accuracy for humidity is spot on. If I had to measure both temperature and humidity simultaneously, I would use the TC74 for temperature and the DHT11 for humidity.
Very help full video for me a Raspberry Pi newbee like me. It helped me to find C and Python code to run different devices that I can use. Thanks again keep the video's coming have a good day..
thanks! I wanna ask about "what if the DHT11 sensor device was on outdoor and RPi was few meters away will does that work when I have wireless internet usb?"
great tutorial. could you make a follow up video on how to have the temperature sensor operate relays ect when given temperature set points and display the changes on lcd display
Great video. Have you considered setting up Apache so you can go to a page to see a graph of recent history or have it send alerts to email/SMS?
Can you output the temp/humidity to a web page? would be great for my camper.. wanna use a couple rpi to monitor all systems
Can I use LCD w/ I2C modul so that only 2 wire goes to Raspberry?
It works!! I love the video and I am interested as to how you use the delays. If I am not mistaken you use delays so you can read the input at the right time, but how did you calculate the amount of time you need to delay?(GPIO pins are digital pins where as you need to read analog. The timing allows you to read like an analogPin would.)
Beautifully done :)
Excellent explanation. Thanks
I have a 3.2 inch Waveshare touch screen which uses 1-26 GPIO pins of the pi. How can I connect a DHT11 to it?
is it necessary to have an additional smaller breadboard for this project?
Is there any way to output those readings in some txt file or something?
so total noob question is there a way to hook up a second probe into this system and have it output its temp on the screen?
going to be setting this up for an octopi and setting this up in my garage/workshop and want one in the enclosure of my 3d printer and one outside and be able to see the difference in temperatures would be neat. I'm not great with code but can kind of read it so will just need to set up a second "deceleration"(i think) for the second probe. wiring the mess will be another project and getting it to look decent will be another and a half.
This is great. I hope you'll do more of these generic Chinese "Arduino" sensors.
+DancesWithRobots sure will, I've got tons of them :)
can you do this without using outty or ssh...
direct through raspbian?
What about to send reading of the temp and humidity through mail when its passes certain temperature.
Whenever I try to run it on ssh with Python it just comes up with the message:
Traceback (most recent call last):
File "temp.py", line 3, in
import Adafruit_DHT
ImportError: No module named Adafruit_DHT
I have installed all the files you mentioned in the video for Python but whenever I try to run it, it just has this message.
Thanks !! Very nice video !!
well what should i do if i want that data from python to pass thru on a html page?
How can I make it so that an RGB LED fades from green to red if the quality of the air is not into a certain range?
What kind of PI are you using model 3?
importError: no module named 'RPLCD' but I have installed it exactly as stated, i used pip. Please do help! :(
Where can I order the boards and connector wires?
What OS are you using?
Could you make video that the temp. & humidity data sent to IoT server like Thingspeak.com?
what if we use 1k ohm pull up resistor?
thank you so much, is there any way to export data through email and sms?
Are there otger models
besides the raspberryPI, that is cmopadible with this code&setup
I want to use it with I2c 16x2 lcd. How can i do it?
Can you do a tutorial on how to put the temp/humidity sensor on a BLE board outside and transfer data back to the Pi?
My LCD does not read temperature and humidity when I run the output LCD code as it is on the video. please I need help. I use C program
I cannot see get this to work on SSH let alone an LCD. It seems to be issues mostly with directories and libraries. I am using a raspberry 3 B +. Someone please let me know if there is an updated guide or a fix.
I moved Adafruit_DHT out of Adafruit_Python_DHT and now it recognises Adafruit_DHT when I try to run the program, but it just comes up with a load of stuff and the error is :
ImportError: cannot import name Raspberry_Pi_Driver
so I've tried to copy exactly what he did and i still get no results ive tried on two seperate lcds both light up but show no characters
i have a problem with python, it show me ImportError: cannot import name 'Raspberry_Pi_2_Driver'
Can you produce a video where the data for the weather is made to go over the internet as a webpage and use the Pi as a server?
how can I put this all in a chassis?
Thanks 👍👍great job
does dht22 works the same with the same code ?
make a video on automatic water level controller with LCD display measuring level . thank you in advance
I'm having issues with the code, I could use some help.
Good morning, Can the data be sent thru the ethernet port ?
Traceback (most recent call last):
File "main.py", line 9, in
print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature,humidity)
ValueError: Unknown format code 'f' for object of type 'str'
Please help
i can run the sensor only script but the sensor w/ lcd runs but doesn't display anything. Can anyone help?
THANK YOU SO MUCH! Quick question, is it possible to connect a small PC fan to the pi and have it turn on whenever the humidity hits above 69% for example? Also can a LED be programmed to turn on once the humidity goes below 62%?
beautiful, thank you !
pastor banner hallo, did you make that circuit and program? I will be happy if you share the code.
It gives me temp=None ans humdity also can you tell me please where is the problem ?
hi I have connected a pi camera to store the images to storage account it is storing perfectly with one of my wifi and it is not storing with other wifi or mobile hotspot what would be the problem Please try to help.application and azure storage account I don't have problem. the problem is with raspberry Pi.
DHT 11 Sensors use 5V and raspberry pi use 3.3V logic level. If I connect direct 5V Output Sensors with raspberry pi so it is safe to use.
Yes the DHT11 can directly be connected to a 5 Volt DC rail
Hi, I have a question.
Is it possible to connect more sensors (one outside/one inside) on the Raspberry ?
Reg, Ad.
up, I have the same question. Do we need extra sensor and which kind of sensor do we need, because to put one ouside and one inside we need some good connection.
I can't paste anything into Putty. :(
“Data not good, skip” for every line. Any idea on how to fix this? I tested the sensor with an Arduino and it works just fine, but it does not give an readings with Raspi.
wrong pin number? try to get your Pi pinout with command "python3 pinout" that you can install with "sudo apt install python3-gpiozero"
I'm at a loss to understand why my outdoor humidity/temp sensors continually report (all three of them) a +/- 50% lower RH than the RH reported by the Met Office and other official weather organisations. Maybe my devices are rubbish? But why do they all agree? Currently, my sensors report 44% RH, and this has remained consistent within +/- 10% over the past few days. Yet all official organisations' RH have been reporting 80-90% RH during the same period. What gives?
on my Pi it doesnt works
Is there a way to record the data?
casbro11 Yes, only write to the end of a file, or into a database.
HI, I am receiving the following error:
File "example.py", line 9, in
print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity)
ValueError: Unknown format code 'f' for object of type 'str'
Can you help what am I missing?
did you find any solution ?
same error, any help?
I had same issue also. I solved it by fixing the wirings of my dht11
Looks like that's Python3... the base code wasn't for 3.
Its indicate that your sensor data not read by raspberry pi.May be your sensor is damaged.Change sensor and try again.
Hello. Thanks for good video.
I tried this example in python but i got this following error.
File "example.py", line 9, in
print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity)
ValueError: Unknown format code 'f' for object of type 'str
anyone help?
Yes!
Is this tutorial suitable for rasbperry pi 4 ?
didnt work for me
I checked with the actual Pinout here components101.com/dht11-temperature-sensor seems to be different for the signal and Vcc
how can i set up 2 out of 1 pi?
the code is the trouble
Please help, it says Data not good, skip
me too :(
Ok you guys to fix the data no good, skip. Go into the code and change delaymicroseconds from a 1 to a 2 or 3. Then change at the very bottom where it says delay(1000) to delay(2000) or delay(3000) depending on what number you changed the other one to. This gives you some readings and a few bad data but hey it works
it didn't give anything other then date not good, skip. what's wrong with this
Problem not reading the sensor:
#!/usr/bin/python
import sys
import Adafruit_DHT
from RPLCD import CharLCD
from RPi import GPIO
lcd = CharLCD(numbering_mode=GPIO.BOARD, cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23])
while True:
humidity, temperature = Adafruit_DHT.read_retry(11, 4)
lcd.cursor_pos = (0, 0)
lcd.write_string("Temperature:%d C" % temperature)
lcd.cursor_pos = (1, 0)
lcd.write_string("Humidity :%d %%" % humidity)
>>> %Run TempHum.py
/usr/local/lib/python3.7/dist-packages/RPLCD/gpio.py:149: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(pin, GPIO.OUT)
Using Pi 4
Data not good, skip
Same problem!
Output with C "Data not good, skip", python just shows emptiness.
same issue with me. Is there any solution for this issue?
I just started using an arduino instead x) Now everything works as expected. I've learnt quite a bit in these past two months as well so maybe I could figure it out now but the Raspberry pi is now a dedicated ssh server and media center x)
Do these steps and it will work ! :)
www.raspberrypi.org/forums/viewtopic.php?f=33&t=7583
wiki.geany.org/howtos/configurebuildmenu
I figured it out in the end and also I've switched over to Arduino long ago x) I'll start toying around with the Raspberry pi again later sometime though :) Thank you for the response!
you're very welcome ! I actually just solved this problem few minutes ago. Now I have another problem "Data not good.Skip" now lets see how I can figure it out :)
Data not good, skip
Hey try changing the timings on your script.... It's 1 milliseconds....that is in the code... Change that to 2...it worked for me
me too :(
@@sudeephegde2924 , thank you ; it was for me also.you just safe my summer.
wiringPi no longer works
Why on earth do you run the editor as root with sudo?
The editing and compiling should be done as an ordinary user. Running the program as root is another thing.
But you should always avoid that too.
Before installing a packages, you should upgrade package database and update all installed programs.
sudo apt update; sudo apt upgrade
And you should not connect the devices with power connected. Never, as that make it easy to ruin the devices.