Multiple i2c communication with 4 device

I am working on a project. Where I am using two Arduino(UNO, Pro Mini), one ds1307 rtc, one 24LC512 eeprom, one Nokia5110 LCD, Some 4digit 7 segment.

In this project I do some calculation, read/write/send and receive data among two arduino , external eeprom using i2c communication.

For better understanding please see the picture :

In Arduino UNO:
I read time from ds1307 and some data(which i previously stored) from 24LC512 eeprom using same Analog pin A4,A5 using i2c communication with Wire.h library.

And also send the time to another Arduino pro mini via I2C which is connected to the Uno using A4 and A5.
Edit time using push button and show them nokia5110.

In Arduino Pro Mini:
Here i received data from master UNO and read some data from 24LC512 eeprom and the do some calculation.

Finally display the calculated value in 4 digit 7 segment.

All is working fine but when i added some new feature the code size is getting big.

And when i upload the code the two device working smoothly for some moment.
And then suddenly the master Hang.

Code of Master UNO:

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <RTClib.h>
#include "Wire.h"
#include "SevenSegmentExtended.h"
#define EEPROM_I2C_ADDRESS 0x50
#define lcdBL 10        // LCD backlight pin
#define btnEnt 4
#define btnUp 3
#define btnDwn 2
#define MENU_ROW_HEIGHT 11
#define LCD_ROWS 5

//................For Atmega Arduino....................
Adafruit_PCD8544 display = Adafruit_PCD8544(9, 8, 7, 6, 5);

RTC_DS1307 rtc;
int latitude, latitudef, longitude, longitudef;
int hour, minute, second, day, month, year;
static const char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

//unsigned long startMillis, currentMillis;
const unsigned long period PROGMEM = 30000; // The duration in milliseconds before the microcontroller goes to sleep
bool exitBool;
byte menuPos, menuScreen, markerPos, menuStartAt, menuPos1, menuScreen1, markerPos1, menuStartAt1, menuPos2, menuScreen2, markerPos2, menuStartAt2;
const char* const menu[12] PROGMEM  = {"Set Time", "Set Date", "Set Method", "Set Mazhab", "Set District", "SegmentBrightness", "DisplayBrightness",
                                       "Display Light", "SetLacation", "Power Down", "Reset Setting", "Exit Menu"
                                      };
const char* const menu1[6] PROGMEM  = {"MWL(Mecca)", "UIS(Karachi)", "ISNA(America)", "Ummal Qura", "EGAS(Egypt)"};
const char* const menu2[2] PROGMEM  = {"Shafi,Hanbali", "Hanafi Mazhub"};
byte MENU_LENGTH =  sizeof(menu) / sizeof(menu[0]);
byte MENU_LENGTH1 =  sizeof(menu1) / sizeof(menu1[0]);
byte MENU_LENGTH2 =  sizeof(menu2) / sizeof(menu2[0]);
SevenSegmentExtended  display1(12, 13);

void setup() {
  Wire.begin();
  rtc.begin();
  if (! rtc.isrunning()) {
    //Serial.println("RTC is NOT running!");
    // Set the date and time at compile time
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }

  pinMode(btnUp, INPUT_PULLUP);
  pinMode(btnDwn, INPUT_PULLUP);
  pinMode(btnEnt, INPUT_PULLUP);
  pinMode(lcdBL, OUTPUT);
  digitalWrite(lcdBL, HIGH);
  display.begin();
  display1.begin();
  display.setContrast(50);
  display.setRotation(4);
  display.clearDisplay();
  delay(1000);
  //startMillis = millis();
}

void loop() {
  DateTime now = rtc.now();
  hour = now.hour();
  minute = now.minute();
  second = now.second();
  day = now.day();
  month = now.month();
  year = now.year();
  
  Wire.beginTransmission(9);//9 here is the address of the slave board
  Wire.write(hour);//Transfers the value of potentiometer to the slave board
  Wire.write(minute);
  Wire.write(second);
  Wire.write(day);
  Wire.write(month);
  Wire.write(lowByte(year));
  Wire.write(highByte(year));
  Wire.endTransmission();
  homePage();
  //delay(100);
  //isButtonDown(btnEnt) == false;
  if (isButtonDown(btnEnt) == true) {
    menuHome();
  }
  delay(1000);
}

void homePage() {
  DateTime now = rtc.now();

  String h, m, s, zero = "0";
  int hr_24, hr_12;
  hr_24 = hour;
  if (hr_24 == 0) {
    hr_12 = 12;
  } else {
    hr_12 = hr_24 % 12;
  }
  if (hr_12 < 10) {
    h = zero + hr_12;
  } else {
    h = hr_12;
  }
  if (minute < 10) {
    m = zero + minute;
  } else {
    m = minute;
  }
  if (second < 10) {
    s = zero + second;
  } else {
    s = second;
  }
  display1.printTime(hr_12, minute, true);
  display.clearDisplay();
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.print(h);
  display.print(":");
  display.print(m);
  display.setTextSize(1);
  display.print(":");
  display.print(s);
  display.setCursor(66, 7);
  display.print("pm");
  display.setCursor(0, 16);
  display.print(day);
  display.print("-");
  display.print(month);
  display.print("-");
  display.print(year);
  display.print("/");
  display.print(daysOfTheWeek[now.dayOfTheWeek()]);
  display.print("\n");
  display.display();
}
void menuHome() {
  int x = 0;
  showMenu();
  delay(100);
  isButtonDown(btnEnt) == false;
  do {
    //currentMillis = millis();
    if (isButtonDown(btnDwn) == true) {
      if (menuPos < MENU_LENGTH - 1) {
        menuPos++;
        if (menuPos - menuStartAt > 3 )
          menuStartAt++;
        showMenu();
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnUp) == true) {
      if (menuPos > 0) {
        menuPos--;
        if (menuPos - menuStartAt < 0 && menuStartAt != 0)
          menuStartAt--;
        showMenu();
      }
      delay(100);
      //startMillis = currentMillis;
    }

    if (isButtonDown(btnEnt) == true) {
      if (menuPos == 0) {
        setHour();
      } else if (menuPos == 1) {
        setDates();
      } else if (menuPos == 2) {
        setMethod();
      } else if (menuPos == 3) {
        setMazhub();
      } else if (menuPos == 4) {
        selectDistrict();
      } else if (menuPos == 5) {
        segmentBrightness();
      } else if (menuPos == 6) {
        displayBrightness();
      } else if (menuPos == 7) {
        toggle();
      } else if (menuPos == 8) {
        setLatiLongi();
      } else if (menuPos == 9) {
        //powerDown();
      }
      else if (menuPos == 10) {
        resetSetting();
      } else if (menuPos == 11) {
        x = 1;
        break;
      }
      delay(100);
      //startMillis = currentMillis = millis();
    }
    //if (currentMillis - startMillis >= period) {
      //powerDown();
    //}
  } while (x != 1);
}

