DHT22 and ATtiny85 problem

Ok hi guys i need help.
When I have connected DHT22 on arduino all is workink fine…
But when i convert program from arduino to ATtiny 85 It’s not working It’s just doing True cycle seems like ATtiny is not reading temperatue. I tried change libraly did’nt help me.
For programming ATtiny i used 8MHz internal clock.
And I have arduino mega 2560.

#include <DHT22.h>

#include <stdio.h>

#define DHT22_PIN 0

// Setup a DHT22 instance
DHT22 myDHT22(DHT22_PIN);

int vn=1;

void setup() {

pinMode(1,OUTPUT);

}

void loop() {
// Wait a few seconds between measurements.
delay(2000);

float h = myDHT22.getHumidity();

float t = myDHT22.getTemperatureC();

if(myDHT22.getTemperatureC()<10)
{

digitalWrite(1,HIGH);
delay(100);
digitalWrite(1,LOW);
delay(100);
}
else
{
delay(2000000);
}

}

You didn’t supply the link to the DHT library you used. There are at least half a dozen libraries for the sensor, so that link is relevant. Many of the libraries work only with the 16MHz version of a Arduino because the use a special timing.

http://www.fast-files.com/getfile.aspx?file=133674

Ok now i used this library there is said

DHT dht(DHTPIN, DHTTYPE); // NOTE: For working with a faster chip, like an Arduino Due or Teensy, you // might need to increase the threshold for cycle counts considered a 1 or 0. // You can do this by passing a 3rd parameter for this threshold. It's a bit // of fiddling to find the right value, but in general the faster the CPU the // higher the value. The default for a 16mhz AVR is a value of 6. For an // Arduino Due that runs at 84mhz a value of 30 works.

So I set DHTTYPE to 3 and problem of sensor is fixed but new problem. And that happens when i conect to pin 1 LED (for test it) its working fine BUT the pin is generating only 1.7V.. :(

Ok I finnaly fixed it Big thank you for help :) :)

How?

#3
hi.
i want control 2 output pin Proportional to temperature and humidity (sensor sht22 - ATtiny13 micro)

i write this program. in arduino uno its ok…but after program .hex to attiny13 dont work.

i use this lib(optiboot/README.md at master · sleemanj/optiboot · GitHub) for add ATtiny 13 to arduino board manager.

whats problem?
(dont add any dht lib to this program.)
thanks.

const uint8_t pin = 2; // 7
const uint8_t PinPotTemp = A2; // 3
const uint8_t PinPotHum = A3; // 2
const uint8_t OutTemp = 0; // 5
const uint8_t OutHum = 1; // 6

#define DHT_CYCLES microsecondsToClockCycles(200)
#define TOLERANCE_CELSIUS 10
#define TOLERANCE_HUMIDITY 10

void setup() {
pinMode(OutTemp, OUTPUT);
pinMode(OutHum, OUTPUT);
}

void loop() {
uint8_t data[5] = {0, 0, 0, 0, 0};

pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
pulseIn(pin, HIGH, 1000);
digitalWrite(pin, HIGH);
pinMode(pin, INPUT);

if (pulseIn(pin, HIGH, 300)) {

for (uint8_t i = 0; i < 40; i++)
data[i / 8] += data[i / 8] + (pulse(LOW) > pulse(HIGH));

if (data[4] == uint8_t(data[0] + data[1] + data[2] + data[3])) {

int16_t celsius = (uint16_t((data[2] & 0x7F) << 8) | data[3]) * ((data[2] & 0x80) ? -1 : 1);
uint16_t humidity = (uint16_t(data[0] << 8) | data[1]);

int16_t PtnTemp = map(analogRead(PinPotTemp), 0, 1023, -400, 800);

if ((PtnTemp + TOLERANCE_CELSIUS) < celsius)
digitalWrite(OutTemp, HIGH);
else if ((PtnTemp - TOLERANCE_CELSIUS) > celsius)
digitalWrite(OutTemp, LOW);

uint8_t PtnHum = map(analogRead(PinPotHum), 0, 1023, 0, 1000);

if ((PtnHum + TOLERANCE_HUMIDITY) < humidity)
digitalWrite(OutHum, HIGH);
else if ((PtnHum - TOLERANCE_HUMIDITY) > humidity)
digitalWrite(OutHum, LOW);
}
}
//delay(2000);
}

uint16_t pulse( bool state)
{
uint16_t cycle = DHT_CYCLES;
while ((digitalRead(pin) == state) && cycle–);
return cycle;
}