I would like to combine 2 arduino codes

Hello
Im trying to combine 2 codes for more than few days and still cant figure it out.
Here are this 2 codes. One is for RTC and other is for temperature and moisture. I would like to change what is on display like:

Temp: 30
Mosture: 30%

and after 3 sec it would change to:

Clock
Date

I guess its not hard but im new at this and i would ask for help
Thanks!

Temp_moisture:

//We'll start by adding our libraries

#include <LiquidCrystal.h>


#include <SimpleDHT.h>

//Declaring digital pin no 6 as the dht11 data pin

int pinDHT11 = 7;
SimpleDHT11 dht11;

//Declaring the lcd pins

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// Don't forget to choose 9600 at the port screen
  
  Serial.begin(9600);
 
//Telling our lcd to start up
  
  lcd.begin(16, 2);
   
   
}

void loop() {

  //These serial codes are for getting readings on the port screen aswell as the LCD display, since they'll offer us a more detailed interface
  
  
  Serial.println("=================================");
  Serial.println("DHT11 readings...");
  
 
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;

  //This bit will tell our Arduino what to do if there is some sort of an error at getting readings from our sensor
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("No reading , err="); Serial.println(err);delay(1000);
    return;
  }
  
  Serial.print("Readings: ");
  Serial.print((int)temperature); Serial.print(" Celcius, ");
  Serial.print((int)humidity); Serial.println(" %");
 
  //Telling our lcd to refresh itself every 0.75 seconds
  lcd.clear();
 
  //Choosing the first line and row
  lcd.setCursor(0,0);
  //Typing Temp: to the first line starting from the first row
  lcd.print("Temp: ");
  //Typing the temperature readings after "Temp: " 
  lcd.print((int)temperature);
  //Choosing the second line and first row
  lcd.setCursor(0,1);
  //Typing Humidity(%): to the second line starting from the first row
  lcd.print("Vlaga: ");
  //Typing the humidity readings after "Humidity(%): "
  lcd.print((int)humidity);
  lcd.print("%");
 
  
  
  
  delay(750);
}

RTC:

#include "Wire.h"
#include <LiquidCrystal.h>
#define PCF8563address 0x51

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

 
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
String days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
 
byte bcdToDec(byte value)
{
  return ((value / 16) * 10 + value % 16);
}
 
byte decToBcd(byte value){
  return (value / 10 * 16 + value % 10);
}
 
void setPCF8563()
// this sets the time and date to the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.write(decToBcd(second));  
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));     
  Wire.write(decToBcd(dayOfMonth));
  Wire.write(decToBcd(dayOfWeek));  
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.endTransmission();
}
 
void readPCF8563()
// this gets the time and date from the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.endTransmission();
  Wire.requestFrom(PCF8563address, 7);
  second     = bcdToDec(Wire.read() & B01111111); // remove VL error bit
  minute     = bcdToDec(Wire.read() & B01111111); // remove unwanted bits from MSB
  hour       = bcdToDec(Wire.read() & B00111111); 
  dayOfMonth = bcdToDec(Wire.read() & B00111111);
  dayOfWeek  = bcdToDec(Wire.read() & B00000111);  
  month      = bcdToDec(Wire.read() & B00011111);  // remove century bit, 1999 is over
  year       = bcdToDec(Wire.read());
}
 
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  // change the following to set your initial time
  second = 0;
  minute = 28;
  hour = 9;
  dayOfWeek = 2;
  dayOfMonth = 13;
  month = 8;
  year = 13;
  // comment out the next line and upload again to set and keep the time from resetting every reset
  setPCF8563();
}
 
void loop()
{
  readPCF8563();
  lcd.print(days[dayOfWeek]); 
  lcd.print(" ");  
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/20");
  lcd.print(year, DEC);
  lcd.print(" - ");
  lcd.print(hour, DEC);
  lcd.print(":");
  if (minute < 10)
  {
    Serial.print("0");
  }
  Serial.print(minute, DEC);
  Serial.print(":");  
  if (second < 10)
  {
    Serial.print("0");
  }  
  Serial.println(second, DEC);  
  delay(1000);
}

and this is what i was working on and its not working...

#include <LiquidCrystal.h>
#include "Wire.h"
#define PCF8563address 0x51
#include <SimpleDHT.h>

//Declaring digital pin no 6 as the dht11 data pin

int pinDHT11 = 7;
SimpleDHT11 dht11;

//Declaring the lcd pins

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
String days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
 
