DS3231 and TFT LCD display functions seem not compatible

Hi everybody,

first time posting because I think I've bitten more than I can chew on my own. I have this project of a weather station using an Arduino UNO, a TFT LCD display, a DS3231 RTC module and a BME280 sensor. I have had the UNO and the DS3231 module for a while, unused from a pet feeder project that I didn't finish. I bought the other components checking the compatibility with the UNO. I'll probably add a button because I want the display to show everything on demand and I forgot to buy one.

So far, I'm adding every component at a time, because I don't want to start too big and spend all the time debugging a complex error.

I've found that the TFT LCD is an ILI9486 model and downloaded the library from 3.5inch Arduino Display-UNO - LCD wiki and I started with the display using the examples and wiring directions.

*      3,5"  TFT   LCD_CS  LCD_CD  LCD_WR  LCD_RD  LCD_RST  SD_SS  SD_DI  SD_DO  SD_SCK 
*     Arduino Uno    A3      A2      A1      A0      A4      10     11     12      13                            
              

*      3,5"  TFT   LCD_D0  LCD_D1  LCD_D2  LCD_D3  LCD_D4  LCD_D5  LCD_D6  LCD_D7  
*     Arduino Uno    8       9       2       3       4       5       6       7

Everything works fine with the simple programs and the more complex ones I've tried from the example folder provided with the library.

Then I've added the DS3231 RTC module. I've plugged it into the SDA and SCL pins because so many of the UNO pins are used by the LCD display and I'm using a library from DS3231 - Rinky-Dink Electronics, checking again with one simple program and one more complex that works fine. Everything is fine on the serial monitor.

But when I start integrating everything in one program, it's not working anymore. The compilation doesn't show any error. I've checked my code by excluding part of the functions and I've found that once I'm calling one of the rtc.getXXXXStr (XXXX being time, DOW or date) or even the rtc.getTime function adapted from a more complex example program, the LCD doesn't display anything anymore, and every mylcd.xxx function gets ignored.

Could it be that the functions of the 2 libraries aren't compatible? Any idea to help sort this issue and make this project work please?

Pin A4 on the Uno is connected to the SDA pin used by I2C, so you are trying to use pin A4 for two different purposes. Try putting LCD_RST on a different pin. Not A5 because that is connected to the SCL pin

Thanks for your answer! I'm afraid I'll need more guidance because all the analog pins are mapped already and I'm not sure I can swap SDA/SCL to 2 digital pins, like 10 to 13 pins of the UNO.

All the SD_XX pins of the LCD are linked to the microSD card reader included with the LCD which I don't plan to use in any way. Would it be ok for me to free them and use 2 of the UNO digital pins to wire the DS3231?

Fairly easy to move LCD_RST from A4 to the RESET pin of the Uno, then initialize the LCD in setup before initializing any I2C devices so that the LCD library does not override the A4 settings for I2C. If I recall correctly, I put a 10k resistor between LCD_RST and RESET just to be safe.

Hello and thank you again.

Instead of asking new questions as I did yesterday evening, I did the test as you proposed and it's working perfectly! Thanks a lot!