How to connect LCD i2c display and DS3231 i2c on arduino

Hi there,

Recently I got a problem where I need to use rtc and display in order to control temperature in my flat.

The problem for me is the thing that I am not sure is it possible to use libraries for DS3231(RTC) and LicquidCrystal_i2C(LCD) together in my code?

So does anybody have experience with this, is it possible to use these two libs in conjunction with I2C port on arduino?

If yes, could you please provide me with some example code?

Thanks :slight_smile:

I think there should be no problem.

Just choose a library for your DS3231 RTC module such as this one and ensure you successfully run one example sketch. You can also set time and date at that moment, so you don't need to do it later.

Then choose a library for your LCD display such as this one and ensure you successfully run one of the example sketch.

When everything is fine, try making your own code using the bases you just learned.

lesept:
I think there should be no problem.

Just choose a library for your DS3231 RTC module such as this one and ensure you successfully run one example sketch. You can also set time and date at that moment, so you don't need to do it later.

Then choose a library for your LCD display such as this one and ensure you successfully run one of the example sketch.

When everything is fine, try making your own code using the bases you just learned.

Probably you have missed, but my LCD is I2C too and the lib for LCD that you have provided is for SPI protocol?

thanks :slight_smile:

To run a sketch using I2C bus you may need an I2C scanner sketch and maybe also pull-up resistors.

Sorry for the lib. I'm on a cellphone, it's not easy to check everything... You may try this one or Google for 'arduino lcd i2c library'

lesept:
To run a sketch using I2C bus you may need an I2C scanner sketch and maybe also pull-up resistors.

Sorry for the lib. I'm on a cellphone, it's not easy to check everything... You may try this one or Google for 'arduino lcd i2c library'

No problem, thank you for quick response, you have saved my day :slight_smile: cheers!

Try that and come back if help needed

With due respect to lesept, but a better library for I2C LCDs (my opinion) is the hd44780 library. That library has the facility to auto detect the LCD I2C address and, more importantly, the I2C expander chip to LCD pin mapping (which can be a huge stumbling block for new users).

When used with another I2C device the address may have to be specified in the LCD constructor. Sometimes the address auto detect will pick the other (RTC) device first. In that case, run the i2C scanner, if necessary, to get the LCD address and put that address in the LCD constructor.

The library is available through the library manager. In the Topic drop down, choose Displays and in filter, enter hd44780. Then select and install the hd44780 library by Bill Perry.

@groundFungus you are right, I have seen this library before, but never used it. I prefer OLED to LCD displays...