Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. DHT11 and Atmega 8MHz

DHT11 and Atmega 8MHz

Scheduled Pinned Locked Moved Troubleshooting
11 Posts 7 Posters 8.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thibthib02
    wrote on last edited by
    #1

    Hello everybody,

    I have trouble with DHT11 on Atmega328 3.3V 8MHz. I use the Humidity sketch and I have a lot of reading error.

    When I try the exemple sketch included in Arduino IDE, everything is ok, no error during 5 hours.

    With the humidity sketch, I have an error every 5 or 7 readings. Maybe an error in the library with timing communication with DHT11??

    Anybody can help me??

    Thank you in advance.

    1 Reply Last reply
    0
    • MagiskeM Offline
      MagiskeM Offline
      Magiske
      wrote on last edited by Magiske
      #2

      How often do you read from the DHT11, might not be an issue. But think you need to wait 1-2 sec pr. poll. (Depending on DHT11/22)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thibthib02
        wrote on last edited by
        #3

        The sleeping time is 30 seconds.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sharath krishna
          wrote on last edited by
          #4

          @Thibthib02 Modify the arduino ide example sketch to work with mysensors and try it .

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Thibthib02
            wrote on last edited by
            #5

            The example sketch is too complicated to modify to work with mysensors. Nobody here use the Humidity sketch with arduino @ 8MHz?

            1 Reply Last reply
            0
            • hekH Offline
              hekH Offline
              hek
              Admin
              wrote on last edited by
              #6

              This DHT library claim to handle 8Mhz:
              https://github.com/Seeed-Studio/Grove_Temperature_And_Humidity_Sensor/tree/master/Humidity_Temperature_Sensor

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Did you try what they suggest here:
                http://forums.adafruit.com/viewtopic.php?f=19&t=46863
                This is for the DHT22, but maybe it relates to the DHT11? They also use a different library I think, but you could integrate that easily, I suppose.

                1 Reply Last reply
                0
                • TotcheT Offline
                  TotcheT Offline
                  Totche
                  wrote on last edited by Totche
                  #8

                  I use this one => Adafruit

                  #include <DHT.h>
                  
                  #define HYGRO_PIN 4         // Pin DHT11
                  
                  DHT dht(HYGRO_PIN, HYGRO_TYPE);
                  
                  float hygrometrie_mem; 
                  float hygro_temp_mem;  
                  
                  // hygrometrie
                  MyMessage msg_hygro(HYGROMETRIE_CHILD, V_HUM);
                  
                   float hygro_temp = dht.readTemperature();
                   float hygrometrie = dht.readHumidity();
                   // isnan => Is Not A Number
                   if (isnan(hygro_temp) || isnan(hygrometrie))
                   {
                      Serial.println("Echec lecture du DHT");
                   } 
                   else if (hygro_temp != hygro_temp_mem) 
                   {
                     hygro_temp_mem = hygro_temp;
                   }
                  
                    Serial.print("Temperature hygro : ");
                    Serial.print(hygro_temp);
                    Serial.println('C');
                    if (hygrometrie != hygrometrie_mem) 
                    {
                      hygrometrie_mem = hygrometrie;
                      gw.send(msg_hygro.set(hygrometrie, 1));
                      Serial.print("Hygrometrie : ");
                      Serial.print(hygrometrie);
                      Serial.println('%');
                    }
                  
                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Andreas Maurer
                    wrote on last edited by
                    #9

                    Hi,

                    no problem at all. The humidity scetch is running fine with a pure atmega328p-pu and a DHT11.

                    I have build it on a breadboard for you to see if it is working:

                    IMG_1213.JPG

                    As you see, the sensor starts and sends temperature and humidity value:

                    sensor started, id 99
                    send: 99-99-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
                    send: 99-99-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                    read: 0-0-99 s=255,c=3,t=6,pt=0,l=2:M
                    
                    send: 99-99-0-0 s=255,c=3,t=11,pt=0,l=8,st=ok:Humidity
                    send: 99-99-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
                    send: 99-99-0-0 s=0,c=0,t=7,pt=0,l=5,st=ok:1.4.1
                    read: 99-1-0 s=0,c=0,t=7,pt=0,l=5:1.4.1
                    send: 99-99-0-0 s=1,c=0,t=6,pt=0,l=5,st=ok:1.4.1
                    read: 99-1-0 s=1,c=0,t=6,pt=0,l=5:1.4.1
                    send: 99-99-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:62
                    read: 99-1-0 s=255,c=3,t=0,pt=1,l=1:62
                    

                    Normally I am using a DHT22 on my selfmade board.
                    IMG_1185.JPG

                    Andreas

                    MagiskeM 1 Reply Last reply
                    1
                    • T Offline
                      T Offline
                      Thibthib02
                      wrote on last edited by
                      #10

                      Maybe a bad DHT11. I will more investigate tomorrow. Thank you guys.

                      1 Reply Last reply
                      0
                      • A Andreas Maurer

                        Hi,

                        no problem at all. The humidity scetch is running fine with a pure atmega328p-pu and a DHT11.

                        I have build it on a breadboard for you to see if it is working:

                        IMG_1213.JPG

                        As you see, the sensor starts and sends temperature and humidity value:

                        sensor started, id 99
                        send: 99-99-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
                        send: 99-99-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                        read: 0-0-99 s=255,c=3,t=6,pt=0,l=2:M
                        
                        send: 99-99-0-0 s=255,c=3,t=11,pt=0,l=8,st=ok:Humidity
                        send: 99-99-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
                        send: 99-99-0-0 s=0,c=0,t=7,pt=0,l=5,st=ok:1.4.1
                        read: 99-1-0 s=0,c=0,t=7,pt=0,l=5:1.4.1
                        send: 99-99-0-0 s=1,c=0,t=6,pt=0,l=5,st=ok:1.4.1
                        read: 99-1-0 s=1,c=0,t=6,pt=0,l=5:1.4.1
                        send: 99-99-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:62
                        read: 99-1-0 s=255,c=3,t=0,pt=1,l=1:62
                        

                        Normally I am using a DHT22 on my selfmade board.
                        IMG_1185.JPG

                        Andreas

                        MagiskeM Offline
                        MagiskeM Offline
                        Magiske
                        wrote on last edited by
                        #11

                        @Andreas-Maurer Nice looking board!!

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        12

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular