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
  • НаукаНаука

Комментарии • 98

  • @nicholasstaples4464
    @nicholasstaples4464 7 лет назад +1

    Dude. This explanation is awesome. Nothing extra. Helped me a bunch. Thanks for uploading. Subscribed.

  • @lettherebelightfixtures
    @lettherebelightfixtures 5 лет назад

    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.

  • @keithoakes2240
    @keithoakes2240 7 лет назад

    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..

  • @markdonadillo4099
    @markdonadillo4099 5 лет назад +1

    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?"

  • @carlmartin6435
    @carlmartin6435 7 лет назад +5

    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

  • @gnatsum64
    @gnatsum64 5 лет назад +11

    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?

  • @tornsoul82
    @tornsoul82 6 лет назад

    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

  • @romeosiera5188
    @romeosiera5188 6 лет назад +1

    Can I use LCD w/ I2C modul so that only 2 wire goes to Raspberry?

  • @victorverdun6573
    @victorverdun6573 8 лет назад

    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.)

  • @pioneercolonel
    @pioneercolonel 7 лет назад +1

    Beautifully done :)

  • @YousefElarian
    @YousefElarian 7 лет назад

    Excellent explanation. Thanks

  • @hashroot3732
    @hashroot3732 7 лет назад

    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?

  • @TheAndroiD619
    @TheAndroiD619 4 года назад

    is it necessary to have an additional smaller breadboard for this project?

  • @vinsan98
    @vinsan98 6 лет назад

    Is there any way to output those readings in some txt file or something?

  • @center4nerds
    @center4nerds 3 года назад

    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.

  • @DancesWithRobots
    @DancesWithRobots 8 лет назад +5

    This is great. I hope you'll do more of these generic Chinese "Arduino" sensors.

    • @Circuitbasics
      @Circuitbasics  8 лет назад +4

      +DancesWithRobots sure will, I've got tons of them :)

  • @weinstienm.d.3826
    @weinstienm.d.3826 5 лет назад

    can you do this without using outty or ssh...
    direct through raspbian?

  • @Sathish_90
    @Sathish_90 6 лет назад

    What about to send reading of the temp and humidity through mail when its passes certain temperature.

  • @camhart3217
    @camhart3217 8 лет назад

    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.

  • @donaldfilbert4832
    @donaldfilbert4832 8 лет назад +6

    Thanks !! Very nice video !!

  • @LtMewS
    @LtMewS 5 лет назад

    well what should i do if i want that data from python to pass thru on a html page?

  • @TommyThousandFaces
    @TommyThousandFaces 7 лет назад

    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?

  • @jessend4259
    @jessend4259 6 лет назад

    What kind of PI are you using model 3?

  • @monkeith5705
    @monkeith5705 6 лет назад

    importError: no module named 'RPLCD' but I have installed it exactly as stated, i used pip. Please do help! :(

  • @BryanSpear
    @BryanSpear 6 лет назад

    Where can I order the boards and connector wires?

  • @romeosiera5188
    @romeosiera5188 6 лет назад

    What OS are you using?
    Could you make video that the temp. & humidity data sent to IoT server like Thingspeak.com?

  • @hosyrm
    @hosyrm 6 лет назад +1

    what if we use 1k ohm pull up resistor?

  • @WYCF80
    @WYCF80 6 лет назад

    thank you so much, is there any way to export data through email and sms?

  • @DeniseSkinner68DeniseSkinner68
    @DeniseSkinner68DeniseSkinner68 2 месяца назад

    Are there otger models
    besides the raspberryPI, that is cmopadible with this code&setup

  • @saiderten4537
    @saiderten4537 7 лет назад

    I want to use it with I2c 16x2 lcd. How can i do it?

  • @MrPaulviles
    @MrPaulviles 7 лет назад +1

    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?

  • @patricklaakak9458
    @patricklaakak9458 3 года назад

    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

  • @user-hz8yn6xz4o
    @user-hz8yn6xz4o 8 месяцев назад

    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.

  • @camhart3217
    @camhart3217 8 лет назад

    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

  • @saebastioncole1307
    @saebastioncole1307 5 лет назад

    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

  • @dinoramartinezsaenz9436
    @dinoramartinezsaenz9436 7 лет назад +1

    i have a problem with python, it show me ImportError: cannot import name 'Raspberry_Pi_2_Driver'

  • @WHNorthcote
    @WHNorthcote 8 лет назад +1

    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?

  • @StephenPhillips
    @StephenPhillips 5 лет назад

    how can I put this all in a chassis?

  • @horreurdesup7174
    @horreurdesup7174 5 лет назад

    Thanks 👍👍great job

  • @raul5024
    @raul5024 4 года назад

    does dht22 works the same with the same code ?

  • @madhukeshnp
    @madhukeshnp 7 лет назад +2

    make a video on automatic water level controller with LCD display measuring level . thank you in advance

  • @ikeman828
    @ikeman828 5 лет назад

    I'm having issues with the code, I could use some help.

  • @armandovalladares3879
    @armandovalladares3879 6 лет назад

    Good morning, Can the data be sent thru the ethernet port ?

  • @TabletopPants29
    @TabletopPants29 3 года назад

    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

  • @IamG3X
    @IamG3X 4 года назад

    i can run the sensor only script but the sensor w/ lcd runs but doesn't display anything. Can anyone help?

  • @dicso0
    @dicso0 7 лет назад +1

    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%?

    • @dicso0
      @dicso0 7 лет назад

      beautiful, thank you !

    • @SaeedAhmed-ix8nm
      @SaeedAhmed-ix8nm 6 лет назад

      pastor banner hallo, did you make that circuit and program? I will be happy if you share the code.

  • @redhasteve6739
    @redhasteve6739 5 лет назад

    It gives me temp=None ans humdity also can you tell me please where is the problem ?

  • @Techfacts_Vinod_Telugu
    @Techfacts_Vinod_Telugu 3 года назад

    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.

  • @GreatNerve
    @GreatNerve 5 лет назад +1

    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.

    • @JoshiNirdeshak
      @JoshiNirdeshak 4 года назад

      Yes the DHT11 can directly be connected to a 5 Volt DC rail

  • @degrootadrianus
    @degrootadrianus 4 года назад +1

    Hi, I have a question.
    Is it possible to connect more sensors (one outside/one inside) on the Raspberry ?
    Reg, Ad.

    • @FatahMusicWorld
      @FatahMusicWorld 4 года назад

      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.

  • @lukasz9653
    @lukasz9653 7 лет назад

    I can't paste anything into Putty. :(

  • @Bullsnation6
    @Bullsnation6 4 года назад +2

    “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.

    • @Speedi1103
      @Speedi1103 3 года назад +1

      wrong pin number? try to get your Pi pinout with command "python3 pinout" that you can install with "sudo apt install python3-gpiozero"

  • @AntPDC
    @AntPDC 5 лет назад

    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?

  • @mariannise6144
    @mariannise6144 6 лет назад +1

    on my Pi it doesnt works

  • @casbro11
    @casbro11 7 лет назад +1

    Is there a way to record the data?

    • @AndersJackson
      @AndersJackson 6 лет назад

      casbro11 Yes, only write to the end of a file, or into a database.

  • @saimullangi6438
    @saimullangi6438 7 лет назад +3

    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?

    • @ivanalex2382
      @ivanalex2382 6 лет назад

      did you find any solution ?

    • @RadimBures
      @RadimBures 6 лет назад

      same error, any help?

    • @monkeith5705
      @monkeith5705 6 лет назад

      I had same issue also. I solved it by fixing the wirings of my dht11

    • @ryanjcole
      @ryanjcole 6 лет назад +1

      Looks like that's Python3... the base code wasn't for 3.

    • @amrutiyameet9035
      @amrutiyameet9035 5 лет назад

      Its indicate that your sensor data not read by raspberry pi.May be your sensor is damaged.Change sensor and try again.

  • @jihyelim1471
    @jihyelim1471 6 лет назад

    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

  • @Major7Sharp5
    @Major7Sharp5 4 года назад

    Yes!

  • @daylenmejlak3753
    @daylenmejlak3753 4 года назад

    Is this tutorial suitable for rasbperry pi 4 ?

    • @bkyuksel
      @bkyuksel 3 года назад

      didnt work for me

  • @razalihusainc7724
    @razalihusainc7724 3 года назад

    I checked with the actual Pinout here components101.com/dht11-temperature-sensor seems to be different for the signal and Vcc

  • @MrLyons-jk1vo
    @MrLyons-jk1vo Год назад

    how can i set up 2 out of 1 pi?

  • @HighFidelityFox
    @HighFidelityFox 6 лет назад +1

    Please help, it says Data not good, skip

  • @ShinYaYeFoWa
    @ShinYaYeFoWa 5 лет назад

    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

    • @IamG3X
      @IamG3X 4 года назад

      it didn't give anything other then date not good, skip. what's wrong with this

  • @pierrekoster2480
    @pierrekoster2480 4 года назад

    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)

  • @odinseye5901
    @odinseye5901 7 лет назад +1

    Data not good, skip
    Same problem!

  • @nautitard
    @nautitard 7 лет назад +1

    Output with C "Data not good, skip", python just shows emptiness.

    • @ronilluminati
      @ronilluminati 7 лет назад

      same issue with me. Is there any solution for this issue?

    • @nautitard
      @nautitard 7 лет назад

      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)

    • @majoradam6641
      @majoradam6641 7 лет назад +1

      Do these steps and it will work ! :)
      www.raspberrypi.org/forums/viewtopic.php?f=33&t=7583
      wiki.geany.org/howtos/configurebuildmenu

    • @nautitard
      @nautitard 7 лет назад +1

      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!

    • @majoradam6641
      @majoradam6641 7 лет назад

      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 :)

  • @zahirtushar7278
    @zahirtushar7278 7 лет назад +4

    Data not good, skip

    • @sudeephegde2924
      @sudeephegde2924 5 лет назад +2

      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

    • @redabousserhane1998
      @redabousserhane1998 5 лет назад

      me too :(

    • @patricklaakak9458
      @patricklaakak9458 3 года назад

      @@sudeephegde2924 , thank you ; it was for me also.you just safe my summer.

  • @andyroo_
    @andyroo_ Год назад

    wiringPi no longer works

  • @AndersJackson
    @AndersJackson 6 лет назад

    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.