byte bcdToDec(byte value)
{
  return ((value / 16) * 10 + value % 16);
}
 
byte decToBcd(byte value){
  return (value / 10 * 16 + value % 10);
}



///////////////////////////////////////////////////////////////////////////////
void setPCF8563()
// this sets the time and date to the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.write(decToBcd(second));  
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));     
  Wire.write(decToBcd(dayOfMonth));
  Wire.write(decToBcd(dayOfWeek));  
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.endTransmission();
}
 
void readPCF8563()
// this gets the time and date from the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.endTransmission();
  Wire.requestFrom(PCF8563address, 7);
  second     = bcdToDec(Wire.read() & B01111111); // remove VL error bit
  minute     = bcdToDec(Wire.read() & B01111111); // remove unwanted bits from MSB
  hour       = bcdToDec(Wire.read() & B00111111); 
  dayOfMonth = bcdToDec(Wire.read() & B00111111);
  dayOfWeek  = bcdToDec(Wire.read() & B00000111);  
  month      = bcdToDec(Wire.read() & B00011111);  // remove century bit, 1999 is over
  year       = bcdToDec(Wire.read());
}
////////////////////////////////////////////////////////////////////////////////////

void cas(){
   readPCF8563();
   lcd.clear();
  lcd.print(days[dayOfWeek]); 
  lcd.print(" ");  
  lcd.print(dayOfMonth, DEC);
  lcd.print(".");
  lcd.print(month, DEC);
  lcd.print(".20");
  lcd.print(year, DEC);
  lcd.print(" - ");
  lcd.print(hour, DEC);
  lcd.print(":");
}
void setup()
{
  lcd.begin(16, 2);
  Wire.begin();
  Serial.begin(9600);
  // change the following to set your initial time
  second = 0;
  minute = 28;
  hour = 9;
  dayOfWeek = 2;
  dayOfMonth = 13;
  month = 8;
  year = 13;
  // comment out the next line and upload again to set and keep the time from resetting every reset
  setPCF8563();
}

void loop() {
  
  //These serial codes are for getting readings on the port screen aswell as the LCD display, since they'll offer us a more detailed interface
  
  
  Serial.println("=================================");
  Serial.println("DHT11 readings...");
  
 
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;

  //This bit will tell our Arduino what to do if there is some sort of an error at getting readings from our sensor
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("No reading , err="); Serial.println(err);delay(1000);
    return;
  }
  
  Serial.print("Readings: ");
  Serial.print((int)temperature); Serial.print(" Celcius, ");
  Serial.print((int)humidity); Serial.println(" %");
 
  //Telling our lcd to refresh itself every 0.75 seconds
  lcd.clear();
 
  //Choosing the first line and row
  lcd.setCursor(0,0);
  //Typing Temp: to the first line starting from the first row
  lcd.print("Temp: ");
  //Typing the temperature readings after "Temp: " 
  lcd.print((int)temperature);
  //Choosing the second line and first row
  lcd.setCursor(0,1);
  //Typing Humidity(%): to the second line starting from the first row
  lcd.print("Vlaga: ");
  //Typing the humidity readings after "Humidity(%): "
  lcd.print((int)humidity);
  lcd.print("%");
 

  cas();
  
  delay(750);
}

Hi,

Suggestions here on how to approach this:

https://arduinoinfo.mywikis.net/wiki/CombiningArduinoSketches

First thing is to get organized and understand EACH sketch..

Does anyone know how to put this 2 codes together?

mateman99:
Does anyone know how to put this 2 codes together?

Do you have a specification?

What have you tried since yesterday?

Please remember to use code tags when posting code

@OP

There is a proven approach known as SSS (Small Start Strategy) Methodology to come up with a working project/system. In this methodology, one starts with a basic (simple and elementary) piece of hardware and the associated software and makes it operational. After that another incremental 'hardware + software' is added and so on until all the parts are added and tested.

1. Make a connection among UNO, DHT11, and Serial Monitor

2. Upload the following sketch -- the compact version of your one.

#include <SimpleDHT.h>
SimpleDHT11 dht11;
int pinDHT11 = 7;
byte temperature;
byte humidity;

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

void loop()
{
  dht11.read(pinDHT11, &temperature, &humidity, NULL); //method to acquire and store temp, humidity
  Serial.print("Readings: ");
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" %H");
  delay(1500);
}

3. Check that the Serial Monitor shows correct Temp and Humidity readings.

