Hi
I'm trying to do a simple test with a DHT11(I know is a horrible sensor ) and struglling to make it work on a ATTiny(85 or 84).
The same simple code works fine on my Arduino Uno and I'm using the Arduino as an ISP. I've also uploaded the simple blink demo to the ATTiny85 and it works fine.
The code is like this:
#include <DHT11.h>
dht11 DHT11;
//int led = 13; //Arduino
int led = 3; //Attiny85
#define DHT11PIN 2
void setup()
{
 pinMode(led, OUTPUT);
}
void loop()
{
 int chk = DHT11.read(DHT11PIN);
 switch (chk)
 {
  case DHTLIB_OK:
   digitalWrite(led, HIGH);
   break;
  case DHTLIB_ERROR_CHECKSUM:
   break;
  case DHTLIB_ERROR_TIMEOUT:
   break;
  default:
   break;
 }
 delay(2000);
 digitalWrite(led, LOW);
 delay(2000);
}
The DHT11 used is the same. I just move the datapin between the two chips. Everything is powered from the the Arduino. I have a 5.k6 pullup on the DHT11 datapin.
When connecting my pocket scope i get this on the datapin on the Arduino: (sorry for the bad pictures, I don't have a working SD card for the Nano) see attached arduino.jpg
But on the Attiny the start on the data is not looking correctly. see attiny.jpg
There is nothing else connected. No serial. Just a LED with 1k resistor and the DHT11 with its pullup.
The LED that should flash when it has read the DHT successfull. I've cooked it down to isolate the problem.
I've tried to change the DHT pin to 0, 1 or 2 without any change.
btw. its running at internal 1MHz. Also tried internal 8MHz with same result
Just to check something on the connections. I know you were trying different ATtiny pins.
In the photo, it looks like the DHT11 sensor pin is connected to physical pin 6 of the ATtiny. That is digital pin 1. So you changed the #define in your program, versus the code posted?
that is correct. the picture was taken when trying pin 1
So the code that match this picture is:
#include <DHT11.h>
dht11 DHT11;
//int led = 13; //Arduino
int led = 3; //Attiny85
#define DHT11PIN 1
void setup()
{
 pinMode(led, OUTPUT);
}
void loop()
{
 int chk = DHT11.read(DHT11PIN);
 switch (chk)
 {
  case DHTLIB_OK:
   digitalWrite(led, HIGH);
   break;
  case DHTLIB_ERROR_CHECKSUM:
   break;
  case DHTLIB_ERROR_TIMEOUT:
   break;
  default:
   break;
 }
 delay(2000);
 digitalWrite(led, LOW);
 delay(2000);
}
It turns out that the CKDIV8 fuse is now set from the factory, so it was running at 1 MHZ all the time even if I changed it to 8MHz. So after unsetting that fuse the standard lib works fine.