This is the continuation of the story of connecting unexpensive NFC readers to Arduino. Part 1 explains how a Mifare reader from Stronglink can be easily connected. This time I’ll show you how to connect more than one of them.
Hardware configuration
The SL018 sports two jumpers which let you select the address the reader will use on an I2C bus. This means that you can connect up to four devices on a single bus and that before you connect more than one you have to solder one or more of these jumpers. Take look at the manual for details.
How is it going to work
Marc’s RFDuino can poll one reader at a time so we need a way to figure out when to poll which reader. Fortunately Stronglink’s readers feature a pin that signals whether a card has been found in the field. On the SL030 this is pin number 5 called “Out”, and we will connect it to one of the Arduino pins. Now, we will only poll the reader for card data once the reader have signalled that the card is actually available.
Software
So, the implementation of the above method works roughly like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
We can add as many segments like this in the loop()
part of the Arduino code and each segment supporting a particular reader will ‘trigger’ whenever that reader fill find a card.
The code where we are waiting for data could be written more naturally as:
1
|
|
but for some reason that I didn’t have the time to investigte does not work.
So, how to make it work exaclty?
Just go to Marc’s github repository and peek into the RFIDuino/SL018/examples/twoReaders directory. It contains a twoReaders file that I have written and which Marc included in his repository. Please note that Marc updated his library for Arduino IDE 1.0 but there is nothing IDE-specific in this example. If you have an older version of the RFDUino library just change the file extension of my code accordingly.
Here’s the full example code for your convenience:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
Good luck and have fun! If you have some improvements to this code for Marc’s (preferably) or my repository on git hub and help pushing this library forward.