Jump to content
43oh

[Energia Library] DHT11 / DHT22 Temperature and Humidity Sensors


Recommended Posts

  • A library for reading dht sensors (temperature and humidity).
  • Since dht sensors are pretty slow, I have used highlevel functions in the lib, there should be plenty of cycles even at 1MHz, but I have only tested it on the CC3200 sofar.

Easy example, other functions are available for getting the raw values instead of float.

  if (dht::readFloatData(2, &temperature, &humidity, true) == 0)
  {
    Serial.print("T: ");
    Serial.print(temperature);
    Serial.print(" H: ");
    Serial.println(humidity);    
  }  
  

Zip file included, source code lives at https://github.com/MORA99/Stokerbot/tree/master/Libraries/dht

 

Note: This lib requires working micros, delayMicroseconds and pulseIn functions, if you are using it on CC3200 you may need to patch your Energia installation.

dht.zip

Link to post
Share on other sites

Hi MORA99 , I have tried your DHT lib with a DHT22 on a CC3200 and it is not functioning . After reading one more time your post here, I noticed the small letters note, where you say:   "This lib requires working micros, delayMicroseconds and pulseIn" 

What do you mean with this note ? What modifications are needed to make it function ?

Thanks in advance 

Link to post
Share on other sites

Hi MORA99 , I have tried your DHT lib with a DHT22 on a CC3200 and it is not functioning . After reading one more time your post here, I noticed the small letters note, where you say:   "This lib requires working micros, delayMicroseconds and pulseIn" 

What do you mean with this note ? What modifications are needed to make it function ?

Thanks in advance 

It means you are supposed to have a sketch framework (Energia or CCS sketch) running, and have not tampered with either of these functions.

He also states that for the CC3200 you may have to get things working, I suppose they're not working out of the box with Energia...

Link to post
Share on other sites
  • 2 weeks later...

Note for future, the current Energia release mentioned above is release 13.

 

Link to similar library: There is another DHT22 library, targeted at the MSP430.

 

http://forum.43oh.com/topic/2865-energia-library-dht22-temp-rh-one-wire-sensor/

 

There have been some efforts to adapt it to the Stellaris LP.

http://forum.43oh.com/topic/2239-solved-dht22-temp-rh-one-wire-sensor-on-energia/page-3

Link to post
Share on other sites
  • 1 month later...

anyone noticed that with version 13 the sample libraries for DHT11, which perfectly worked with version 12, doesn't work anymore with 13? talking about the samples for arduino from DFrobot wiki page ...

 

the project is verified, downloaded, but the values from the sensors are something strange. 

 

I tried again with version 12 and it is working good.

 

didn't go in the details why, but something changed with version 13.

 

regards

Link to post
Share on other sites

anyone noticed that with version 13 the sample libraries for DHT11, which perfectly worked with version 12, doesn't work anymore with 13? talking about the samples for arduino from DFrobot wiki page ...

 

the project is verified, downloaded, but the values from the sensors are something strange. 

 

I tried again with version 12 and it is working good.

 

didn't go in the details why, but something changed with version 13.

 

regards

 

Would help to mention what platform you are using (MSP430, Tiva, C2k) - obviously not the CC3200, since not supported in 12.

 

(On Tiva would think that the problems with the Energia delay routines might be an issue, and would suggest using the patch.  However that would also be true of version 12.)

Link to post
Share on other sites
  • 4 weeks later...

hi,

i am using the library which is  posted above.since u mentioned energia version 12 i downloaded that.but the problem is i don't see anything in my serial monitor window.i tried with both version 13 and verison 12 of energia but nothing worked out for me.you did not mention any pin numbers.can you help my telling me  what changes i need to do so that it  works on any of the port.for example  can know how i can change it to read data from pin 1.7(port 1 pin 7).

 

Thank you

 

ps:i am a newbie to energia so my questions seems weird.i am sorry for that.

Link to post
Share on other sites
  • 2 weeks later...

So, time has gone by bugs have been fixed and I was trying the DHT code with my CC3200 and DHT11. 

Energia Version 0101E0014 and I'm not able to get the sensor to work.

 

It seems to work ok with the DHT11 if you change true to false.

static int8_t readFloatData(unsigned char pin, float *temperature, float *humidity, boolean dht22);

 

The true/false is to set if the sensor is a dht11 or dht22, so thats intended.

The main difference is precision and the dht11 requires a bit more delay.

Link to post
Share on other sites
  • 4 weeks later...
  • 1 month later...

 

  • A library for reading dht sensors (temperature and humidity).
  • Since dht sensors are pretty slow, I have used highlevel functions in the lib, there should be plenty of cycles even at 1MHz, but I have only tested it on the CC3200 sofar.

Easy example, other functions are available for getting the raw values instead of float.

  if (dht::readFloatData(2, &temperature, &humidity, true) == 0)
  {
    Serial.print("T: ");
    Serial.print(temperature);
    Serial.print(" H: ");
    Serial.println(humidity);    
  }  
  

Zip file included, source code lives at https://github.com/MORA99/Stokerbot/tree/master/Libraries/dht

 

Note: This lib requires working micros, delayMicroseconds and pulseIn functions, if you are using it on CC3200 you may need to patch your Energia installation.

 

 

Hello, Mora. I tried your library and found that code does not works properly all the time.

 

After system was powered up, few readings is OK and after that readFloatData() and readRawData() returns error (on my MSP430G2553 Launch pad).

 

I fixed this problem and also added two classes which buffers data from DHT22 and saves them in the internal memory. So, when you want get data faster than 1 time per 2 seconds (for DHT22) data will be returned from internal memory.

 

How can I send this fixes to you? Do you want them?

Link to post
Share on other sites

Very nice, I noticed that I get quite a few errors on dht in my project, but I sleep the chip alot so didnt investigate it much.

 

You can send the changes to me (jkn@air-port.dk) by mail if you like, and I will update the github/lib.

 

Hello. I sent you all data. Please, tell me if you like it :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...