4. Connect DS3231 RTC Module (if you have) and LCD with the UNO. (I don't own the one you have.) as per following diagram. (I have used I2C LCD.)
rtc3231-21x.png

5. Upload the following sketch and check that the LCD shows current Time and Date.

#include <Wire.h>     //needed because DS3231 uses I2C Bus
#include <RTClib.h>   //needed becuase we have ready-made functions of this librray
#include<LiquidCrystal_I2C.h>  //neded by LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); //lcd address; 16 characters 2 line

RTC_DS3231 rtc;     //the object rtc is created from the class RTC_DS3231
char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
#define deviceAddress 0x68

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 1);

  if (! rtc.begin())   //DS3231 is intialized
  {
    while (1);
  }
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
  rtc.adjust(DateTime(2019, 03, 20, 11, 41, 17));//set date-time manualy:yr,mo,dy,hr,mn,se
}

void  loop()
{
  //--read Date and Tme from DS3231 using the method now()---------------------;
  //--store the Date and Time into another user define object bamed nowTime
  DateTime nowTime = rtc.now();

  //---show Day and Date on Top Line of LCD--------------
  int x = nowTime.dayOfTheWeek(); //dyOfTheWeek() is a pre-defined method
  lcd.print(daysOfTheWeek[x]);    //days of the Week[] is the user defined array
  lcd.print(": ");

  lcd.print(nowTime.day());
  lcd.print("/");

  lcd.print(nowTime.month());
  lcd.print("/");

  lcd.print(nowTime.year());

  Wire.beginTransmission(deviceAddress); //START, Roll Cal
  Wire.write(0x00); //set SEC Register address
  Wire.endTransmission(); //Execute the above queued data, ACK, STOP

  Wire.requestFrom(deviceAddress, 3);   //SEC, MIN, and HRS to read from RTC as BCD
  byte bcdSeconds = Wire.read();
  byte bcdMinutes = Wire.read();
  byte bcdHours = Wire.read();
  bcdHours = bcdHours & 0b00011111;

  lcd.setCursor(0, 0);
  lcd.print("Clock: ");
  //show HRS--
  lcd.write((bcdHours >> 4) + 0x30);
  lcd.write((bcdHours & 0x0F) + 0x30);
  lcd.write(':');

  //show MIN--
  lcd.write((bcdMinutes >> 4) + 0x30);
  lcd.write((bcdMinutes & 0x0F) + 0x30);
  lcd.print(':');

  //shiw SEC
  lcd.write((bcdSeconds >> 4) + 0x30);
  lcd.write((bcdSeconds & 0x0F) + 0x30);

  lcd.setCursor(0, 1);
}

6. Look into the following merged program and see how the two sketches have been merged together. Upload the program and check that the readings are coming alternately on the LCD. Show RTC for 3-sec and then show Temp/Humidity for 3-sec.

#include <Wire.h>     //needed because DS3231 uses I2C Bus
#include <RTClib.h>   //needed becuase we have ready-made functions of this librray
#include<LiquidCrystal_I2C.h>  //neded by LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); //lcd address; 16 characters 2 line
//------------------------------------------------------------------
RTC_DS3231 rtc;     //the object rtc is created from the class RTC_DS3231
char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
#define deviceAddress 0x68
byte secTime;
//------------------------------------------------------------------
#include <SimpleDHT.h>
SimpleDHT11 dht11;
int pinDHT11 = 7;
byte temp;
byte humidity;
//-----------------------------------------------------------------

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 1);

  if (! rtc.begin())   //DS3231 is intialized
  {
    while (1);
  }
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
  rtc.adjust(DateTime(2019, 03, 20, 11, 41, 17));//set date-time manualy:yr,mo,dy,hr,mn,se
}

void  loop()
{
  showTempHumidity();
  delay(3000);
  lcd.clear();
  showTimeDate();
  delay(3000);
  lcd.clear();
}

void showTempHumidity()
{
  dht11.read(pinDHT11, &temp, &humidity, NULL); //method to acquire and store temp, humidity
  lcd.setCursor(0, 0);
  lcd.print("Temp: "); lcd.print((int)temp); lcd.write(0xDF); lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: "); lcd.print((int)humidity); lcd.print(" %H");
  delay(1500);
}

