DHT22 temp & humidity not reading correctly

I'm using an breadboard Attiny85 & software serial to experiment with a DHT22 temp and humidity sensor with a 10k resistor between pin 1 Vcc(5v) and pin 2 data, with pin 4 tied to GND (I've also tried it with pin 3 also tied to GND). I'm using the adafruit DHT library, and the following code.

#include "SoftwareSerial.h"
#include "DHT.h"


#define DHT22PIN 0 //DHT is on pin 0 (pinout 5)
#define DHTTYPE DHT22

DHT dht(DHT22PIN,DHTTYPE); // pin 0 (pinout 5) DHT22
SoftwareSerial TinySerial(3, 4); // RX, TX pinout g2,y3


void setup()  
{
  // Open serial communications and let us know we are connected
  TinySerial.begin(9600);
  TinySerial.println("Tiny Serial Connected via SoftwareSerial Library");
  dht.begin();
  delay(1000); //delay so I can give myself time to think

}

void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  delay(250);  //delay to give sensor time to read
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {
  
  TinySerial.print("\n");
  TinySerial.print("Received data...");
  TinySerial.print("\n");
  TinySerial.print("Humidity: ");
  TinySerial.print(h);
  TinySerial.println(" %\t");
  TinySerial.print("Temperature: ");
  TinySerial.print(t);
  TinySerial.println(" *C");
  TinySerial.println("Next reading in 5 seconds");
  delay(5000);
  }





}

The output I'm receiving on the serial monitor is as follows:

Tiny Serial Connected via SoftwareSerial Library

Received data...
Humidity: 32.80 %
Temperature: 0.40 *C
Next reading in 5 seconds

Received data...
Humidity: 40.20 %
Temperature: 0.80 *C
Next reading in 5 seconds

Received data...
Humidity: 33.60 %
Temperature: 0.40 *C
Next reading in 5 seconds

Received data...
Humidity: 16.00 %
Temperature: 12.80 *C
Next reading in 5 seconds

Occasionally, the humidity or the temperature will be in the expected ranges. I've tried using different pins for the inputs and outputs and get the same response. Similar code worked for a DHT11, but my requirements for temp are below 0 celsius. Any hints on what might be my issue? Thanks in advance for any possible help.

AFAIK is there a special lib for the DHT22 (like for the DHT11) - did you tried another one already ?

I've downloaded Robs latest library, and I'll be giving my new code a try. I'll update this when I have more info.

the resistor might be a 4K7 for some sharper edges :slight_smile:

The new library works (I used a slightly modified example sketch).

Rob, you're a god among men. A.R.Ty, you're not quite a god, but thank you.