Using Arduino SDA & SCL pins

Hi All,

I have a SPI controlled LCD attached to the SDA and SCL pins of Arduino Micro as per schematic below. When I attach the I2C Real time clock using the same pins, I cannot get it to work. I am already using the SPI pins MOSI MISI SCK & SS for a SD card reader (DFR0229). In isolation, both the RTC and LCD work fine. I'm usure if this is even possible, please could someone explain my options?

Thanks!

Your display has a serial interface (among others) NOT an I2C interface. Connecting it to the I2C pins messes up the other I2C devices.

Don't do that! SPI and I2C (SCL/SDA) are different bus systems.

I doubt that. An SPI controlled LCD cannot work with the Wire library on SCL and SDA. Please correct your module description and wiring diagram.

The SPI bus, being a bus after all, is meant to accommodate multiple devices.

Reusing or double use of the I2C pins for SPI is gonna present problems.

On the same hand, or is it the other hand, there have been reports about some SD card devices not playing nice on the SPI bus…

You may need to figure that out or move to a I2C LCD device and let the SD card own the SPI capability.

a7

You need an SPI interface as described on page 55 of the data sheet. You are part way there, you just need to use some other pins for for SI and CLK

That is correct. I am using the SPI.h library with the SPI controlled LCD with the SDA and SCL pins as per schematic. This works fine as long as I do not attach the RTC to the same pins.

The LCD is using the SPI bus and SPI.h library, not the Wire.h library.

An SPI device, without a chip select is not capable of sharing the SPI bus. You would likely need to connect the E pin on the display to a digital output of the Arduino, and configure it as the CS signal for the display. But, it looks like you have the same problem with the RTC, which does not appear to even HAVE a CS pin, so you have a real problem there. It is probably not possible to use those two devices on the same SPI bus. But you could perhaps use software SPI to connect the RTC to two different pins on the Arduino, if your application can tolerate the CPU overhead that would require.

Pins SCK, MOSI and MISO are designed for SPI, while SCL and SDA are designed for I2C. You should obey the rules.

If I replace the LCD for an I2C device, I should be able to use it with the RTC module on the same SDA & SCL pins? My next issue is that when I use the I2C scanning programme within the Arduino IDE, it did not report back the address of the RTC module (with LCD detached!). Without the address I won't be able to add another IC2 LCD device and control them individually.

Yes, I got that from an internet search. As it worked without an issue for other projects I left it. In the other projects, no other modules were attached to pins SDA and SCL.

The DS3231 is an I2C device.

Yes, I got the DS3231 working by itself.

You are trying to use the SDA and SCL two different ways. I2C is a bidirectional protocol with device addressing and SPI isn't (addressing is done via the CS lines). When you tell both of them to use the same pins they will fight it out. One (or maybe neither) will win and at least one device won't work.

If you use the common LCD with I2C pack pack it will coexist with the DS3231. They will have separate I2C addresses and will show up when you do the scan.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.