DHT22 on OLED

Hello,
I'm trying to use a Wemos D1 mini with an OLED shield to display temperature and humidity from a DHT22 sensor. My code will not work, but I'm not getting any errors. You'll notice that hum, temp, and temp_f are commented out. If I don't have them all commented out, the screen goes black after clearing the "Temp/Hum" opening text (even if only one is left on).

With this code, I have "Temp: 0.00F Hum:0.00%" displaying.

I've looked through a lot of examples, and I can't figure out what I'm doing wrong. Any help would be appreciated.

Thanks


#include <DHT.h>
#include <DHT_U.h>

#include <SPI.h>

#include <Wire.h>

#include <Adafruit_SSD1306.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#define OLED_RESET 0
Adafruit_SSD1306 display(OLED_RESET);

#define DHTPIN D4 //Need to find the correct pin numbers for this part
#define DHTTYPE DHT22
DHT dht (DHTPIN, DHTTYPE);

int chk;
float hum;
float temp;
float temp_f;

void setup() {
Serial.begin (9600);

display.begin (SSD1306_SWITCHCAPVCC, 0x3C); //HEX address may need changed to specific for screen

display.display ();
delay(2000);

display.clearDisplay ();

display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,10);
display.println("Temp");
display.println("Hum");

display.display();
delay (1000);
display.clearDisplay();
display.display();

}

void loop() {
// put your main code here, to run repeatedly:

//hum = dht.readHumidity();
//temp = dht.readTemperature();
//temp_f = (temp*9)/5+32;

display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,10);
display.println("Temp:");
display.print (temp_f);
display.print (" ");
display.print("F");

display.setCursor (0,30);
display.println("Hum:");
display.print(hum);
display.print (" ");
display.print("%");

display.display();

delay (1000);

display.clearDisplay();
display.display();
}

You might consider using a pin other than 0 for OLED_RESET.

I'm trying to use a Wemos D1 mini with an OLED shield

For which you have provided no links.

The fact that you CAN write to the display when the use of the DHT instance, tied to pin D4, is commented out suggests that the OLED shield is using pin D4.

I'm unable to find any information on the OLED shield i'm using. I purchased it from aliexpress.

I've tried assigning the DHTPIN to several different pins and they all produce this same result.

Found it.

Bumping this up to the top.

There is NOTHING useful at that link.

I mentioned earlier "You might consider using a pin other than 0 for OLED_RESET."

Did you ever try a different pin for OLED_RESET?