void showTimeDate()
{
  //--read Date and Tme from DS3231 using the method now()---------------------;
  //--store the Date and Time into another user define object bamed nowTime
  DateTime nowTime = rtc.now();
  lcd.setCursor(0, 1);
  //---show Day and Date on Top Line of LCD--------------
  int x = nowTime.dayOfTheWeek(); //dyOfTheWeek() is a pre-defined method
  lcd.print(daysOfTheWeek[x]);    //days of the Week[] is the user defined array
  lcd.print(": ");

  lcd.print(nowTime.day());
  lcd.print("/");

  lcd.print(nowTime.month());
  lcd.print("/");

  lcd.print(nowTime.year());

  Wire.beginTransmission(deviceAddress); //START, Roll Cal
  Wire.write(0x00); //set SEC Register address
  Wire.endTransmission(); //Execute the above queued data, ACK, STOP

  Wire.requestFrom(deviceAddress, 3);   //SEC, MIN, and HRS to read from RTC as BCD
  byte bcdSeconds = Wire.read();
  byte bcdMinutes = Wire.read();
  byte bcdHours = Wire.read();
  bcdHours = bcdHours & 0b00011111;

  lcd.setCursor(0, 0);
  lcd.print("Clock: ");
  //show HRS--
  lcd.write((bcdHours >> 4) + 0x30);
  lcd.write((bcdHours & 0x0F) + 0x30);
  lcd.write(':');

  //show MIN--
  lcd.write((bcdMinutes >> 4) + 0x30);
  lcd.write((bcdMinutes & 0x0F) + 0x30);
  lcd.print(':');

  //show SEC
  lcd.write((bcdSeconds >> 4) + 0x30);
  lcd.write((bcdSeconds & 0x0F) + 0x30);

  lcd.setCursor(0, 1);
}

rtc3231-21x.png

I have normal LCD and it have that connection:
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

and if i change LiquidCrystal_I2C lcd(0x27, 16, 2); to my LCD settings i got error:

lcd.init();

(exit status 1
no matching function for call to 'LiquidCrystal::init()')

Thanks for any more help

Screenshot_1.png

Quick and dirty way:

void setup()
{
  setup1();
  setup2();
}

void loop()
{
  loop1();
  loop2();
}

Then just rename the setup() and loop() functions in the two sketches.

To switch between loop1() and loop2() ever three seconds, use the "Blink Without Delay" example:

bool OneRunning = true;
const long interval = 3000;           // interval at which to blink (milliseconds)

void loop()
{
  if (OneRunning)
    loop1();
  else
    loop2();

  // check to see if it's time to switch
  static unsigned long previousMillis = 0;
  if (millis() - previousMillis >= interval)
  {
    previousMillis += interval; // Re-start the timer
    OneRunning = !OneRunning; // Toggle
  }
}

mateman99:
I have normal LCD and it have that connection:
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

and if i change LiquidCrystal_I2C lcd(0x27, 16, 2); to my LCD settings i got error:

lcd.init();

(exit status 1
no matching function for call to 'LiquidCrystal::init()')

Thanks for any more help

Leave your normal LCD connection and the associated library as it is. I used I2C LCD as a quick connection.

GolamMostafa:
Leave your normal LCD connection and the associated library as it is. I used I2C LCD as a quick connection.

Can u please change the code for normal lcd? because if i add lcd connections its showing error

(
exit status 1
conflicting declaration 'LiquidCrystal lcd'
)
Im very sory but i dont realy know much abouth arduino.

mateman99:
Can u please change the code for normal lcd? because if i add lcd connections its showing error

I have done for you. Upload the sketch and check that the Clock and Sensor show correct readings on LCD.

#include <Wire.h>     //needed because DS3231 uses I2C Bus
#include <RTClib.h>   //needed becuase we have ready-made functions of this librray
#include<LiquidCrystal.h>  //neded by LCD
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//------------------------------------------------------------------
RTC_DS3231 rtc;     //the object rtc is created from the class RTC_DS3231
char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
#define deviceAddress 0x68
byte secTime;
//------------------------------------------------------------------
#include <SimpleDHT.h>
SimpleDHT11 dht11;
int pinDHT11 = 7;  //connect DHT11 signal at DPin-7
byte temp;
byte humidity;
//-----------------------------------------------------------------

void setup()
{
  lcd.begin(16, 2);
  lcd.setCursor(0, 1);

  if (! rtc.begin())   //DS3231 is intialized
  {
    while (1);
  }
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
  rtc.adjust(DateTime(2019, 03, 20, 11, 41, 17));//set date-time manualy:yr,mo,dy,hr,mn,se
}

void  loop()
{
  showTempHumidity();
  delay(3000);
  lcd.clear();
  showTimeDate();
  delay(3000);
  lcd.clear();
}

