-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Up to 5 devices simultanious #290
Comments
Hello ! We have the same problem it's realy annoying ! |
Help me on this issue here : |
You can just use the standard ReadUidMultiReader example.
That's it. The code you posted makes no sense at all to me. I suggest you start from scratch. If you cannot get it to work reliably because of the cable distance, then it's also an option to use 2 Arduino's connected by I2C or Serial and exchange the data between the Arduino's. |
Hello, I'm working with 4 readers and it works ok, It's based on miguelbalboa's multi rfid example
But I have a problem setting the gain, I tryed this after the PCD_init(): mfrc522[readern].PCD_SetAntennaGain(0x07); and: mfrc522[readern].PCD_SetRegisterBitMask(mfrc522[readern].RFCfgReg, (0x07<<4)); But when I try to change the gain, my readers can't read the rfid tags or read it sometimes. It is annoying that i can't setting the gain fine. When I did a basic program to test the mfrc522 readers, setting the gain worked fine, but now with the multi-readers and the need of a loop with the PCD_Init() (I need to know that the card is present yet), it doesn't work! I would appreciate some help. Thanks! |
i think i saw a snippet of this in a forum but it was deleted when i check back. |
Here is the .ino, this is a test setup, I have a more complex program comparing UIDs, storing it to eeprom, activating outputs and many others functions but the base is this, reading the UIDs of the PICC. I don't need access to PICC memory or do more advanced stuff, only read their UID and know when PICC is over the reader. You can see in the sketch where I tryed to set gain. //******************************************************************************************
//** ARDUINO PRO MINI 3.3v 8MHz **
//** GND GND VCC RX TX /DTR **
//** +--------------------------------+ **
//** | [ ] [ ] [ ] [ ] [ ] [ ] | **
//** | SERIAL PORT | **
//** D1 | [ ]1/TX RAW[ ] | | **
//** D0 | [ ]0/RX GND[ ] | <--> GND **
//** | [ ]RST SCL/A5[ ] RST[ ] | **
//** | [ ]GND SDA/A4[ ] VCC[ ] | --> VCC 3.3v **
//** D2 | [ ]2/INT0 ___ A3[ ] | --> SDA/SS reader #3 **
//** D3 |~[ ]3/INT1 / \ A2[ ] | --> SDA/SS reader #2 **
//** D4 | [ ]4 /PRO \ A1[ ] | --> SDA/SS reader #1 **
//** D5 |~[ ]5 \ MINI/ A0[ ] | --> SDA/SS reader #0 **
//** D6 |~[ ]6 \___/ SCK/13[ ] | --> SCK (Clock) **
//** D7 | [ ]7 A7[ ] MISO/12[ ] | <-- MISO (Master In Slave Out) **
//** B0 | [ ]8 A6[ ] MOSI/11[ ]~| --> MOSI (Master Out Slave In) **
//** B1 |~[ ]9 SS/10[ ]~| --> RST All readers (for now) **
//** | [RST-BTN] | **
//** +--------------------------------+ **
//** http://busyducks.com/ascii-art-arduinos **
//** **
//** MDLSoft(c) 2017 Test setup ver: 1.02 **
//******************************************************************************************
#include <SPI.h>
#include <MFRC522.h>
#include <string.h>
constexpr uint8_t NR_OF_READERS = 4;
constexpr uint8_t RST_PIN = 10;
constexpr uint8_t SS_0_PIN = A0;
constexpr uint8_t SS_1_PIN = A1;
constexpr uint8_t SS_2_PIN = A2;
constexpr uint8_t SS_3_PIN = A3;
byte ssPins[] = {SS_0_PIN, SS_1_PIN, SS_2_PIN, SS_3_PIN};
byte readedCard[NR_OF_READERS][4]; // Matrix for storing UID over each reader
MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instances
void setup()
{
Serial.begin(9600); // Initialize serial communications
while (!Serial); // Do nothing until serial connection is opened
SPI.begin(); // Init SPI bus
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++)
{
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
}
pinMode(RST_PIN, OUTPUT);
digitalWrite(RST_PIN, LOW); // mfrc522 readers hard power down.
}
void loop()
{
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++)
{
if(getRFID(reader))
{
Serial.print(F("Reader "));
Serial.print(reader);
Serial.print(F(": Card UID:"));
printUID(readedCard[reader]);
Serial.println();
}
}
delay(2000);
}
//******************** Routine for print 4 byte UID to serial ******************************
void printUID(byte *buffer){
for (byte i = 0; i < 4; i++){
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);}}
//********************************END OF ROUTINE********************************************
//************ Routine for scan readers and store the UIDs in readedCard array *************
bool getRFID(byte readern)
{
bool isPICCpresent = false;
digitalWrite(RST_PIN, HIGH); // Get RC522 reader out of hard low power mode
mfrc522[readern].PCD_Init(); // Init the reader
//****** Trying to set antenna gain to max, erratic functioning of the readers ***********
//mfrc522[readern].PCD_SetRegisterBitMask(mfrc522[readern].RFCfgReg, (0x07<<4));
//mfrc522[readern].PCD_SetAntennaGain(0x04);
// mfrc522[readern].PCD_ClearRegisterBitMask(mfrc522[readern].RFCfgReg, (0x07<<4));
// mfrc522[readern].PCD_SetRegisterBitMask(mfrc522[readern].RFCfgReg, 0x07);
//delay(50);
if (mfrc522[readern].PICC_IsNewCardPresent() && mfrc522[readern].PICC_ReadCardSerial())
{
memcpy(readedCard[readern], mfrc522[readern].uid.uidByte, 4);
isPICCpresent = true;
}
mfrc522[readern].PICC_HaltA();
mfrc522[readern].PCD_StopCrypto1();
digitalWrite(RST_PIN, LOW); // return to hard low power mode
return isPICCpresent; // returns TRUE if PICC is detected, false if not
}
//********************************END OF ROUTINE******************************************** |
I use Arduino UNO Board and i have a problem with two RFID by pin MOSI and MISO, i follow the code on top my comment, so can help me, |
You shoul use 3.3v for the RFID readers, you could lower the UNO from 5v to 3.3v or use level shifters. Other than that is to have the connections right and as is a relatively high frequency you should take care about contacts in the breadboards or dupont wires. In my case, I soldered flat cables to have better conectivity. You could show us your circuit, maybe we can help you with it. |
Yes, you have to use 3.3v to Vcc for every RC522. All the communication bus (MOSI, MISO and SCK) and select (SSn) should also work at 3.3v. Maybe you have already though about this, but I suggest you try first with only one Rc522 reader and then add one by one. It's easier to find bugs and get working multiple rfid readers in the same bus. I haven't tried more than 4 readers but you shouldn't have any problems. |
Thank you @MDLSoft, so i'll dasiy chain all RC522's 3.3V like I would for other wires (MOSI, MISO, etc). Thank you! |
I was hoping I´d find what I´m looking for but sadly no... What I want it is also to use 5 readers, but like access control. Every rfid reader is programmed to ´allow´ 1 tag/card. So when all 5 tags are scanned by the proper reader, a realy switches. How do I do that? It's like combining acces control with multirfidreader but I don't know how to do it. |
Wouldn’t be too hard to do what you’re proposing… Of course the readers themselves are not actually ‘programmed’ to remember cards. This must be handled by your logic. One approach would be to store your ‘valid keys’ in the EEPROM of your MCU device…
Opening a relay thereafter is trivial. There are good demo sketches around for both of these elements.
Lou
… On Jan 30, 2018, at 5:03 PM, remconet ***@***.***> wrote:
I was hoping I´d find what I´m looking for but sadly no... What I want it is also to use 5 readers, but like access control. Every rfid reader is programmed to ´allow´ 1 tag/card. So when all 5 tags are scanned by the proper reader, a realy switches. How do I do that? It's like combining acces control with multirfidreader but I don't know how to do it.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#290 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAJZOanhEEe6ya7ouC4XJXHDSBDg6aHQks5tP5HHgaJpZM4MIVfO>.
|
I've done 12 (at reasonable distance ~20ft)) cat 5e. You should have no problem with 4,5 or 6. I'd pull CS up though - I have never had much luck beyond 3 readers with CS floating. Sky is the limit if you pullup. Also - I don't level shift. I've seen folks doing it, it's the right thing to do, but could not pull off level shifting beyond 1 reader. Could be the quality of the shifters I was using - I don't know. That said, the readers seem to work well at 5v signals - but I understand you are doing this at your own risk as 5v is over spec. |
Heya giz02 - can you tell me what you mean by pull CS up? I assume you're pulling up a pin with a resister, but I don't recall a pin on the arduino called CD - what am I missing? |
Hello Everyone Thanks |
I also managed to make 5 RFID readers to work simultaneously with Arduino Uno and miguelbalboa's library. Check this repo https://github.com/Annaane/MultiRfid or this is a video that shows that's functional : https://www.youtube.com/watch?v=ahc8Yai_sWI |
@amkamyab I had the same issue before I initialized all CS pins to HIGH before the individual setup. Otherwise all RFID devices will respond simultaneously and you get crazy firmware readings. |
@thoka |
I also had this problem. I solved this by turning the readers | on, measure, off | one by one. This worked really well. !! BUT !! You can switch them really quickly and it still works. (I tried 10 readings per second). Also, because of having to use one extra pin per reader now, the maximum amount of readers is 4 now on a normal Arduino. I anyone needs more information on this, I'll gladly help out! Just message me |
Dear Github Swarm, This is going to be a long one, just trying to explain the situation as good as possible. First off, please don't be too harsh, my coding skills are almost none existent, and it takes me a really long time to understand what's happening in a code. While making progress, I'm happily spending more hours than necessary. The Situation: The Problem: When plugged in via 12V adapter it works as well, but ONLY every second or third time. One last fun fact: in the code below Reader#2 is initiated last, - this is the one that doesn't always work. Why does it work when powered via USB, and then not always when powered via 12V VIN? tags, Cables, Readers, Nanos have been replaced to make sure it's not a hardware error. To come to an end- I appreciate all help I can get,
|
Maybe the 12V isn't clean DC ? Like it isn't producing a constant 12V, but rather jumps back and forth around 12V. This could cause problems. Other than that I don't know a reason why it doesn't work. Maybe the supply doesn't provide enough current? I did excaclty the same thing as you. I made an escape room puzzel with 3 RFID chips. |
This code should work if your RFID chips are working fine.
|
Has anyone ever tried using multiple MRFC522 RFID readers bought from china (I guess they are clones)? They work perfectly when using one only, but it looks like there is some noise on the MOSI line even if I turn off the readers that I do not want to read by actively pulling the corresponding SS pins high. The ReadUidMultiReader code works, when I disconnect all the MOSI cables exept from one, but of course that is just helpful for debugging. Or am I missing something else? |
Hi, please look at my posts above. The only solution I found is: You are supposed to turn the chips on/off not with the SS pin, but with the 3.3V power input of the MFRC522. The readers need 3.3v, and the digital pins provide 5v. So I used a 3.3v regulator to convert the 5v to 3.3v. Otherwise the RFID readers might explode. I used the LD1117V33. Please take a look at the code above. After hours and hours of trying this is the best method I could find. You can email me at sjoerd1999@gmail.com in case you still have questions or want more info. |
Mine are from China too and maybe any problem to recognize some rfid tags but all work in the system. Now I have 6 readers working fine. I use an arduino Pro mini at 3.3v so I haven't to convert the supply voltage. |
Since there's only one reader on at the same time, all chips could also use the same SS pin to save some pins. Don't know if that would work with the RST pin method though. Using a 3.3V Arduino is smart! Only a bit annoying if you want to use the Arduino to run a 5V component as well. Could you explain why you are using the RST pin to power it off? In my method I just cut the 3.3V line. Is the RST method better? Normally the readers take 20mAh each, so when you're only running them one by one for a short period of time, this saves a huge amount of power indeed! |
Of course, using RST pin you use the same SS pin for all readers. This is as I have configured. I suppose that cut the supply line or using the RST is the same, in both cases requires same initialization time. How did you that? The supply is directly one pin from arduino? I haven't any problem using 5v input modules supplying it with only 3.3v, or maybe only a simple transistor as digital switch when "power" inductance connected without optocoupler isolation. |
The Arduino digital pins can provide 20mAh, the same as the chips take. So yeah the supply is directly from the Arduino pin in my case. |
I've never tried the RST method myself. The code is just based on what I think might work. You could try to put the You could also try to delete either one or both of these lines: Oh, and try to swap the HIGH and LOW when turning on/off the reset pin, think I made a mistake there |
Thanks for quick response...I am trying these at the moment. I am struggling to read any cards at the moment will update |
At the moment with those updates I have still struggled to get any reading on the code. Any other thoughts? |
Just build the setup really quick with two readers. |
got it thanks I guess i changed something else by accident. Genuinely appreciate the time have a good one |
Hi @sjoerd1999 . Thank you very much for your quick response. I've tested your code but I don't get it works. I've bought too LD33V regulators but it doesn't works neither. The sensors are activated one after another like expected but they don't read the UID. I am using: Arduino Mega 2560, RFID sensord RC522 and LD33V regulators. What I am doing wrong? |
Using an older library version might help (I used the MFRC522 library from the Arduino IDE library manager, version 1.3.6). When using the LD33V method, do the lights of the RFID readers turn off completely when not reading, or are they slightly dimmed? I had a problem with some versions of the RC522 where the chips did not turn off completely when disconnected from power and therefore still interfered. They should all blink one-by-one. The RST method worked fine for me, maybe check the wiring again? Also make sure you use the right Arduino code, both methods have different code. :) |
I am downloading the library version 1.3.6 for testing... if not works i will test the RST method again.... |
Library 1.3.6 doesn't resolve the problem. Somebody know why digital output gives 3,6V instead 5V ?? |
How are you powering the Mega? If you power it via the Vin pin, you need at least 7V. |
I am powering trough USB for monitoring, and after I will power it with the electric transformer. |
Many thanks @sjoerd1999 for all your help. I've got it works perfectly with 12 sensors!! Finally with RST method (that doesn't work first time I tried out).... |
Gents, I am facing same issues you all described here. |
This is the code RFIDmultiRST (1).zip |
Thanks for such quick replay. Sorry disturbing you again:
I am using a MEGA 2560 and 5 x RFID-RC522
I´ve been testing with your code, just modifying SDA pin ( I ´v used pin 30 ) and adding digital pins up to 5 for each RST instead of 3
MOSI,MISO,SCLK and SDA are common connexion and from there to 50,51 and 52 and pin 30 for SDA
When running I am just getting “00000000” all the time , no one RFID RC522 is reading.
3.3V are supplied by same Mega, perhaps I need and external P.Supply?
[cid:image003.jpg@01D673B3.A295B9F0]
De: sjoerd1999 <notifications@github.com>
Enviado el: sábado, 15 de agosto de 2020 15:06
Para: miguelbalboa/rfid <rfid@noreply.github.com>
CC: Godall, Cisco <Cisco_Godall@instron.com>; Comment <comment@noreply.github.com>
Asunto: Re: [miguelbalboa/rfid] Up to 5 devices simultanious (#290)
Gents, I am facing same issues you all described here.
I need 5 RFID working although not simultaneously.
I have tried to RST method without success.
Joerd1999, do you mind share your code and how did you wire them?
I need to finalise my school project. many thanks.
This is the code RFIDmultiRST (1).zip<https://github.com/miguelbalboa/rfid/files/5078670/RFIDmultiRST.1.zip>
Did you get one RFID reader working? What board are you using?
The wiring is quite straightforward, all readers connect to the same SDA/MOSI/MISO/SCK/GND/3.3V pins. Only the RST pin of each reader goes to a unique digital pin. These RST pins are declared in the code (the RSTpins[] array)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#290 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AO4SBB3PAXLCKQX4DVEACALSA2B4NANCNFSM4DBBK7HA>.
|
The 3.3V pin of the MEGA can only supply up to 50 mA of current total. Since the readers need 20mA each, you might want to use a different 3.3V power supply. (A 3.3V regulator should work fine). (this might not be needed as the inactive readers don't consume as much, but still worth a try). |
Thanks so much for your help.
After many test here below my findings.
When I use a RFID in one arruino reliability is 100 %
When 2 are connected to a single arduino reliability is 90%.
With 3 RFID reliability falls down to 40%
And with 4 MiSO together is about 20%, with 5 is no more than 10%.
As I need a very reliable system and no much time left for more experiments I have added UNO’s for each RFID and all them connected with I2C.
Now my project is 100% reliable.
Is a very nice felling to know that there is a community ready to help.
Thanks so much.
Emès des d’iPhone
El 16 ag 2020, a les 19:13, sjoerd1999 <notifications@github.com> va escriure:
Thanks for such quick replay. Sorry disturbing you again: I am using a MEGA 2560 and 5 x RFID-RC522 I´ve been testing with your code, just modifying SDA pin ( I ´v used pin 30 ) and adding digital pins up to 5 for each RST instead of 3 MOSI,MISO,SCLK and SDA are common connexion and from there to 50,51 and 52 and pin 30 for SDA When running I am just getting “00000000” all the time , no one RFID RC522 is reading. 3.3V are supplied by same Mega, perhaps I need and external P.Supply?
The 3.3V pin of the MEGA can only supply up to 50 mA of current total. Since the readers need 20mA each, you might want to use a different 3.3V power supply. (A 3.3V regulator should work fine). (this might not be needed as the inactive readers don't consume as much, but still worth a try).
Please try it first with 1 or 2 readers, then scale up to 5.
Also, which digital pins are you using as RST pins? Don't use pins 0 and 1, as they are used for Serial.
You could also try to use the ICSP header pins for the MISO/MOSI/SCK pins, instead of 51/50/52
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#290 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AO4SBB5PZYQ6PJ52MZXUY7TSBAHTPANCNFSM4DBBK7HA>.
|
Hello, I have sketched two RFIDs and two load cells. When I combined the program between 2 RFIDs and 2 loadcells, the two RFIDs were read and the first loadcell was read but the second loadcell was not read. If the two RFID programs and loadcell programs are separated then the two RFIDs run normally and the two loadcells run normally. How can I combine the two programs so that they can run normally? Thank you |
Hi all. thanks in advance to all |
I had a problem with antenna gain in a multi-reader setting. I was breadboarding with 2 readers and their physical proximity meant that the increased gain was causing the two readers to see each other's signals and get confused. |
This did the trick for me to solve intermittent initialization. What I did was:
All of the delays are probably overkill, but after wrestling with intermittent reader initializing (about half the time one random reader would not work, but not the same one each time), I figure it's a cheap price for not messing with it. |
Hey just used this bit of advice to fix my solution using 8 RC522 and its working great. Everything is consistent and I get clear data from the devices. Hopefully this helps others like myself digging through the ancient posts. |
Glad it helped. |
Hi guys. I found the same problems using 2 rfid mfrc522. Only one random device worked at a time from the start. Thinking there was some initialization error, I tried to find the bug in the library that was causing the devices to initialize badly. I think the problem is related to how the library handles hard reset in the initialization phase. I SOLVE the problem with this trick: I remove the reset pin from the PCD_Init function with -1 for the rst pin like PCD_Init(ss_pin,-1) and in the setup part I add some code to make one hard reset for all the RFIDs and let the PCD_Init function just make a soft reset for each device. I make a function ad hoc to initialize all the modules for calling it in the setup with the purpose to call also in the loop if some devices stop working to hard reset all and make working again.
I hope you can solve the problem like I do. |
Hello all ! |
I propose the following fix to init correctly more than 1 reader: /****************************************************************************************************** for (MFRC522 reader : readers) {
} |
I am posting this to describe my experience in trying to get 5 RFID devices (MFRC522) to work at the same time using 1 Arduino.
This is also relevant to these posts:
#191
#277
#263
After a lot of trial and error I got 5 devices to work simultaneously using this library.
Make sure to use quality cables! I used CAT5E UTP cables to connect the RFID devices to the Arduino.
I started with 5 cables with a total length of 40 meters. I could get 2 devices to work reliable but I could not use the other 3 devices. So I repositioned the Arduino and cut the cables to about 15 meters length total (5 cables, 3 meter each). Maybe if you would use even better quality cables you can increase the length of the cables.
Try multiple RFID cards. I noticed after a while that some cards would work on one device but were not recognized on another device.
Make sure to have 1 or 2 backup MFRC522. When I couldn't figure out why one device would not read the tags when connected, I swapped it with one of my backups and it started working. Keep in mind that the device that could not read the card still works when connected on my breadbord. So maybe there is just to much interference for that device.
So now after many hours of trial and error I got 5 devices to work reliably, without any extra components, WITHOUT a multiplexer, over a total cable length of 15 meters.
I hope this helps someone.
NOTE: I only tested that it could recognize the card UID. I did not test if it could read the actual data on the card because that's not required for my goals.
The text was updated successfully, but these errors were encountered: