Arduino uno Freeze after some hours or days of work

Hello I have created a incubator with Arduino uno, lcd1602 and DHt11.
My Arduino freeze after some days or hours, I have test with many power supply but no result.

This is the code:
#include <LiquidCrystal.h> // eshte e LCD
#include <Wire.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);// eshte e LCD, shiko skemen e lidhjes "LCD1"

#define heaterPin 6
#define humidifierPin 5

//-----S RTC
#include "RTClib.h"// eshte RTC
RTC_DS1307 rtc;
DateTime now;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

//-----E RTC

// Temperatura Humidity DHT11 start
#include <dht11.h>
dht11 DHT11;
#define PIN_DHT11 2
// Temperatura Humidity DHT11 finish

//const int heaterPin = 5; jane percaktuar mesiper
//const int humidifierPin = 6; jane mesiper
const float temperatureThreshold = 37.5;
const float humidityThreshold = 60.0;

void setup() {
pinMode(heaterPin, OUTPUT);
pinMode(humidifierPin, OUTPUT);

lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("Hello World!");
//kodi i meposhtem eshte RTC
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
lcd.begin(0, 1);
lcd.print("JO RTC");
Serial.flush();
delay(2000);
// abort();
}
// rtc.adjust(DateTime(2022, 1, 1,18, 55, 2));

//deri ketu RTC

//e reja rtc
if(!rtc.isrunning()){

// Serial.println("RTC power failure, resetting the time!");
rtc.adjust(DateTime(F(DATE), F(TIME)));
lcd.begin(0, 1);
lcd.print("JO runni");
}
// e reja mbyllet

}

void loop() {

//----------

DateTime now = rtc.now();
lcd.begin(0, 1);
lcd.print("Current time: ");
delay(2000);
lcd.begin(0, 1);
lcd.print(now.year(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.day(), DEC);
lcd.print(" (");
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(") ");
delay(1000);
lcd.begin(0, 1);
lcd.print("ORA : ");
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.println("Seko");
delay(2000);
// Temperature code start

DHT11.read(PIN_DHT11);
float humidity = DHT11.humidity;
float temperature=DHT11.temperature;

lcd.begin(0, 1);
lcd.print("Current Humidity: ");
delay(1000);

lcd.begin(0, 1);

lcd.print((float)DHT11.humidity, 2);
delay(3000);

lcd.begin(0, 1);
delay(1000);
lcd.print("Temperature (oC): ");
delay(1000);

lcd.begin(0, 1);
lcd.print((float)DHT11.temperature, 2);
delay(3000);

//Temperature code finish

if (temperature < temperatureThreshold) {
digitalWrite(heaterPin, HIGH); //heater pin eshte pin 5
} else {
digitalWrite(heaterPin, LOW);
}

if (humidity < humidityThreshold) {
digitalWrite(humidifierPin, HIGH); // eshte pin 6
} else {
digitalWrite(humidifierPin, LOW);
}

delay(1000);

}
PleAE GIVE A CORRECT ANSWER
Thank you!!

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

2 Likes

Good.
Please post schematics anyway.

2 Likes

Did your RAM run out?

Apart from all,the other potential issues, why do you keep calling
lcd.begin();
all the time ?

1 Like

I guess it should be
lcd.setCursor()

LCD keywords can be found on this page.

There is also confusion about pin 5 and 6.
Leo..

Sometimes it freeze after 1 days, sometimes after 7 days, but it work well during that time.
I have commect arduino uno to LCD1602, DHT11, RTC , DS18B20.

i check connection and it is ok. But i need your help to find problem because of chicken eggs.

We need your help to help you find the problem(s).

Re-read the suggestions in the posts again.

Because this code is modified by a template. But i think it isnt the cause to problem

Pin 5 and 6 are for relay ot temperature resistance and oin 6 for humidifier.

Arduino is connected with lcf1602, a dht11, rtc, and it work fine for some says, next it freeze the SCREEN.

How?

These issues are often caused by power supply problems and over heating regulators .

Hence the multiple requests for a wiring diagram ( hand drawn is good )

I have use different 5v, 2A power supply, the same that i charge my phone.
Below is the schematic, where with DHT22 mean DHT11.
thank you !!

Any help please ?
Incubator schematic

That doesn’t look right ! Where are the pull up resistors for the ds18b20 and the humidity sensor . There are no resistors in series with the LED’s to limit current . These might be your problem .
How is the board powered ??

No problem because dht11 and dsb18b20 has their own board but i didnt put in schem.

That’s why we need a proper schematic.
Draw one !

1 Like

Board is powered by 5v power supply, the same that charge phone by usb cable. It work well for some days until it freeze the screen

There is a problem with something we can’t see , that why we need all the details .
A picture of your layout is worth looking at too, if you have a bad connection that can cause it to freeze .

Thank yoy hammy.
I am sure that the connection is done well, i have tested before.
Dht11 and dsb18b20 are connected by their own board that each of them have 3 pins and digital pines are connected to pin 2,4.