Conflict with more than one sensor, libraries default pins

I am doing a project in which I use an RFID MRC522, a RTC ds1302, an I2C with its display and finally a SD card reader-writer. The problem is that I do not have the availability of all the pins that come preset in the libraries, in my case I can not run the SD reader-writer. Is there any way to use other pins for this sensor, how?

it looks complicated.. . do you have a screenshot?

yes, here is



this is only the setup

as you can see I tried to rename the variables but it doesn't work it still doesn't read the sd

where is the problem in the code?

the code no have any problems, he compileted. But in the serial plotter always appear the message " sd did not initialize"

im from Argentina, but i traduce for you the message wich appears in the console. This message is because i do a check before run the program

hmm... i found it [Workaround Arduino SD Card Initialization Error! - EmbedJournal](

thanks, that was so helpful i really apreaciatte that

pinMode(chipSelectPin, OUTPUT);
  digitalWrite(chipSelectPin, HIGH);
const int misoPin = 8;
const int mosiPin = 7;
const int sckPin = 1;
const int chipSelectPin = 0;

The problem still, and rechecking the code i note that this solution is already in the code. I verified the conection and is great. The conecction follows this order

so everything works?

Hi, @khronnotix
What is your arduino board?
Why did you remapped a spi pins?

Note, that you can't do that if you using a hardware SPI bus. These pins has a predefined values and cannot be changed.
What's a problem with default spi pins?

Hi, i'm using a arduino uno(not the official one). The problem is that the pins predefined have the same pins and they are interrupted by each other

Are you meant that the more than one module uses an predefined SPI pins? It is a perfectly normal situation. The SPI is a multiclient bus.

You can connect a several sensors sharing the same SCK, MOSI and MISO pins to all clients. To prevent clients been interrupts by each other you only need to use a separate CS pins to each slave (see picture).

To read more about Arduino and SPI, you can visit the Arduino & Serial Peripheral Interface (SPI) guide.

Thank you very much for all your help, thanks to you I was able to solve it, honestly I had not paid attention to SPI communication, I was able to understand it and learn something new. I pass you a video that reinforced what they explained to me. SPI protocol features and how to integrate multiple sensors // Arduino Zero, LoRa and E-Ink modules - YouTube

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