void showTempHumidity()
{
  dht11.read(pinDHT11, &temp, &humidity, NULL); //method to acquire and store temp, humidity
  lcd.setCursor(0, 0);
  lcd.print("Temp: "); lcd.print((int)temp); lcd.write(0xDF); lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: "); lcd.print((int)humidity); lcd.print(" %H");
  delay(1500);
}

void showTimeDate()
{
  //--read Date and Tme from DS3231 using the method now()---------------------;
  //--store the Date and Time into another user define object bamed nowTime
  DateTime nowTime = rtc.now();
  lcd.setCursor(0, 1);
  //---show Day and Date on Top Line of LCD--------------
  int x = nowTime.dayOfTheWeek(); //dyOfTheWeek() is a pre-defined method
  lcd.print(daysOfTheWeek[x]);    //days of the Week[] is the user defined array
  lcd.print(": ");

  lcd.print(nowTime.day());
  lcd.print("/");

  lcd.print(nowTime.month());
  lcd.print("/");

  lcd.print(nowTime.year());

  Wire.beginTransmission(deviceAddress); //START, Roll Cal
  Wire.write(0x00); //set SEC Register address
  Wire.endTransmission(); //Execute the above queued data, ACK, STOP

  Wire.requestFrom(deviceAddress, 3);   //SEC, MIN, and HRS to read from RTC as BCD
  byte bcdSeconds = Wire.read();
  byte bcdMinutes = Wire.read();
  byte bcdHours = Wire.read();
  bcdHours = bcdHours & 0b00011111;

  lcd.setCursor(0, 0);
  lcd.print("Clock: ");
  //show HRS--
  lcd.write((bcdHours >> 4) + 0x30);
  lcd.write((bcdHours & 0x0F) + 0x30);
  lcd.write(':');

  //show MIN--
  lcd.write((bcdMinutes >> 4) + 0x30);
  lcd.write((bcdMinutes & 0x0F) + 0x30);
  lcd.print(':');

  //show SEC
  lcd.write((bcdSeconds >> 4) + 0x30);
  lcd.write((bcdSeconds & 0x0F) + 0x30);

  lcd.setCursor(0, 1);
}

Never mind..i dont know why date and time is not working...

Here is the url of picture

Its because i use PCF8563 RTC and not DS3231. I cant chage it to my RTC -.-

Can someone help me change it?
This is the only thing that i would like to request. I wont ask for nothing more abouth this code
Thanks in the future

mateman99:
Can someone help me change it?
This is the only thing that i would like to request. I wont ask for nothing more abouth this code
Thanks in the future

OK! Upload the following sketch and see what happens. If not working, report the exact error message. I could not test this program as I don't own the PCF8563 RTC Chip. I have simply merged your RTC Program with humidity program.

#include "Wire.h"
#include <LiquidCrystal.h>
#define PCF8563address 0x51
//------------------------------------------------------------------
#include <SimpleDHT.h>
SimpleDHT11 dht11;
int pinDHT11 = 7;
byte temp;
byte humidity;
//-----------------------------------------------------------------
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
String days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  // change the following to set your initial time
  second = 0;
  minute = 28;
  hour = 9;
  dayOfWeek = 2;
  dayOfMonth = 13;
  month = 8;
  year = 13;
  // comment out the next line and upload again to set and keep the time from resetting every reset
  setPCF8563();
}

void loop()
{
  showTempHumidity();
  delay(3000);
  lcd.clear();
  showTimeDate();
  delay(3000);
  lcd.clear();
}

void showTempHumidity()
{
  dht11.read(pinDHT11, &temp, &humidity, NULL); //method to acquire and store temp, humidity
  lcd.setCursor(0, 0);
  lcd.print("Temp: "); lcd.print((int)temp); lcd.write(0xDF); lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: "); lcd.print((int)humidity); lcd.print(" %H");
  // delay(1500);
}

void showTimeDate()//;void loop()
{
  readPCF8563();
  lcd.setCursor(0, 1);   //DP0 position TopLine
  lcd.print(days[dayOfWeek]);
  lcd.print(" ");
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/20");
  lcd.print(year, DEC);
  // lcd.print(" - ");
  //------------------------------------------
  lcd.setCursor(0, 0);  //DP0 postion BotLine
  lcd.print(hour, DEC);
  lcd.print(":");
  if (minute < 10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second < 10)
  {
    lcd.print("0");
  }
  lcd.println(second, DEC);
  // delay(1000);
}

byte bcdToDec(byte value)
{
  return ((value / 16) * 10 + value % 16);
}