void setHour() {
  DateTime now = rtc.now();
  int x = 0;
  isButtonDown(btnEnt) == false;
  do {
    if (isButtonDown(btnUp) == true) {
      hour = hour + 1;
      if (hour > 24) {
        hour = 24;
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnDwn) == true) {
      hour = hour - 1;
      if (hour < 1) {
        hour = 1;
      }
      delay(100);
      //startMillis = currentMillis;
    }
    display.clearDisplay();
    display.fillRect(4, 14, 28, 23, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(6, 18);
    display.setTextSize(2);
    display.print(hour);

    timeColon();

    display.fillRect(46, 14, 28, 23, WHITE);
    display.setTextColor(BLACK);
    display.setCursor(48, 18);
    display.print(minute);
    display.display();
    delay(100);

    if (isButtonDown(btnEnt) == true) {
      delay(100);
      setMinute();
      x = 1;
      break;
    }
  } while (x != 1);
}

void setMinute() {
  int x = 0;
  do {
    if (isButtonDown(btnUp) == true) {
      minute = minute + 1;
      if (minute > 60) {
        minute = 1;
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnDwn) == true) {
      minute = minute - 1;
      if (minute < 1) {
        minute = 60;
      }
      delay(100);
      //startMillis = currentMillis;
    }
    display.fillRect(4, 14, 28, 23, WHITE);
    display.setTextColor(BLACK);
    display.setCursor(6, 18);
    display.setTextSize(2);
    display.print(hour);

    timeColon();

    display.setCursor(48, 18);
    display.fillRect(46, 14, 28, 23, BLACK);
    display.setTextColor(WHITE);
    display.print(minute);
    display.display();
    delay(100);

    if (isButtonDown(btnEnt) == true) {
      delay(100);
      rtc.adjust(DateTime(year, month, day, hour, minute, 1));
      showSuccess();
      x = 1;
      break;
    }
  } while (x != 1);
}

void timeColon() {
  display.setCursor(30, 18);
  display.setTextColor(BLACK);
  display.print(":");
}

void setDates() {
  String zero = "0";
  int x = 0;
  do {
    if (isButtonDown(btnUp) == true) {
      day = day + 1;
      if (month == 2) {
        if (day > 28) {
          day = 1;
        }
      } else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
        if (day > 31) {
          day = 1;
        }
      } else {
        if (day > 30) {
          day = 1;
        }
      }
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      day = day - 1;
      if (day < 1) {
        day = 1;
      }
      delay(100);
    }

    display.clearDisplay();
    display.fillRoundRect(4, 14, 18, 15, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(8, 18);
    display.setTextSize(1);
    if (day < 10) {
      String d = zero + day;
      display.print(d);
    } else {
      display.print(day);
    }
    displayMonth();
    if (month < 10) {
      String m = zero + month;
      display.print(m);
    } else {
      display.print(month);
    }
    displayYear();
    display.print(year);
    display.display();
    isButtonDown(btnEnt) == true;
    delay(100);
    if (isButtonDown(btnEnt) == true) {
      setMonths();
      x = 1;
      break;
    }
  } while (x != 1);
}

void setMonths() {
  int x = 0;
  String zero = "0";
  do {
    if (isButtonDown(btnUp) == true) {
      month = month + 1;
      if (month > 12) {
        month = 1;
      }
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      month = month - 1;
      if (month < 1) {
        month = 12;
      }
      delay(100);
    }
    display.clearDisplay();
    displayDay();
    if (day < 10) {
      String d = zero + day;
      display.print(d);
    } else {
      display.print(day);
    }
    display.setCursor(22, 18);
    display.setTextColor(BLACK);
    display.print(":");
    display.fillRoundRect(26, 14, 18, 15, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(30, 18);
    if (month < 10) {
      String m = zero + month;
      display.print(m);
    } else {
      display.print(month);
    }
    displayYear();
    display.print(year);
    display.display();
    isButtonDown(btnEnt) == true;
    delay(100);

    if (isButtonDown(btnEnt) == true) {
      setYears();
      x = 1;
      break;
    }
  } while (x != 1);
}

void setYears() {

  int x = 0;
  String zero = "0";
  do {
    if (isButtonDown(btnUp) == true) {
      year = year + 1;
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      year = year - 1;
      delay(100);
    }
    display.clearDisplay();
    displayDay();
    if (day < 10) {
      String d = zero + day;
      display.print(d);
    } else {
      display.print(day);
    }

    displayMonth();

    if (month < 10) {
      String m = zero + month;
      display.print(m);
    } else {
      display.print(month);
    }
    display.setCursor(44, 18);
    display.setTextColor(BLACK);
    display.print(":");
    display.fillRoundRect(50, 14, 28, 15, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(53, 18);
    display.print(year);
    display.display();

    isButtonDown(btnEnt) == true;
    delay(100);

    if (isButtonDown(btnEnt) == true) {
      rtc.adjust(DateTime(year, month, day, hour, minute, 1));
      showSuccess();
      x = 1;
      break;
    }
  } while (x != 1);
}

void displayDay() {
  display.fillRoundRect(4, 14, 18, 15, 3, WHITE);
  display.setTextColor(BLACK);
  display.setCursor(8, 18);
  display.setTextSize(1);
}

void displayMonth() {
  display.setCursor(22, 18);
  display.setTextColor(BLACK);
  display.print(":");
  display.fillRoundRect(26, 14, 18, 15, 3, WHITE);
  display.setTextColor(BLACK);
  display.setCursor(30, 18);

}

void displayYear() {
  display.setCursor(44, 18);
  display.setTextColor(BLACK);
  display.print(":");
  display.fillRoundRect(50, 14, 28, 15, 3, WHITE);
  display.setTextColor(BLACK);
  display.setCursor(53, 18);
}

void setMethod() {
  methodMenu();
  //currentMillis = millis();
  int x = 0;
  delay(100);
  isButtonDown(btnEnt) == false;
  do {
    //currentMillis = millis();
    if (isButtonDown(btnDwn) == true) {
      if (menuPos1 < MENU_LENGTH1 - 1) {
        menuPos1++;
        if (menuPos1 - menuStartAt1 > 3 )
          menuStartAt1++;
        methodMenu();
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnUp) == true) {
      if (menuPos1 > 0) {
        menuPos1--;
        if (menuPos1 - menuStartAt1 < 0 && menuStartAt1 != 0)
          menuStartAt1--;
        methodMenu();
      }
      delay(100);
      //startMillis = currentMillis;
    }

    if (isButtonDown(btnEnt) == true) {
      if (menuPos1 == 0) {
        writeString(1800, "0");
        showSuccess();
        x = 1;
        break;
      } else if (menuPos1 == 1) {
        writeString(1800, "1");
        showSuccess();
        x = 1;
        break;
      } else if (menuPos1 == 2) {
        writeString(1800, "2");
        showSuccess();
        x = 1;
        break;
      } else if (menuPos1 == 3) {
        writeString(1800, "3");
        showSuccess();
        x = 1;
        break;
      } else if (menuPos1 == 4) {
        writeString(1800, "4");
        showSuccess();
        x = 1;
        break;
      }
      delay(100);
      //startMillis = currentMillis = millis();
    }
  } while (x != 1);
}

void methodMenu() {
  for (byte i = menuStartAt1; i < (menuStartAt1 + LCD_ROWS); i++) {
    byte markerY1 = (i - menuStartAt1) * MENU_ROW_HEIGHT;
    if (i == menuPos1) {
      display.setTextColor(WHITE, BLACK);
      display.fillRect(0, markerY1, display.width(), MENU_ROW_HEIGHT, BLACK);
    }
    else {
      display.setTextColor(BLACK, WHITE);
      display.fillRect(0, markerY1, display.width(), MENU_ROW_HEIGHT, WHITE);
    }
    if (i >= MENU_LENGTH1)
      continue;
    display.setCursor(3, markerY1 + 2);
    display.setTextSize(1);
    display.print((char*)pgm_read_word(&(menu1[i])));
  }
  display.display();
}

void setMazhub() {
  mazhudMenu();
  //currentMillis = millis();
  int x = 0;
  delay(100);
  isButtonDown(btnEnt) == false;
  do {
    //currentMillis = millis();
    if (isButtonDown(btnDwn) == true) {
      if (menuPos2 < MENU_LENGTH2 - 1) {
        menuPos2++;
        if (menuPos2 - menuStartAt2 > 3 )
          menuStartAt2++;
        mazhudMenu();
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnUp) == true) {
      if (menuPos2 > 0) {
        menuPos2--;
        if (menuPos2 - menuStartAt2 < 0 && menuStartAt2 != 0)
          menuStartAt2--;
        mazhudMenu();
      }
      delay(100);
      //startMillis = currentMillis;
    }

    if (isButtonDown(btnEnt) == true) {
      if (menuPos2 == 0) {
        writeString(1803, "0");
        showSuccess();
        x = 1;
        break;
      } else if (menuPos2 == 1) {
        writeString(1803, "1");
        showSuccess();
        x = 1;
        break;
      }
      delay(100);
      //startMillis = currentMillis = millis();
    }
  } while (x != 1);
}

void mazhudMenu() {
  for (byte i = menuStartAt2; i < (menuStartAt2 + LCD_ROWS); i++) {
    byte markerY2 = (i - menuStartAt2) * MENU_ROW_HEIGHT;
    if (i == menuPos2) {
      display.setTextColor(WHITE, BLACK);
      display.fillRect(0, markerY2, display.width(), MENU_ROW_HEIGHT, BLACK);
    }
    else {
      display.setTextColor(BLACK, WHITE);
      display.fillRect(0, markerY2, display.width(), MENU_ROW_HEIGHT, WHITE);
    }
    if (i >= MENU_LENGTH2)
      continue;
    display.setCursor(3, markerY2 + 2);
    display.setTextSize(1);
    display.print((char*)pgm_read_word(&(menu2[i])));
  }
  display.display();
}

void segmentBrightness() {
  //currentMillis = millis();
  int lightIntensity = read_String(1832).toInt();
  int x = 0;
  isButtonDown(btnEnt) == false;
  delay(100);
  display.clearDisplay();
  do {
    display.setCursor(2, 5);
    display.println("Brigthness");
    display.drawLine(2, 21, lightIntensity, 21, BLACK);
    display.drawLine(2, 22, lightIntensity, 22, BLACK);
    display.drawLine(2, 23, lightIntensity, 23, BLACK);
    display.drawLine(2, 24, lightIntensity, 24, BLACK);
    display.drawLine(2, 25, lightIntensity, 25, BLACK);
    display.drawLine(2, 26, lightIntensity, 26, BLACK);
    display.drawLine(2, 27, lightIntensity, 27, BLACK);
    display.drawLine(2, 28, lightIntensity, 28, BLACK);
    drawRec();
    //currentMillis = millis();
    if (isButtonDown(btnUp) == true) {
      lightIntensity = lightIntensity + 5;
      if (lightIntensity > 82) {
        lightIntensity = 82;
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnDwn) == true) {
      lightIntensity = lightIntensity - 5;
      if (lightIntensity < 2) {
        lightIntensity = 2;
      }
      delay(100);
      //startMillis = currentMillis;
      display.clearDisplay();
    }
    for (int i = 20; i > 29; i++) {
      display.drawLine(2, i, lightIntensity, i, BLACK);
      display.display();
    }
    String lightIntensityStr;
    lightIntensityStr = lightIntensityStr+lightIntensity;
    //Serial.println(lightIntensityStr);
    if (isButtonDown(btnEnt) == true) {
      writeString(1832, lightIntensityStr);
      showSuccess();
      x = 1;
      break;
    }
  } while (x != 1);
}

void displayBrightness() {
  //currentMillis = millis();
  int lightIntensity = read_String(1832).toInt();
  int x = 0;
  isButtonDown(btnEnt) == false;
  delay(100);
  display.clearDisplay();
  do {
    display.setCursor(2, 5);
    display.println("Brigthness");
    display.drawLine(2, 21, lightIntensity, 21, BLACK);
    display.drawLine(2, 22, lightIntensity, 22, BLACK);
    display.drawLine(2, 23, lightIntensity, 23, BLACK);
    display.drawLine(2, 24, lightIntensity, 24, BLACK);
    display.drawLine(2, 25, lightIntensity, 25, BLACK);
    display.drawLine(2, 26, lightIntensity, 26, BLACK);
    display.drawLine(2, 27, lightIntensity, 27, BLACK);
    display.drawLine(2, 28, lightIntensity, 28, BLACK);
    drawRec();
    //currentMillis = millis();
    if (isButtonDown(btnUp) == true) {
      lightIntensity = lightIntensity + 5;
      if (lightIntensity > 82) {
        lightIntensity = 82;
      }
      delay(100);
      //startMillis = currentMillis;
    }
    if (isButtonDown(btnDwn) == true) {
      lightIntensity = lightIntensity - 5;
      if (lightIntensity < 2) {
        lightIntensity = 2;
      }
      delay(100);
      //startMillis = currentMillis;
      display.clearDisplay();
    }
    for (int i = 20; i > 29; i++) {
      display.drawLine(2, i, lightIntensity, i, BLACK);
      display.display();
    }
    String lightIntensityStr;
    lightIntensityStr = lightIntensityStr+lightIntensity;
    if (isButtonDown(btnEnt) == true) {
      writeString(1836, lightIntensityStr);
      showSuccess();
      x = 1;
      break;
    }
  } while (x != 1);
}

void drawRec() {
  display.drawRect(2, 20, 81, 10, BLACK);
  display.display();
}

void setLatiLongi() {
  int x = 0;
  do {
    if (isButtonDown(btnUp) == true) {
      latitude = latitude + 1;
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      latitude = latitude - 1;
      delay(100);
    }
    display.clearDisplay();

    display.setCursor(0, 12);
    display.setTextColor(BLACK);
    display.print("Latitud:");
    display.fillRoundRect(50, 10, 15, 11, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(52, 12);
    display.setTextSize(1);
    display.print(latitude);

    displayLatitudef();
    display.print(latitudef);

    displayLongitude();
    display.print(longitude);

    displayLongitudef();
    display.print(longitudef);

    display.display();

    isButtonDown(btnEnt) == false;
    delay(200);
    if (isButtonDown(btnEnt) == true) {
      writeString(1800, "2");
      setLatitudef();
      x = 1;
      break;
    }
  } while (x != 1);
}

void setLatitudef() {
  int x = 0;
  do {
    if (isButtonDown(btnUp) == true) {
      latitudef = latitudef + 1;
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      latitudef = latitudef - 1;
      delay(100);
    }

    display.clearDisplay();

    displayLatitude();
    display.print(latitude);

    display.setCursor(64, 12);
    display.setTextColor(BLACK);
    display.print(".");
    display.fillRoundRect(69, 10, 15, 11, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(71, 12);
    display.print(latitudef);

    displayLongitude();
    display.print(longitude);

    displayLongitudef();
    display.print(longitudef);

    display.display();

    isButtonDown(btnEnt) == false;
    delay(100);
    if (isButtonDown(btnEnt) == true) {
      setLongitude();
      x = 1;
      break;
    }
  } while (x != 1);
}

void setLongitude() {
  int x = 0;
  do {
    if (isButtonDown(btnUp) == true) {
      longitude = longitude + 1;
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      longitude = longitude - 1;
      delay(100);
    }
    display.clearDisplay();

    displayLatitude();
    display.print(latitude);

    displayLatitudef();
    display.print(latitudef);

    display.setCursor(0, 28);
    display.setTextColor(BLACK);
    display.print("Longitu:");
    display.fillRoundRect(50, 26, 15, 11, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(52, 28);
    display.setTextSize(1);
    display.print(longitude);

    displayLongitudef();
    display.print(longitudef);

    display.display();
    isButtonDown(btnEnt) == false;
    delay(100);
    if (isButtonDown(btnEnt) == true) {
      setLongitudef();
      x = 1;
      break;
    }
  } while (x != 1);
}

void setLongitudef() {
  String zero = "0";
  int x = 0;
  do {
    if (isButtonDown(btnUp) == true) {
      longitudef = longitudef + 1;
      delay(100);
    }
    if (isButtonDown(btnDwn) == true) {
      longitudef = longitudef - 1;
      delay(100);
    }

    display.clearDisplay();

    displayLatitude();
    display.print(latitude);

    displayLatitudef();
    display.print(latitudef);

    displayLongitude();
    display.print(longitude);

    display.setCursor(64, 28);
    display.setTextColor(BLACK);
    display.print(".");
    display.fillRoundRect(69, 26, 15, 11, 3, BLACK);
    display.setTextColor(WHITE);
    display.setCursor(71, 28);
    display.print(longitudef);

    display.display();

    isButtonDown(btnEnt) == false;
    delay(100);
    if (isButtonDown(btnEnt) == true) {
      showSuccess();
      x = 1;
      break;
    }
  } while (x != 1);
}

void displayLatitude() {
  display.setCursor(0, 12);
  display.setTextColor(BLACK);
  display.print("Latitud:");
  display.setTextColor(BLACK);
  display.setCursor(52, 12);
  display.setTextSize(1);
  display.fillRoundRect(50, 10, 15, 11, 3, WHITE);
}

void displayLatitudef() {
  display.setCursor(64, 12);
  display.setTextColor(BLACK);
  display.print(".");
  display.setTextColor(BLACK);
  display.setCursor(71, 12);
  display.setTextSize(1);
  display.fillRoundRect(69, 10, 15, 11, 3, WHITE);
}

void displayLongitude() {
  display.setCursor(0, 28);
  display.setTextColor(BLACK);
  display.print("Longitu:");
  display.fillRoundRect(50, 26, 15, 11, 3, WHITE);
  display.setTextColor(BLACK);
  display.setCursor(52, 28);
  display.setTextSize(1);
}

void displayLongitudef() {
  display.setCursor(64, 28);
  display.setTextColor(BLACK);
  display.print(".");
  display.fillRoundRect(69, 26, 15, 11, 3, WHITE);
  display.setTextColor(BLACK);
  display.setCursor(71, 28);
  display.setTextSize(1);
}

void resetSetting() {

}

void selectDistrict() {
  //currentMillis = millis();
  int x = 0;
  String data = read_String(0);
  int nextIndex = data.length() + 3;
  int currentIndex = 0;

  int dataLen = data.length();
  int dashIndex = data.lastIndexOf('-');
  int comma = 1 + data.lastIndexOf(',');
  String distName, latitude, longitude, latLong;

  distName = data.substring(0, dashIndex);
  latLong = data.substring(dashIndex + 1, dataLen);
  latitude = data.substring(dashIndex + 1, comma - 1);
  longitude = data.substring(comma, dataLen);

  double latitude_ = latitude.toDouble();
  double longitude_ = longitude.toDouble();
  displayDistrict();
  //display.drawTriangle(42, 0, 34, 8, 50, 8, BLACK);
  //display.drawTriangle(42, 47, 34, 39, 50, 39, BLACK);
  display.print(distName);
  do {
    if (isButtonDown(btnUp) == true) {
      int pv_data_length = readIndex(currentIndex - 1);
      int pv_data_index = currentIndex - (pv_data_length + 2);
      data = read_String(pv_data_index);

      currentIndex = pv_data_index;

      // Next Index will be change with previous
      nextIndex = currentIndex + data.length() + 3;

      int dataLen = data.length();
      int dashIndex = data.lastIndexOf('-');
      int comma = 1 + data.lastIndexOf(',');
      String distName, latitude, longitude, latLong;

      distName = data.substring(0, dashIndex);

      displayDistrict();
      display.print(distName);
      //display.fillTriangle(42, 0, 34, 8, 50, 8, BLACK);
      //display.drawTriangle(42, 47, 34, 39, 50, 39, BLACK);
      delay(100);
      //startMillis = currentMillis;
    }

    if (isButtonDown(btnDwn) == true) {
      data = read_String(nextIndex);
      currentIndex = nextIndex;
      nextIndex = nextIndex + data.length() + 3;

      int dataLen = data.length();
      int dashIndex = data.lastIndexOf('-');
      int comma = 1 + data.lastIndexOf(',');
      String distName, latitude, longitude, latLong;

      distName = data.substring(0, dashIndex);

      displayDistrict();
      display.print(distName);
      //display.drawTriangle(42, 0, 34, 8, 50, 8, BLACK);
      //display.fillTriangle(42, 47, 34, 39, 50, 39, BLACK);
      //startMillis = currentMillis;
    }

    display.display();

    isButtonDown(btnEnt) == false;
    if (isButtonDown(btnEnt) == true) {
      clearEeprom();
      delay(100);
      writeString(1806 , data);
      showSuccess();
      x = 1;
      break;
    }
  } while (x != 1);
}

void displayDistrict() {
  display.clearDisplay();
  display.setCursor(10, 19);
  display.setTextColor(WHITE, BLACK);
  display.fillRoundRect (0, 15, display.width(), 15, 15, BLACK);
}

void showSuccess() {
  display.clearDisplay();
  display.setCursor(0, 0);
  display.setTextSize(1);
  display.setTextColor(BLACK, WHITE);
  display.print("Successfuly Changed.");
  display.display();
  delay(1000);
  showMenu();
}

void exitLoop() {
  if (isButtonDown(btnEnt)) {
    detachInterrupt(btnEnt);
    exitBool = true;
  }
}

void toggle() {
  if (isButtonDown(btnEnt))
    digitalWrite(lcdBL, !digitalRead(lcdBL));
}

bool isButtonDown(byte pin) {
  if (digitalRead(pin) == LOW) {
    delay(30);
    if (digitalRead(pin) == LOW)
      return true;
    return false;
  }
  return false;
}

void showMenu() {
  for (byte i = menuStartAt; i < (menuStartAt + LCD_ROWS); i++) {
    byte markerY = (i - menuStartAt) * MENU_ROW_HEIGHT;
    if (i == menuPos) {
      display.setTextColor(WHITE, BLACK);
      display.fillRect(0, markerY, display.width(), MENU_ROW_HEIGHT, BLACK);
    }
    else {
      display.setTextColor(BLACK, WHITE);
      display.fillRect(0, markerY, display.width(), MENU_ROW_HEIGHT, WHITE);
    }
    if (i >= MENU_LENGTH)
      continue;
    display.setCursor(3, markerY + 2);
    display.setTextSize(1);
    display.print((char*)pgm_read_word(&(menu[i])));
  }
  display.display();
}

int readIndex(int index) {
  int newStrLen =  readAddress(index);
  return newStrLen;
}

String read_String(int index) {
  int len = readAddress(index);
  char data[len + 1];
  for (int i = 0; i < len; i++) {
    data[i] = (char)readAddress(i + index + 1);
  }
  data[len] = '\0';
  return String(data);
}

int writeString(int index, String data) {
  int strLen = data.length() + 1;
  char string[strLen];
  data.toCharArray(string, strLen);
  writeAddress(index, strLen);
  int i = 0;
  for (i = 0; i < strLen; i++) {
    writeAddress(i + index + 1, string[i]);
  }
  writeAddress(index + i + 1, strLen);
  return index + strLen + 1;
}

void writeAddress(int address, byte val) {
  Wire.beginTransmission(EEPROM_I2C_ADDRESS);
  Wire.write((int)(address >> 8));   // MSB
  Wire.write((int)(address & 0xFF)); // LSB
  Wire.write(val);
  Wire.endTransmission();
  delay(5);
}

byte readAddress(int address) {
  byte rData = 0xFF;
  Wire.beginTransmission(EEPROM_I2C_ADDRESS);
  Wire.write((int)(address >> 8));   // MSB
  Wire.write((int)(address & 0xFF)); // LSB
  Wire.endTransmission();
  Wire.requestFrom(EEPROM_I2C_ADDRESS, 1);
  rData =  Wire.read();
  delay(10);
  return rData;
}

void clearEeprom(){
  for (int i = 1806; i < 1831; i++){
    Wire.beginTransmission(EEPROM_I2C_ADDRESS);
    Wire.write((int)(i >> 8));   // MSB
    Wire.write((int)(i & 0xFF)); // LSB
    Wire.write(0);
    Wire.endTransmission();
    delay(5);
  }
}

Sketch uses

Code of slave Pro mini:

#include"Wire.h"
#include "SevenSegmentExtended.h"
#include <time.h>
#include <math.h>
#include <string.h>
#define EEPROM_I2C_ADDRESS 0x50
using namespace std;
int hour, minute, second, day, month, year;
double dhuhr_minutes;
const int NUM_ITERATIONS = 1;   //number of iterations needed to compute times
double julian_date;
double latitude;
double longitude;
double Time_Zone;
String latiLongi;

static const char* TimeName[] = {"Fajr", "Sunrise", "Dhuhr", "Asr", "Sunset", "Maghrib", "Isha"};

enum JuristicMethod {Shafi, Hanafi};
enum TimeID {Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha, TimesCount};

enum CalculationMethod {
 MWL,      // Muslim World League (MWL)
 Karachi,  // University of Islamic Sciences, Karachi
 ISNA,     // Islamic Society of North America (ISNA)
 Makkah,   // Umm al-Qura, Makkah
 Egypt,    // Egyptian General Authority of Survey
 CalculationMethodsCount
};
enum AdjustingMethod {    // Adjusting Methods for Higher Latitudes
 None,       // No adjustment
 MidNight,   // middle of night
 OneSeventh, // 1/7th of night
 AngleBased, // angle/60th of night
};
struct MethodConfig {
 double fajr_angle;
 bool   maghrib_is_minutes;
 double maghrib_value;   // angle or minutes
 bool   isha_is_minutes;
 double isha_value;      // angle or minutes

 MethodConfig() {
   fajr_angle = 18.0;
   maghrib_is_minutes = true;
   maghrib_value = 0.0;    // angle or minutes
   isha_is_minutes = false;
   isha_value = 18.0;      // angle or minutes
 }

 MethodConfig(double fajr_angle,
              bool maghrib_is_minutes,
              double maghrib_value,
              bool isha_is_minutes,
              double isha_value)
   : fajr_angle(fajr_angle)
   , maghrib_is_minutes(maghrib_is_minutes)
   , maghrib_value(maghrib_value)
   , isha_is_minutes(isha_is_minutes)
   , isha_value(isha_value)
 {
 }
};

MethodConfig method_params[CalculationMethodsCount];
unsigned int calc_method ;
unsigned int asr_juristic;
AdjustingMethod adjust_high_lats;


String two_digits_format(int num);
static String int_to_string(int num);
static double fix_hour(double a);
static void get_float_time_parts(double time, int& hours, int& minutes);
String float_time_to_time24(double Time);
String float_time_to_time12(double Time, bool no_suffix = false);
double deg2rad(double d);
double rad2deg(double r);
static double dsin(double d);
static double dcos(double d);
static double dtan(double d);
static double darcsin(double x);
static double darccos(double x);
static double darctan(double x);
static double darctan2(double y, double x);
static double darccot(double x);
static double fix_angle(double a);
static double time_diff(double time1, double time2);
void sun_position(double jd, double &D, double &Eq_t);
double equation_of_time(double jd);
double sun_declination(double jd);
double compute_mid_day(double _t);
double compute_time(double g, double t);
void day_portion(double times[]);
double compute_asr(int Step, double t);
void compute_times(double times[]);
double night_portion(double angle);
void adjust_high_lat_times(double times[]);
void adjust_times(double times[]);
void compute_day_times(double times[]);
double get_julian_date(int Year, int Month, int Day);
void get_prayer_times(int Year, int Month, int Day, double _latitude, double _longitude, double _timezo, double times[]);
void get_prayer_times(time_t date, double latitude, double longitude, double Tzone, double times[]);
//const byte PIN_CLK = 4;   // define CLK pin (any digital pin)
//const byte PIN_DIO = 5;   // define DIO pin (any digital pin)
SevenSegmentExtended  display(2, 3);
SevenSegmentExtended  display1(4, 5);
SevenSegmentExtended  display2(6, 7);
SevenSegmentExtended  display3(8, 9);
SevenSegmentExtended  display4(10, 11);
SevenSegmentExtended  display5(12, 13);
//SevenSegmentExtended  display6(A0, A1);

const unsigned int clockSpeed = 10000;    // speed up clock for demo

void setup() {
 Wire.begin(9);
 //Wire.begin();
 //Serial.begin(9600);
 Wire.onReceive(receiveEvent);
 display.begin();
 display1.begin();
 display2.begin();
 display3.begin();
 display4.begin();
 display5.begin();
 //display6.begin();
 delay(1000);             // wait 1000 ms
 adjust_high_lats = None;
 dhuhr_minutes = 0;
 Time_Zone  = 6;          // +6.0 for Bangladesh
};

void receiveEvent(int bytes) {
 while (0 < Wire.available()) {
   hour = Wire.read();
   minute = Wire.read();
   second = Wire.read();
   day = Wire.read();
   month = Wire.read();
   year = Wire.read()  |  (Wire.read() << 8);
 }
}

void loop() {
 String methodNo = read_String(1800);
 char ch;
 if (methodNo == "0") {
   ch = '0';
 } else if (methodNo == "1") {
   ch = '1';
 } else if (methodNo == "2") {
   ch = '2';
 } else if (methodNo == "3") {
   ch = '3';
 } else if (methodNo == "4") {
   ch = '4';
 }
 calc_method = ch & 0x0F;
 method_params[0] = MethodConfig(18.0, true,  0.0, false, 17.0); // MWL
 method_params[1] = MethodConfig(18.0, true,  0.0, false, 18.0); // Karachi
 method_params[2] = MethodConfig(15.0, true,  0.0, false, 15.0); // ISNA
 method_params[3] = MethodConfig(18.5, true,  0.0, true,  90.0); // Makkah
 method_params[4] = MethodConfig(19.5, true,  0.0, false, 17.5); // Egypt

 String mazhubNo = read_String(1803);
 do {
   if (mazhubNo == "0") {
     ch = '0';
   } else if (mazhubNo == "1") {
     ch = '1';
   }
 } while (ch != '0' && ch != '1' );
 //Serial.println(ch);
 asr_juristic = ch & 0x0F;

 struct tm current_date;

 current_date.tm_sec   = 0;            /** < seconds after the minute - [ 0 to 59 ] */
 current_date.tm_min   = minute;       /** < minutes after the hour   - [ 0 to 59 ] */
 current_date.tm_hour  = hour;         /** < hours since midnight     - [ 0 to 23 ] */
 current_date.tm_mday  = day;          /** < day of the month         - [ 1 to 31 ] */
 current_date.tm_wday  =  0;           /** < days since Sunday        - [ 0 to  6 ] */
 current_date.tm_mon   =  month - 1;   /** < months since January     - [ 0 to 11 ] */
 current_date.tm_year  = year - 1900;  /** < years since 1900                       */

 time_t date = mktime(&current_date);
 double times[TimesCount];
 
 String data = read_String(1806);
 int dataLen = data.length();
 int dashIndex = data.lastIndexOf('-');
 int comma = 1 + data.lastIndexOf(',');
 String latitudeStr, longitudeStr, latiLongiStr;

 latiLongiStr = data.substring(dashIndex + 1, dataLen);
 latitudeStr = data.substring(dashIndex + 1, comma - 1);
 longitudeStr = data.substring(comma, dataLen);

 latitude = latitudeStr.toDouble();
 longitude = longitudeStr.toDouble();
 
 get_prayer_times(date, latitude, longitude, Time_Zone, times);

 String fajrStr = float_time_to_time12(times[0]).c_str();
 int fajrHour = fajrStr.substring(0, 2).toInt();
 int fajrMin = fajrStr.substring(2, 4).toInt();
 display.printTime(fajrHour, fajrMin, false);

 String sunRiseStr = float_time_to_time12(times[1]).c_str();
 int sunRiseHour = sunRiseStr.substring(0, 2).toInt();
 int sunRiseMin = sunRiseStr.substring(2, 4).toInt();
 display1.printTime(sunRiseHour, sunRiseMin, false);

 String dhuhrStr = float_time_to_time12(times[2]).c_str();
 int dhuhrHour = dhuhrStr.substring(0, 2).toInt();
 int dhuhrMin = dhuhrStr.substring(2, 4).toInt();
 display2.printTime(dhuhrHour, dhuhrMin, false);

 String asrStr = float_time_to_time12(times[3]).c_str();
 int asrHour = asrStr.substring(0, 2).toInt();
 int asrMin = asrStr.substring(2, 4).toInt();
 display3.printTime(asrHour, asrMin, false);

 String magribStr = float_time_to_time12(times[5]).c_str();
 int magribHour = magribStr.substring(0, 2).toInt();
 int magribMin = magribStr.substring(2, 4).toInt();
 display4.printTime(magribHour, magribMin, false);

 String ishaStr = float_time_to_time12(times[6]).c_str();
 int ishaHour = ishaStr.substring(0, 2).toInt();
 int ishaMin = ishaStr.substring(2, 4).toInt();
 display5.printTime(ishaHour, ishaMin, false);

 int brightNess = read_String(1832).toInt();
 display.setBacklight(brightNess);
 display1.setBacklight(brightNess);
 display2.setBacklight(brightNess);
 display3.setBacklight(brightNess);
 display4.setBacklight(brightNess);
 display5.setBacklight(brightNess);
 //display6.setBacklight(brightNess);

 delay(1000);
};

String two_digits_format(int num) {
 char tmp[16];
 tmp[0] = '\0';
 sprintf(tmp, "%2.2d", num);
 return String(tmp);
}
static String int_to_string(int num) {
 char tmp[16];
 tmp[0] = '\0';
 if (num >= 0 && num <= 9) sprintf(tmp, "0%d", num);
 else sprintf(tmp, "%d", num);
 return String(tmp);
}

static double fix_hour(double a) {
 a = a - 24.0 * floor(a / 24.0);
 a = a < 0.0 ? a + 24.0 : a;
 return a;
}
static void get_float_time_parts(double time, int& hours, int& minutes) {
 time = fix_hour(time + 0.5 / 60);   // add 0.5 minutes to round
 hours = floor(time);
 minutes = floor((time - hours) * 60);
}
String float_time_to_time24(double Time) {
 if (isnan(Time))
   return String();
 int hours, minutes;
 get_float_time_parts(Time, hours, minutes);
 return two_digits_format(hours) + two_digits_format(minutes);
}
String float_time_to_time12(double Time, bool no_suffix = false) {
 if (isnan(Time))
   return String();
 int hours, minutes;
 get_float_time_parts(Time, hours, minutes);
 const char* suffix = hours >= 12 ? " PM" : " AM";
 hours = (hours + 12 - 1) % 12 + 1;
 return int_to_string(hours) + two_digits_format(minutes);
}
double deg2rad(double d) {
 return d * M_PI / 180.0;
}
double rad2deg(double r) {
 return r * 180.0 / M_PI;
}
static double dsin(double d) {
 return sin(deg2rad(d));
}
static double dcos(double d) {
 return cos(deg2rad(d));
}
static double dtan(double d) {
 return tan(deg2rad(d));
}
static double darcsin(double x) {
 return rad2deg(asin(x));
}
static double darccos(double x) {
 return rad2deg(acos(x));
}
static double darctan(double x) {
 return rad2deg(atan(x));
}
static double darctan2(double y, double x) {
 return rad2deg(atan2(y, x));
}
static double darccot(double x) {
 return rad2deg(atan(1.0 / x));
}
static double fix_angle(double a) {
 a = a - 360.0 * floor(a / 360.0);
 a = a < 0.0 ? a + 360.0 : a;
 return a;
}
static double time_diff(double time1, double time2) {
 return fix_hour(time2 - time1);
}
void sun_position(double jd, double &D, double &Eq_t) {
 double d = jd - 2451545.0;  // jd is the given Julian date
 double g = fix_angle(357.529 + 0.98560028 * d);
 double q = fix_angle(280.459 + 0.98564736 * d);
 double L = fix_angle(q + 1.915 * dsin(g) + 0.020 * dsin(2 * g));
 double R = 1.00014 - 0.01671 * dcos(g) - 0.00014 * dcos(2 * g);
 double e = 23.439 - 0.00000036 * d;
 double RA = darctan2(dcos(e) * dsin(L), dcos(L)) / 15.0;
 D = darcsin(dsin(e) * dsin(L));  // declination of the Sun
 RA = fix_hour(RA);
 Eq_t = q / 15.0 - RA;      // equation of time
}
double equation_of_time(double jd) {
 double D;
 double Eq_t;
 sun_position(jd, D, Eq_t);
 return Eq_t;
}
double sun_declination(double jd) {
 double D;
 double Eq_t;
 sun_position(jd, D, Eq_t);
 return D;
}
double compute_mid_day(double _t) {
 double t = equation_of_time(julian_date + _t);
 double z = fix_hour(12 - t);
 return z;
}
double compute_time(double g, double t) {
 double d = sun_declination(julian_date + t);
 double z = compute_mid_day(t);
 double v = 1.0 / 15.0 * darccos((-dsin(g) - dsin(d) * dsin(latitude)) / (dcos(d) * dcos(latitude)));
 return z + (g > 90.0 ? - v :  v);
}
void day_portion(double times[]) {
 for (int i = 0; i < TimesCount; ++i) {
   times[i] /= 24.0;
 }
}
double compute_asr(int Step, double t) {
 double d = sun_declination(julian_date + t);
 double g = -darccot(Step + dtan(fabs(latitude - d)));
 return compute_time(g, t);
}
void compute_times(double times[]) {
 day_portion(times);
 times[Fajr]    = compute_time(180.0 - method_params[calc_method].fajr_angle, times[Fajr]);
 times[Sunrise] = compute_time(180.0 - 0.833, times[Sunrise]);
 times[Dhuhr]   = compute_mid_day(times[Dhuhr]);
 times[Asr]     = compute_asr(1 + asr_juristic, times[Asr]);
 times[Sunset]  = compute_time(0.833, times[Sunset]);
 times[Maghrib] = compute_time(method_params[calc_method].maghrib_value, times[Maghrib]);
 times[Isha]    = compute_time(method_params[calc_method].isha_value, times[Isha]);
}
double night_portion(double angle) {
 switch (adjust_high_lats)
 {
   case AngleBased:
     return angle / 60.0;
   case MidNight:
     return 1.0 / 2.0;
   case OneSeventh:
     return 1.0 / 7.0;
   default:
     // Just to return something!
     // In original library nothing was returned
     // Maybe I should throw an exception
     // It must be impossible to reach here
     return 0;
 }
}
void adjust_high_lat_times(double times[]) {
 double night_time = time_diff(times[Sunset], times[Sunrise]);   // sunset to sunrise

 // Adjust Fajr
 double fajr_diff = night_portion(method_params[calc_method].fajr_angle) * night_time;
 if (isnan(times[Fajr]) || time_diff(times[Fajr], times[Sunrise]) > fajr_diff)
   times[Fajr] = times[Sunrise] - fajr_diff;

 // Adjust Isha
 double isha_angle = method_params[calc_method].isha_is_minutes ? 18.0 : method_params[calc_method].isha_value;
 double isha_diff = night_portion(isha_angle) * night_time;
 if (isnan(times[Isha]) || time_diff(times[Sunset], times[Isha]) > isha_diff)
   times[Isha] = times[Sunset] + isha_diff;

 // Adjust Maghrib
 double maghrib_angle = method_params[calc_method].maghrib_is_minutes ? 4.0 : method_params[calc_method].maghrib_value;
 double maghrib_diff = night_portion(maghrib_angle) * night_time;
 if (isnan(times[Maghrib]) || time_diff(times[Sunset], times[Maghrib]) > maghrib_diff)
   times[Maghrib] = times[Sunset] + maghrib_diff;
}
void adjust_times(double times[]) {
 for (int i = 0; i < TimesCount; ++i)
   times[i] += Time_Zone - longitude / 15.0;

 times[Dhuhr] += dhuhr_minutes / 60.0;   // Dhuhr

 if (method_params[calc_method].maghrib_is_minutes)    // Maghrib
   times[Maghrib] = times[Sunset] + method_params[calc_method].maghrib_value / 60.0;

 times[Isha];

 if (method_params[calc_method].isha_is_minutes)   // Isha
   times[Isha] = times[Maghrib] + method_params[calc_method].isha_value / 60.0;

 if (adjust_high_lats != None)
   adjust_high_lat_times(times);
}
void compute_day_times(double times[]) {
 double default_times[] = { 5, 6, 12, 13, 18, 18, 18 };    // default times
 for (int i = 0; i < TimesCount; ++i)
   times[i] = default_times[i];

 for (int i = 0; i < NUM_ITERATIONS; ++i)
   compute_times(times);

 adjust_times(times);
}
double get_julian_date(int Year, int Month, int Day) {
 if (Month <= 2){
   Year -= 1;
   Month += 12;
 }

 double a = floor(Year / 100.0);
 double b = 2 - a + floor(a / 4.0);
 double c = floor(365.25 * (Year + 4716)) + floor(30.6001 * (Month + 1)) + Day + b - 1524.5;

 return c;
}

void get_prayer_times(int Year, int Month, int Day, double _latitude, double _longitude, double _timezo, double times[]) {
 latitude = _latitude;
 longitude = _longitude;
 Time_Zone = _timezo;
 julian_date = get_julian_date(Year, Month, Day);
 julian_date = julian_date - longitude / (double) (15 * 24);
 compute_day_times(times);
}
void get_prayer_times(time_t date, double latitude, double longitude, double Tzone, double times[]) {
 tm* t = localtime(&date);
 get_prayer_times((1900 + t->tm_year), (t->tm_mon + 1), (t->tm_mday), latitude, longitude, Tzone, times);
}

int readIndex(int index) {
 int newStrLen =  readAddress(index);
 return newStrLen;
}

String read_String(int index) {
 int len = readAddress(index);
 char data[len + 1];
 for (int i = 0; i < len; i++) {
   data[i] = (char)readAddress(i + index + 1);
 }
 data[len] = '\0';
 return String(data);
}

int writeString(int index, String data) {
 int strLen = data.length() + 1;
 char string[strLen];
 data.toCharArray(string, strLen);
 writeAddress(index, strLen);
 int i = 0;
 for (i = 0; i < strLen; i++) {
   writeAddress(i + index + 1, string[i]);
 }
 writeAddress(index + i + 1, strLen);
 return index + strLen + 1;
}

void writeAddress(int address, byte val) {
 Wire.beginTransmission(EEPROM_I2C_ADDRESS);
 Wire.write((int)(address >> 8));   // MSB
 Wire.write((int)(address & 0xFF)); // LSB
 Wire.write(val);
 Wire.endTransmission();
 delay(5);
}

byte readAddress(int address) {
 byte rData = 0xFF;
 Wire.beginTransmission(EEPROM_I2C_ADDRESS);
 Wire.write((int)(address >> 8));   // MSB
 Wire.write((int)(address & 0xFF)); // LSB
 Wire.endTransmission();
 Wire.requestFrom(EEPROM_I2C_ADDRESS, 1);
 rData =  Wire.read();
 delay(10);
 return rData;
}

Sketch uses

My question is:

  1. Why the master hang or stop responding?
  2. Is it for multiple I2C communication at a time using same pin(All of them use only A4 And A5 ) ?
  3. Is the code size is too big and at tha same time transmit data that's why hang or stop?

New problem: The UNO receive unknown value from ds1307.

What makes you say that the code is too big to post here ?

Post is updated with code.

Thank you

If your I2C bus is really bad, then it can halt the sketch.
Please show us a photo, that shows the wiring of the I2C bus.
You can use a single 4k7 pullup resistor at the Master. But a few 10k here and there is no problem.
To solve noise problems on the I2C bus, a timeout was added. The Wire.setWireTimeout() should be called after Wire.begin().
https://github.com/arduino/ArduinoCore-avr/blob/master/libraries/Wire/src/Wire.cpp#L90

I thought that the Nokia 5110 LCD display was a 3.3V display and that resistors are used between a 5V Arduino and the 3.3V 5110 display. My 5110 was very faint and worn out. Are you sure that you want to use it, instead of a new modern display ?

Master sketch: At first glance I see no major issues. Some code seems to be redundant. Check what the RTC library can do, I think you can use some of those functions instead of your own code. We prefer a sketch that is responsive has no delay and does not wait in do-while loops. There are libraries that debounce buttons, that will also make your sketch smaller.

Slave sketch: No major issues here at first glance. A Arduino Uno / Mega / Nano / Pro Mini uses 32-bit 'float' instead of 'double'. Is that good enough for your project ? I doubt it, with so many calculations. The String class is used a lot, I don't know if that causes problems in the heap. The global variables that are used in receiveEvent() should be 'volatile'.

How is the UNO powered?

both UNO and pro mini powered from my laptop through usb.

Fine. Then power problems can be ruled out.
You use some while statements that look like road blocks. Any chance they can be the reason?

Try by changing String data types to cstring in both UNO and Pro.

1 Like

Is the code size is too big for UNO and its RAM and At the same time transmit data that's why hang or stop?

New problem: The UNO receive unknown value from ds1307.

Ok i will try it.

Can you write down in plain text using serial numbers what do you want to achive from your this hardware setup: UNO-Pro-EEPROM-RTC-LCD-7SDU.

Note: You are missing common ground connection in your diagram of Post-1! Check that you have also missed it in the actual wiring!

2 Likes

Several of the places you use String can simply be replaced by directly printing the leading '0'.

Your PROGMEM arrays of char* do not store the actual text in PROGMEM, only the pointers. The text strings are being stored in ram.

Is there a reason you cannot use a mega or some other board with more memory?

No in actual wiring i also put the common GND. But in this picture i missed to point out it.

In Uno I have 3 buttons for set time and setting and nokia5110 lcd for showing what changes are done.
Here i also save the changed setting in eeprom 24lc512 using master UNO.

Also read time from rtc and send the time to the slave pro mini using i2c.
Because slave Arduino pro mini need the time to calculate the Muslim prayer time.

In pro mini I received time from UNO and read some data(settings value that i saved previously from UNO) from eeprom 24lc512 and then calculate Muslim Prayer Time
Finally show the prayer time in 4 digit 7 segment .

That's it......

You have said that your system works for a while!
1. 7-segment Display Unit is connected with Pro; then why have you included SevenSegmentExtended.h librray with Master?

2. In Master code, you have the object display. But, in the code there is another uncreated object named display1. Why?

3. In master code, you have an unefined routine named: menuHome().

Please, recompile your Master sketch and remove the redundant codes.

I have also connect a 7segment with Master to show current time.

display object is used for nokia 5110 display. And display1 object is used for 7segment with Master to show current time.

homePage() function is to show this

and menuHome() is used for menu below

Have you created it? Check your sketch. I have encountered compilation ertor.

yes i created.

But i can successfully compile and run it.

Did you mean to use CString ?
So do i need to add #include<string.h> library ?
But what is the benefit of using CString instead of String ?

I think the problem that I faces is caused for I2C communication. But I am not sure about that.
I just guessed it. Because:

  1. All of the I2C devices are connected to the Master with same two pin A4 and A5.
  2. Master read data from two I2C devices(ds1307 rtc and 24lc512 eeprom) and transmit it to slave at the same time using same I2C pin A4 and A5.
  3. Slave also receive data from Master and read data from same eeprom using I2C communication at the same time.

Is this multiple I2C communication with same pin are conflicted and which causes hang ?
Or is it because the code is biggerand RAM is not enough to run the code?

Any suggestions or advice?