Go Down

Topic: SD Cards Pins & RC522 & RTC Module (Read 821 times) previous topic - next topic

hasduino

Hello
I'm having a common problem but i want put a stop to this mess.





Here It Comes :)




I will make a rfid based Access Control and recorde the data on an sd card. Data will include the identity of the card, date and time. So i will cobine RTC module, RFID module (RC522), micro sd card module and Arduino Uno. I'm having issue to work RFID and sd card module together because they are using same pins. I will make a list for what i tryed to make this work.

What I tryed:
  • Connect sharing pins together
  • Connect 3.3v to micro sd card module
  • Connect 5v to RC522
  • Tested each module individually
  • Modify the "Sd2PinMap.h" for use empty pins (didn't work as well)(click to see the modifyed one. I chanced 418-421 numbered lines)



What i need:

Move the pins of micro SD Card modules pins to between 2-8 numbered digital pins or any solition wich solve my problem.




I know there is lots of topics in this forum but non of them solved my problem.



This is my current codes. I barrow these from another guy on the internet and i put my rtc module codes.

Code: [Select]
#include <DS1307RTC.h>
#include <Wire.h>
#include <TimeLib.h>
#include <SPI.h>
#include <MFRC522.h>
 
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

 
void setup()
{
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Approximate your card to the reader...");
  Serial.println();

}
void loop()
{
  tmElements_t tm;
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "00 00 00 00" && RTC.read(tm))//change here the UID of the card/cards that you want to give access
  {
   
    Serial.println("Authorized access");
   Serial.print("Ok, Time = ");
    print2digits(tm.Hour);
    Serial.write(':');
    print2digits(tm.Minute);
    Serial.write(':');
    print2digits(tm.Second);
    Serial.print(", Date (D/M/Y) = ");
    Serial.print(tm.Day);
    Serial.write('/');
    Serial.print(tm.Month);
    Serial.write('/');
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.println();
    delay(3000);
  }
 
 else   {
    Serial.println(" Access denied");
    delay(3000);
  }
}
void print2digits(int number) {
  if (number >= 0 && number < 10) {
    Serial.write('0');
  }
  Serial.print(number);
}

knut_ny

#1
Feb 21, 2018, 12:24 pm Last Edit: Feb 25, 2018, 12:00 pm by knut_ny
Problem with SD module is that it doesn't release MISO when not selected.
Some modules, with 3-state buffers, are easy to modify.
Ny

hasduino

Problem with SD module is that it doesn't release MISO when not selected.
Some modules, with 3-state buffers, are easy to modify.
So what is your advice?
Should i put a transistor to blok MISO pins of sd module when i'm not using it?

knut_ny

#3
Mar 29, 2018, 11:10 pm Last Edit: Mar 29, 2018, 11:19 pm by knut_ny
add a 3-state buffer. Let CS-line controll its state.
Don't dare say if a single transistor (mosfet) can do the trick.  (Never tried)
The schematic u'll emulate is
this one..
Ny

hasduino

add a 3-state buffer. Let CS-line controll its state.
Don't dare say if a single transistor (mosfet) can do the trick.  (Never tried)
The schematic u'll emulate is
this one..
It looks realy complicated. Is there any ic for this purpose ?

I have tried to block miso and mosi pins by transistors. I use 4 transistors and i use 2 cs lines to controll them. Due to this image (https://commons.wikimedia.org/wiki/File:SPI_timing_diagram2.svg#mw-jump-to-license) i should stop communication when cs pin is high. So i added an inverter (74hc04) and connect inverted cs pins to transistors non inverted cs pins to micro sd and rfid. But somehow it didn't work. I will upload schemes in about 14-16 hours.

hasduino

This is my last status. This scheme is not working...

knut_ny

..modify the SD-card.
Post a picture / link to your module. Then it can be possible to point out mod needed.
Ny

Go Up