I have a Dragon LoRa 1.3 shield hooked up to an Arduino Mega. The Mega also has an SD card breakout with pin 53 as chipSelect pin. The Dragino shield uses pin 10 as chipSelect. The Dragino shield and code by itself work like a charm, so does the SD breakout and code. But when I hook both of them up together, the SD card can not be initialized most of the time (sporadically it works). I have the feeling as if the two things interfere with each other and have done some googling, but can't lay my hand on what I am doing wrong. Any ideas?
SurferTim:
Some SD card readers do not share the SPI bus. Can you post a link to your SD card reader?
That's probably what it is - I thought I might burn some hardware whilst prototyping, so u got these: Micro SD card mini TF card reader module SPI interfaces with level converter chip for arduino
That looks like a suspect card. If that is a Catalex design, which it appears to be, all lines go through that logic level converter, including the MISO line. In early models, the output enable (OE) for the MISO line was connected to ground. That made the MISO line always active, and would not release the MISO line to allow other devices to use the SPI bus. In newer models, the MISO OE is connected to the CS pin, so it will release the MISO line when the CS (slave select) is taken HIGH.
The only difference between the two is the one circuit board trace.
Thank you so much! What a pity - this has taken me hours over hours. I guess I'll just bin them. Is there any particular microSD card breakout that you can recommend?
To be honest, I'm not familiar with any of the SD card readers. I dislike recommending anything I haven't tried, or at least heard from other users that they work ok.
I found a work-around, at least for my issue. I need to read configuration settings from an SD card during setup. Then I do not read the card any more. So I added a small relay to my system and power the SD card via the relay.
Upon startup, I do the following:
pinMode(SDPowerPin, OUTPUT);
digitalWrite(SDPowerPin, HIGH);
delay(1000);
// read the data from the card that I need.
// then turn the poser off to the card.
digitalWrite(SDPowerPin, LOW);
delay(1000);
// then call the initialization for the dragino LORA logic
As long as there is no power to the SD card when you initialize the Dragino, it works fine.