DHT22 doesn't work with Attiny85

Hi, I'm exasperated,
I literally browsed every site in this beautiful world to get a DHT22 to work on my Attiny85.
I really tried everything.
The problem is that I have tried to use SimpleDHT.h and when I read the values are all 0, but it does not say that the module is not working. The link (which can be changed) is DHT pin data -> pin 0 of the attiny85. I heard it might be clock problems, but currently attiny85 is running at 8mhz. The DHT22 module works on a normal arduino.
Code example I tried:

#include <SoftwareSerial.h>
#include <SimpleDHT.h>

SoftwareSerial HC12 (A1, 1);
SimpleDHT22 dht22(0);

void setup () {
  pinMode(A1, OUTPUT);
  HC12.begin(9600);
}

void loop(){
  byte tt = 0;
  byte hh = 0; 
  dht22.read(&tt, &hh, NULL);
  HC12.println(String(tt) + "'C " + String(hh) + "%");
  delay(4000);
}

I think a PIN 0 does not exist (DHT22(0)). So, depending on where the data pin of the DHT 22 is connected to the ATtiny, at least pin 1 should be used.

I don't know, is this a cause of your problem, but types of parameters that you use in function read() is wrong.
Please see the library's examples carefully.

I think it does exist and is indicated on the pinout you posted!

What Arduino core/board package did you use for tiny85?

How do you know that it is the DHT22 that is not working? Could it be that the serial link to the HC12 or the HC12 itself is not working?

OK... You're right. I got it mixed up with the five at PB0.

Nah all the modules works good, in an Arduino uno. I even tried the only module HC12 with only the Attiny85 and works.

The Core I use is the one with this link: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

I will do it now.

I tried this code (the example of the lib):

  float temperature = 0;
  float humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    HC12.print("Read DHT22 failed, err="); delay(1000); HC12.print(SimpleDHTErrCode(err)); delay(1000);
    HC12.print(","); delay(1000); HC12.println(SimpleDHTErrDuration(err)); delay(2000);
    return;
  }
  
  HC12.print("Sample OK: "); delay(1000);
  HC12.print((float)temperature); HC12.print(" *C, "); delay(1000);
  HC12.print((float)humidity); HC12.println(" RH%");

(Sending it to he other HC12)
and in enters in the If (so there is an error) and say:

Read DHT22 failed, err=16,255

Error 16 - SimpleDHTErrStartLow
Your sensor answers to request with incorrect timing, probably do not answers at all.
Check the wiring

There is a better one than that, in my opinion. It might be worth trying.

https://www.google.com/url?sa=t&source=web&rct=j&url=https://github.com/SpenceKonde/ATTinyCore&ved=2ahUKEwiM9fSiib35AhWUiVwKHTqjBoIQFnoECCAQAQ&usg=AOvVaw2CxVsgE56E_G6VCygC6h0c

It has software serial built-in on pins 0, 1 (I think... Page linked above says PB0, PA1 which is strange... @DrAzzy ?), so you will not need to include that as a separate library.

Could it be that the standard arduino library is so poorly written that it assumes 16 MHz? If you're running at 5v, try the PLL clock option. Or a better DHT library. Those things are not hard to write, and dozens (not counting forks) surely exist.

Meant to be PB0, PB1 - that's a typo that's fixed, but all development is going towards 2.0.0-dev branch, not master (please do report issues for any error, even a typo in 2.0.0-dev). But that''s something I get to once I get DxCore and megaTinyCore working, neither of which currently is in my dev version, and people want the DD's and I have a bag of DD14's on breakout boards that I'd love to sell... The wheels of those cores are FAR squeakier.

Plus, I need a new feature to efficiently do one of my own projects, running on a DB48, so it would help to be able to compile on that platform

Didn't you create a core for the attiny85? I could try your core. Maybe works?

I will try tomorrow.

Agreed 100%.

Do you mean PB5 at pin 1 on the chip?


This pin is available as a weak GPIO, but you need to set a certain fuse bit to use it (by default it is the RESET pin).

Hi im back,
I wanted try the Attiny core from DrAzzy but there are a lot of option, this configuration is good?:
image

I even tried using the library TinyDHT.h from adafruit, i changed the pin from 0 to 1, i even tried changing the clock of attiny85, but nothing... now im gonna try the DrAzzy Core

I FINALLY GOT IT WORK, i can't believe.
I Solved with this library: DHTlib - Arduino Reference
And this code: attiny85-ssd1306.ino - Wokwi Arduino and ESP32 Simulator

But i'm still interessed with the DrAzzy Core @DrAzzy .

Bookmarked to verify against ATTinyCore 2.0.0 and list on library page.

Has this code been verified working on actual hardware? (note: All I care about is if it can read the value from the DHT - displaying it with Serial.print() is sufficient for me to declare this library working and put (as the first entry anyone has submitted) at attinycore's supported librarys list.

Note that as I said, It doesn't count if not tested on hardware. Simulators lie. >50% of problems reported when testing in simulators are false positives