Conflict between LiquidCrystal.h and Real Time Clock Libraries

I am making an alarm clock as a Christmas present, I am using a 20 column 4 row LCD display and a DS3231 I2C breakout. The LCD display is compatible with the LiquidCrystal.h library, and I was planning to use the RTClib.h library for the clock. I will add my full code at the bottom, since it is somewhat long.

My problem is that I think that the RTC library I am using is incompatible with LiquidCrystal.h. This is my set-up:

#include <RTClib.h>
#include <LiquidCrystal.h>

#define alarmPin 8
#define alarmNum 4
#define hourSet 3
#define minSet 2
#define buzzer 10
#define numberOfAlarms 2
#define R_LED 6
#define G_LED 9
#define B_LED 11

LiquidCrystal lcd(A0,A1,13,12,7,5,A2,A3,A4,A5);
RTC_DS3231 RTC;

uint8_t brightness = 255;
const char* DOW[7] = {"Sun. ", "Mon. ", "Tues. ", "Wed. ", "Thurs. ", "Fri. ", "Sat. "};

// mode 0 is neither, mode 1 is set alarm 1, mode 2 is set alarm 2
uint8_t alarmset_mode = 0;
// the hour set on alarm 1
uint8_t alarm_hr_1 = 0;
// the minute set on alarm 2
uint8_t alarm_min_1 = 0;
// the hour set on alarm 2
uint8_t alarm_hr_2 = 0;
// the minute set on alarm 2
uint8_t alarm_min_2 = 0;
// mode 0 is neither alarm, mode 1 is first alarm, mode 2 is second alarm, mode 3 is both
uint8_t alarm_active = 0;

uint16_t hourupg;
uint16_t minupg;
uint16_t secupg;
uint16_t yearupg;
uint16_t monthupg;
uint16_t dayupg;
uint16_t weekdayupg;

void setup() {
  // initialize LCD screen
  lcd.begin(20,4);
  lcd.clear();

  Serial.begin(9600);
  
  // disable 32K pin
  RTC.disable32K();

  // pinmode sets
  pinMode(buzzer, OUTPUT);
  pinMode(R_LED, OUTPUT);
  pinMode(B_LED, OUTPUT);
  pinMode(G_LED, OUTPUT);
  pinMode(minSet, INPUT_PULLUP);
  pinMode(hourSet, INPUT_PULLUP);
  pinMode(alarmNum, INPUT_PULLUP);
  pinMode(alarmPin, INPUT_PULLUP);

  setBacklight(255,255,255);
  analogWrite(buzzer, 255);

  // clock and wire begin
  RTC.begin();

  // configure RTC
  if (RTC.lostPower()) {
    // set time at compile time
    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
    alarmset_mode = 0;
  }

  
}

The LCD display will only display gibberish when I actually run the loop, and I experimented to figure out the cause.

  1. When I place
while(true){
    lcd.setCursor(0,0);
    lcd.print(10000000);
  }

before I write RTC.begin()
It prints off "1000" correctly on the first line of the LCD.
2) When I write it after, it prints gibberish
3) When I write it after, but comment out "RTC.begin()", it prints correctly again
I'm not very familiar with I2C, so I don't really know if/why it would interfere with parallel communications off of totally separate pins. I attached pictures of the "gibberish" I am talking about. I ran out of character space to put the full code in here, but if someone thinks that the cause is not the RTC board, let me know and I can post the rest.

Thanks in advance

a DS3231 I2C

LiquidCrystal lcd(A0,A1,13,12,7,5,A2,A3,A4,A5);

Please always post what Arduino you are using and post a schematic of your setup.

I2C occupies the A4 and A5 pin on the UNO.
Don't use them for the LCD if you need I2C

Ugh thank you, that had been giving me headaches for days now. It's working perfectly now. If I wasn't so short on pins I'd have probably switched them around already and figured out that the I2C takes those pins.

Sorry for not posting the schematic/picture of wiring, I will make sure to do that next time.

that's fine if you could solve it.

If you are short on pins consider either

  • 4 bit mode instead of 8bit mode,
  • an i2c-Adapter for the LCD