byte decToBcd(byte value)
{
  return (value / 10 * 16 + value % 10);
}

void setPCF8563()
// this sets the time and date to the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(dayOfMonth));
  Wire.write(decToBcd(dayOfWeek));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.endTransmission();
}

void readPCF8563()
// this gets the time and date from the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.endTransmission();
  Wire.requestFrom(PCF8563address, 7);
  second     = bcdToDec(Wire.read() & B01111111); // remove VL error bit
  minute     = bcdToDec(Wire.read() & B01111111); // remove unwanted bits from MSB
  hour       = bcdToDec(Wire.read() & B00111111);
  dayOfMonth = bcdToDec(Wire.read() & B00111111);
  dayOfWeek  = bcdToDec(Wire.read() & B00000111);
  month      = bcdToDec(Wire.read() & B00011111);  // remove century bit, 1999 is over
  year       = bcdToDec(Wire.read());
}

Thanks for helping!
In this code, lcd is showing like this:
Humidity : 30%H date time
Its all in one row

mateman99:
Thanks for helping!
In this code, lcd is showing like this:
Humidity : 30%H date time
Its all in one row

Thanks for the efforts and the beautiful video!

Add the following line in the setup() function; this is not there.

lcd.begin(16, 2);

Also, change this line:

lcd.println(second, DEC);

to

lcd.print(second, DEC);

in the

showTimeDate() function.

Upload the modified sketch and report results.

Thanks you very much GolamMostafa!
I wouldnt be able to finish this code without you and others!
This is realy good community!
Thanks you again and if i would need anything more help i will come here
Good luck guys!

Here is the code for anyone who would mybe need it!
RTC+Temp+Humidity:

#include "Wire.h"
#include <LiquidCrystal.h>
#define PCF8563address 0x51
//------------------------------------------------------------------
#include <SimpleDHT.h>
SimpleDHT11 dht11;
int pinDHT11 = 7;
byte temp;
byte humidity;
//-----------------------------------------------------------------
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
String days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

void setup()
{
  lcd.begin(16, 2);
  Wire.begin();
  Serial.begin(9600);
  // change the following to set your initial time
  second = 0;
  minute = 10;
  hour = 18;
  dayOfWeek = 2;
  dayOfMonth = 26;
  month = 3;
  year = 19;
  // comment out the next line and upload again to set and keep the time from resetting every reset
  setPCF8563();
}

void loop()
{
  showTempHumidity();
  delay(3000);
  lcd.clear();
  showTimeDate();
  delay(3000);
  lcd.clear();
}

void showTempHumidity()
{
  dht11.read(pinDHT11, &temp, &humidity, NULL); //method to acquire and store temp, humidity
  lcd.setCursor(0, 0);
  lcd.print("Temp: "); lcd.print((int)temp); lcd.write(0xDF); lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: "); lcd.print((int)humidity); lcd.print(" %H");
  // delay(1500);
}

void showTimeDate()//;void loop()
{
  readPCF8563();
  lcd.setCursor(0, 1);   //DP0 position TopLine
  lcd.print(days[dayOfWeek]);
  lcd.print(": ");
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/20");
  lcd.print(year, DEC);
  // lcd.print(" - ");
  //------------------------------------------
  lcd.setCursor(0, 0);  //DP0 postion BotLine
  lcd.print("Ura: ");
  lcd.print(hour, DEC);
  lcd.print(":");
  if (minute < 10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second < 10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);
  // delay(1000);
}

byte bcdToDec(byte value)
{
  return ((value / 16) * 10 + value % 16);
}

byte decToBcd(byte value)
{
  return (value / 10 * 16 + value % 10);
}

void setPCF8563()
// this sets the time and date to the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(dayOfMonth));
  Wire.write(decToBcd(dayOfWeek));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.endTransmission();
}

void readPCF8563()
// this gets the time and date from the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.write(0x02);
  Wire.endTransmission();
  Wire.requestFrom(PCF8563address, 7);
  second     = bcdToDec(Wire.read() & B01111111); // remove VL error bit
  minute     = bcdToDec(Wire.read() & B01111111); // remove unwanted bits from MSB
  hour       = bcdToDec(Wire.read() & B00111111);
  dayOfMonth = bcdToDec(Wire.read() & B00111111);
  dayOfWeek  = bcdToDec(Wire.read() & B00000111);
  month      = bcdToDec(Wire.read() & B00011111);  // remove century bit, 1999 is over
  year       = bcdToDec(Wire.read());
}

Here is a little video and sory for bad quality its just imgur xD