Hi to all
I am trying to read multiple rfid readers with an arduino nano but it isnt working in a reliable way (loop verry slow and not always reading cards) annyone sugetions?
here is how i did it arduino uno - Issue sharing MISO with multiple RC522 RFID Readers - Arduino Stack Exchange and this my code
/*******************************************
* function:get the id of RFID key
* RFID Uno r3
* VCC 3.3V
* RST 2
* GND GND
* MISO **
* MOSI 4
* SCK 5
* NSS 6
* IRQ 3
****************************************/
#include"rfid1.h"
RFID1 rfid;//create a variable type of RFID1
uchar serNum[20]; // array to store your ID
int i=0;
void setup()
{
Serial.begin(9600); //initialize the serial
}
void loop()
{
if(i==1){
rfid.begin(3, 6, 4, 7, 5, 2);
}
if(i==2){
rfid.begin(3, 6, 4, 8, 5, 2);
}
if(i==3){
rfid.begin(3, 6, 4, 9, 5, 2);
}
if(i==4){
rfid.begin(3, 6, 4, 10, 5, 2);
}
if(i==5){
rfid.begin(3, 6, 4, 11, 5, 2);
}
i++;
if (i==6){i=0;
}
// Serial.println(i);
rfid.init();
uchar status;
uchar str[MAX_LEN];
// Search card, return card types
status = rfid.request(PICC_REQIDL, str);
if (status != MI_OK)
{
return;
}
Show card type
rfid.showCardType(str);
//Prevent conflict, return the 4 bytes Serial number of the card
status = rfid.anticoll(str);
if (status == MI_OK)
{
Serial.print("The card's number is: ");
//memcpy(serNum, str, 20);
rfid.showCardID(str);//show the card ID
Serial.println();
uchar* id = serNum;
if( id[0]==0xC0 && id[1]==0xB7 && id[2]==0xB9 && id[3]==0x79)
{
Serial.print(" Hello Dannel! ");
delay(2000);
}
}
delay(100);
rfid.halt(); //command the card into sleep mode
}