Adafruit DHT Library and ATtiny85

Hello there to everyone who has experience,

I am trying to use Arduino-tiny for the first time. I did this so that I could use the Adafruit DHT11 sensor library. I have successfully implemented the example sketch on an Arduino Nano (mega328) However, when I connect the one-wire sensor to the ATtiny, it reads as zero. I know I have the pin right because when I disconnect the wire I get "Read failFailed to read from DHT". I am running at 8MHz internal oscillator.

Can someone look in the DHT library code read() function and see whether anything would run differently on an ATtiny?

Serial output:
Humidity: 0.00 % Temperature: 0.00 *C
Humidity: 0.00 % Temperature: 0.00 *C
Humidity: 0.00 % Temperature: 0.00 *C
Humidity: 0.00 % Temperature: 0.00 *C
Humidity: 0.00 % Temperature: 0.00 *C

Hello there to everyone who has experience,

What about the rest of us? No hello for us?

Can someone look in the DHT library code read() function and see whether anything would run differently on an ATtiny?

Nothing jumps out at me.

Give this one a try. It looks like the error trapping is more complete...
http://arduino.cc/playground/Main/DHT11Lib

If the timing is critical (which appears to be the case) the problem could be as simple as the uncalibrated internal oscillator.

Thanks for this suggestion. The new library works exactly like it should and has better error reporting like you said. I was able to create my nice ATtiny thermometer with seven-segment display.

This library works on Attiny 85 @8mhz and a DHT22 .
http://playground.arduino.cc/Main/DHTLib
you have to create manually the .h and .cpp as described at the end of the page.

//
//    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>
#include <SoftwareSerial.h>
dht DHT;

#define DHT22_PIN 0
#define rxPin 2
#define txPin 3
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
void setup()
{
  
    pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(9600);

  mySerial.println("DHT TEST PROGRAM ");
  mySerial.print("LIBRARY VERSION: ");
  mySerial.println(DHT_LIB_VERSION);
  mySerial.println();
  mySerial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}

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

  delay(1000);

}
//
// END OF FILE
//

Image.jpg

Thanks for testing the lib on the attiny85. I'll update the playground article that it works with attiny85
[done]

bodtx:
This library works on Attiny 85 @8mhz and a DHT22 .
Arduino Playground - DHTLib
you have to create manually the .h and .cpp as described at the end of the page.

//

//    FILE: dht_test.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.07
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
//     URL: Arduino Playground - DHTLib
//
// Released to the public domain
//

#include <dht.h>
#include <SoftwareSerial.h>
dht DHT;

#define DHT22_PIN 0
#define rxPin 2
#define txPin 3
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
void setup()
{
 
   pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);
 mySerial.begin(9600);

mySerial.println("DHT TEST PROGRAM ");
 mySerial.print("LIBRARY VERSION: ");
 mySerial.println(DHT_LIB_VERSION);
 mySerial.println();
 mySerial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}

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

delay(1000);

}
//
// END OF FILE
//

I am not able to run the library with Attiny, I give compilation error.

" Arduino:1.6.3 (Windows XP), Placa:"ATtiny, ATtiny85, 8 MHz (internal)"

In file included from dht_test.ino:1:0:

C:\Documents and Settings\R2Yum\Mis documentos\Arduino\libraries\dht_Attiny/dht.h:64:2: error: #endif without #if

#endif

^

In file included from dht_test.ino:13:0:

C:\Documents and Settings\R2Yum\Mis documentos\Arduino\libraries\dht_Attiny/dht.h:64:2: error: #endif without #if

#endif

^

"

^
I have arduino IDE 1.6.3

robtillaart:
Thanks for testing the lib on the attiny85. I'll update the playground article that it works with attiny85
[done]

The library also works well with Digispark USB attiny85 @16.5MHz, using IDE 1.6.5 and board defined with Board Manager. Tested on AM2301.

Hey guys so I know this is an old thread but I just thought I would post my own personal struggles with this subject and how i got it to work. So to start with I am using the high low tech attiny85 core and I wanted to get the dht22 to work on it. But it was not and I struggled with the code for days now. I am using the tillart dht22 library i think my version is 1.20 because I cant find a zip of any other version. But i could not get the code to work. it would compile and upload but nothing. Finally in desperation I removed my 10k pullup resistor! and then I got positive results. It was because my pullup resistor was too high!! So I thought I would post that here and let you guys know just in case someone else stubbles here and is frustrated like I was.