LCD stops working after awhile

Hey,
So I've been working on a humidity and temperature sensor for my 3d printer enclosure, and it seems to work.
But after a few minutes, the display starts to display random characters. I'm currently using a usb cord to power the Nano. I have the usb plugged into a surge protector with 2 usb slots. After some research I found people suggesting adding a capacitor between the power and ground in order to fix this problem, but it hasn't seemed to change anything for me.

This diagram attached is the exact wiring I'm using. The capacitor is 1uF, while the resistor is 4.7k ( if you can't tell).


This is the code I'm using, but it doesn't seem to be a code problem, considering the program itself seems to have no problem running. The only thing I'm skeptical about is the delays.

#include "DHT.h" //including the dht22 library
#include "LiquidCrystal.h"
#define DHTPIN 2 //Declaring pin 9 of arduino for the dht22
#define DHTTYPE DHT22 //Defining which type of dht22 we are using (DHT22 or DHT11)
DHT dht(DHTPIN, DHTTYPE); //Declaring a variable named dht
LiquidCrystal lcd(9,8,7,6,5,4); // Initializing the LCD pins.
void setup() { //Data written in it will only run once
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
dht.begin(); //This command will start to receive the values from dht22
}
void loop() { //Data written in it will run again and again
lcd.clear();
float hum = dht.readHumidity(); //Reading the humidity and storing in hum
float temp = dht.readTemperature(true); //Reading the temperature as Celsius and storing in temp
// Check if any reads failed and exit early (to try again).
if (isnan(hum) || isnan(temp)) {
lcd.print("Failed to read");
delay(2200);
return;
}
lcd.setCursor(0,0); //Setting the cursor at the start of the LCD
lcd.print("Temp.: "); //Writing the temperature on the LCD
lcd.print(temp); //Writing the value of temperature on the LCD
lcd.print(" F");
lcd.setCursor(0,1); //setting the cursor at next line
lcd.print("Humi.: "); //Writing the humidity on the LCD display
lcd.print(hum); //Writing the humidity value stored in hum on the LCD display
lcd.print(" %");
delay(2200);
}

So if anyone has suggestions for why this might be happening, and how to fix it, that'd be great.
Thanks!

Circuit Drawing.png

Nothing particularly obvious. :roll_eyes:

Don't power Nanos or UNOs from "Vin" or the "barrel jack". :astonished: But you are not attempting to.

Are all the connections soldered? I’ve had problems like that using a breadboard.

Yeah I soldered all of them. I even went back and re-did it, because I thought maybe one of them was loose or something. Like I said, I know the circuit shows me using the Vin, but I'm actually using a USB.

this took a little bit of research... here's a link to the datasheet:

link

check the electrical connection diagram. There should be a pull up on pin 2 of the DHT22. Try a 10k resistor.

wolframore:
this took a little bit of research... here's a link to the datasheet:

link

check the electrical connection diagram. There should be a pull up on pin 2 of the DHT22. Try a 10k resistor.

That link doesn't work for me unfortunately. I'm currently redoing the soldering and i realized that I think one of my grounded wires should actually be going into a resistor. I may have swapped them.

You’re talking about the contrast on the lcd? That wouldn’t cause issues like you described. It would make it hard to see

Yeah the new configuration I was trying didn't seem to make it work. The link you attached is blocked for me. Is there another way I could view it?

Try this...

link