DHT11 and Atmega 8MHz



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



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



  • The sleeping time is 30 seconds.



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



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


  • Admin



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



  • 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('%');
      }
    


  • 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



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



  • @Andreas-Maurer Nice looking board!!


Log in to reply
 

432
Online

6.9k
Users

7.8k
Topics

82.6k
Posts

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.