Go Down

Topic: Class for DHT11, DHT21 and DHT22 (temperature & humidity) (Read 184913 times) previous topic - next topic

joergsh

Hello,
at first many thanks for this great lib.

I tested it on a pro mini with 3,3v and 16MHz and it works fine.

For safety work i bought some 3,3V 8 MHz boards but run in trouble with the 8 MHz.

Could You please help me to make it work with please :)  I choose the right board, serial and one wire sensors works fine.

So could I make changes to make it run with 8MHz 328p?

Thanks in advance and regards

Joerg

robtillaart


Code: [Select]
[code] but run in trouble with the 8 MHz.[/code]
Can you explain the kind of trouble you have?
What output did your sketch generate?
(Please post it here for others reference - I know you mailed it to me)

Have you tried to run the examples?

You mailed me you renamed the lib because of a name conflict, please can you move the other lib from the libraries folder and use the original name.




Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

joergsh

ok for better verification I build a simple sketch based on yours:
Code: [Select]

//
//    FILE: dht_test.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.07
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
//     URL: http://arduino.cc/playground/Main/DHTLib
//
// Released to the public domain
//

#include <dht.h>

dht DHT;

#define DHT22_PIN 2

void setup()
{
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT_LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}

void loop()
{
  // READ DATA
  Serial.print("DHT22, \t");
  int chk = DHT.read22(DHT22_PIN);
  switch (chk)
  {
    case DHTLIB_OK: 
Serial.print("OK,\t");
break;
    case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
    case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
    default:
Serial.print("Unknown error,\t");
break;
  }
  // DISPLAY DATA
  Serial.print(DHT.humidity, 1);
  Serial.print(",\t");
  Serial.println(DHT.temperature, 1);

  delay(1000);



}
//
// END OF FILE
//



Output is:

Quote

Read sensor: Time out error<\r>
<\n>Humidity (%): 0.00<\r>
<\n>Temperature (??C): 0.00<\r>
<\n>Temperature (??F): 32.00<\r>
<\n>Temperature (??K): 273.15<\r>
<\n>Dew Point (??C): nan<\r>
<\n>Dew PointFast (??C): nan<\r>






robtillaart

do you have a pull up resistor (4K7 or 10K) on the dataline?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

joergsh

I have 4k7 on data line and it works fine with a pro mini with 16 MHz



bevangg

#82
May 04, 2014, 07:13 pm Last Edit: May 04, 2014, 07:15 pm by bevangg Reason: 1
Sorry no, using nano @16mhz, was getting odd / erroneous readings from dht11, 10k pullup and it works

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

bevangg

#84
May 05, 2014, 09:47 pm Last Edit: May 05, 2014, 10:50 pm by bevangg Reason: 1
Hi see attached images (right click and view in new tab, they are too big for the forum viewer), the DHT11 is on a prototyping board and is wired using very short connections. I have not got around to trimming the resistor pins and probably won't bother as it is a prototype at this stage. Since putting the 10k pull-up resistor on it readings have  been consistently accurate (95% as a guess) and not wildly variant as it was before ie temperature showing 120 centigrade. The nano can't adequately supply so many relays and sensors when connected over usb hence the power supply module as the voltage drops to 3.7 which is not enough for the 433mhz receiver to function. The DHT11 does not seem to be affected by the voltage at all. All parts were bought at banggood.com, cheap, quality and fast delivery (relatively by chinese standards). The whole lot in the shots including the nano cost £12.50. The relays can be controlled by the sensors, the rtc  or over the internet using lightwaverf.

robtillaart

With 4 relay's you definitely need an additional power supply!  in fact even with one you need to have it.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Reavstone


robtillaart

some explanations - http://playground.arduino.cc/Main/DHTLib -
latest code - https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Reavstone

I was reading that but I dont seem to find the "download link" for the library, normally on the other libraries I have, I downloaded them.
can you please help me?
What to I need to do in order to have this library?

robtillaart

There is one download link for all my libraries on github (up a few levels)
Better learn to work with git to keep up to date with the latest versiob

Or find attached the DHT part only 1.0.9 version.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up