LoRa Shield and SD Card with arduino

Hello guys,

I am trying to use LoRa Shield and SD Card module with arduino.

If i run them separaetely , they run fine. But if i try to run them togehter the LoRa fails.
I know they both are using SPI Bus.

LoRa Shield CS = 5
SD Card Module CS = 4


#include <SPI.h>
#include <RH_RF95.h>
#include <SD.h>

File myFile;


// Single instance of RH_RF95 
RH_RF95 rf95(5,2);


void setup()
{
 Serial.begin(9600);

delay(500);

  if (!rf95.init())
  {
    Serial.println("init failed");
  }
  
delay(2000);

Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");

}

  delay(2000);
}


void loop()
{
 
}

Could you please help me.

Thank you very much

looking for:

void setup()
{
pinMode (CS1, OUTPUT);
pinMode (CS2, OUTPUT);
SPI.begin();
}

looking for:

int digitalPotWriteRed(int value)
{
digitalWrite(CS1, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS1, HIGH);
} int digitalPotWriteGreen(int value)
{
digitalWrite(CS2, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS2, HIGH);
}
...

search term: arduino multiple SPI

bottom line: you have to turn one CS off, then turn the other one on. either, or the other, not both

http://www.learningaboutelectronics.com/Articles/Multiple-SPI-devices-to-an-arduino-microcontroller.php

In this case the usual suspect is the SD card module. You should check that your SD card module correctly handles the SPI bus signals. It's usually the MISO signal that is causing the problems, which only becomes apparent when a 2nd device is added to the SPI bus.

Search the forums and you should find several discussions on the subject along with solutions.

Thank you @markd833

You are right. I also think SD Card module is making the problem. I have spent a lot of time to fix it. And i could not find the solution on internet also. But I gonna spend some more time with it.

From memory, the solution was for the MISO signal to bypass the "level shifting" chip. Something like: Lift the MISO signal pin on the chip on the header side and route the MISO signal direct from the SD card socket to the header. Note that there may have been a diode in there as well.

A search for "arduino sd card miso fix" via google will bring up many discussions.

Solder one wire, cut one trace:


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