Can't get DS3234 RTC Chip data to LCD Display

This is my first Arduino project so I’m thinking I may be missing a “big picture” item here. I have an Uno R3, DS3234 Realtime Clock board and a 1602 LCD display up and running. The clock chip successfully writes time and date data to the Arduino serial monitor using the DS3234_Example_Code sketch. I can put lcd.print() statements at the beginning of setup and they successfully get written to the lcd display. But once the loop gets going, lcd.print() statements do not work. Random characters are output to the display. If I disable the RTC_init function I can write text to the display from the loop. Is there some incompatablity between the clock chip and lcd display that I don’t understand?

DS3234_Example_Code.ino (2.58 KB)

Which Arduino are you using? How is it wired?

It appears from your code that you are using SPI to communicate with the RTC. On the Uno this uses pins 10, 11, 12 & 13. You also appear to be using pins 10, 11 & 12 to communicate with the LCD?

One of the advantages of the LiquidCrystal library, which sadly is not only not emphasized but is completely ignored in the tutorial, is the fact that any available I/O pin on the Arduino can be used for any of the signal or data lines required by the LCD.

The idea is that you inventory the pins used by all of the other peripherals in your project, in this case the pins used by the RTC, and then choose different pins for your LCD. You then inform the library which pins you are using by means of the LiquidCrystal lcd(...) statement.

You must make sure to put the pin numbers in the proper order as shown in the first comment in the code fragment below which is unfortunately missing from the tutorial example.

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

Don

dannable: Which Arduino are you using? How is it wired?

It appears from your code that you are using SPI to communicate with the RTC. On the Uno this uses pins 10, 11, 12 & 13. You also appear to be using pins 10, 11 & 12 to communicate with the LCD?

The Arduino is indeed an Uno R3. I'm using D2 for the RTC chip select and the ICSP pins for the SPI

CLK - ICSP3 MISO - ICSP1 MOSI - ICSP4

I'm assuming this does not interfere with using D12-11-10-9-8-7 for driving the LCD.

floresta: One of the advantages of the LiquidCrystal library, which sadly is not only not emphasized but is completely ignored in the tutorial, is the fact that any available I/O pin on the Arduino can be used for any of the signal or data lines required by the LCD.

The idea is that you inventory the pins used by all of the other peripherals in your project, in this case the pins used by the RTC, and then choose different pins for your LCD. You then inform the library which pins you are using by means of the LiquidCrystal lcd(...) statement.

You must make sure to put the pin numbers in the proper order as shown in the first comment in the code fragment below which is unfortunately missing from the tutorial example.

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

Don

Yes, I have initialized the LCD in the proper sequence in which it is wired. RS-D12, E-D11, D4-D10, D5-D9, D6-D8, D7-D7. Text is successfully printed to the LCD at the beginning of setup. But in the loop lcd.print() statements do not work, printing only random characters to the screen. If I disable (comment out) both the RTC_init and SetTimeDate functions, then lcd.print() works. Both of those functions involve the SPI and that's why I'm wondering if there is some conflict between the 2 chips.

The Uno has ICSP pins for the the SPI data lines mirrored on D11-D13. You will still have the pin conflicts with the lcd even though you are using the physical ICSP location. You will indeed have to change your lcd wiring and the pin descriptor.

Aha. My assumptions about the pins were wrong. Thank you sir, I will make the necessary adjustments.

Thank you cattledog that was the problem, you are indeed a god.