interference between SPI device and SD sheld data logger(hardware and software)

I am currently working on a project which requires me to take measurements of temperature and record the data only an SD card.
I am using the following components to achieve this.

Arduino Mega 2560
Playingwithfusion max31855k 4ch type k thermal-couple sensor break out board (only two channel is used)
Adafruit Assembled Data Logging shield

The 4ch thermalcouple board comes with their own libarary and some example sketches. I have tested and confirmed that this circuit works on its own. The board uses SPI and PINs 7, 8 for CS.

The data logging shield is designed for a arduino uno. but it can be configured to work with a mega. I have also got the test code for this to work. The adafruit board have an onboard RTC which have been synced to the correct time, this uses the I2c communication.

The problem appeared when I tried to connected both of them to arduino.
The two pins that is being shared by the two SPI devices are SCK and MISO. When calling SD.begin, the error message shows up. this happens with us running the temperature sensor board and only running the code for the SD shield.

It appears that the hardware of the two SPI devices are interfering with each other. But i cant not work out the reason.

I also tested with only one device connected at a time, and running the codes(combined). again, the SD.begin returned error.

after doing some trial and error, it seems when ever i have SPI.begin in the code, SD.begin returns the error message.

I have looked around and found some with similar problems. But in the end could not solve the problem. The temperature sensor board uses their own libarary, this may be the reason behind the conflict?

I'm new to this forum, please feel free if to ask questions or correct any mistakes i've made.

This seems to be a long standing problem with ethernet shields, and I am hoping that someone somewhere can suggest an answer.

The MISO (Master in Slave out) is the data from all the devices to the Arduino Mega. They are tied together, and that is normal for a SPI bus. When a device is not selected it should make its MISO high impedance, so other devices can use the SPI bus.

There are however many shields and chips that don't make the MISO high impedance. Sometimes extra hardware on the shield is added to make that possible, sometimes extra hardware on the shield to level shift the signals (for example from 3.3V to 5V logic) is the problem itself, because the level shifter does not make the MISO high impedance when the device is not selected.

Another problem is that sometimes a 3.3V MISO is combined with a 5V MISO, and current from the 5V MISO will flow into the device with the 3.3V MISO signal.

These are indeed a serious problem when combining shields with SPI.
A solution can be to look into the schematics and try to fix it by adding hardware or changing things on the shield.

So i finally got my system to work, it turns out the SD library that i downloaded from Adafruit's website uses sofeware SPI. This seems to be the fundamental problem as soft and hard SPI can not use the same pins. So all i had to do was use 4 different pins for my SD shield.

1 Like

Thanks for sharing :slight_smile: