2

I am building a Raspberry Pi B+ powered survey device. It would use NFC scanners for multiple choice questions. It should display a question on LCD screen and the user should have his NFC tag scanned by NFC scanner corresponding to his choice.

I am planning on using SunFounder's NFC scanner for Raspberry Pi, however, if I use separate GPIO pins for separate scanners, I can only read from 3 scanners which is not enough.

According to the user manual, NFC scanner uses 5 GPIO pins + 5V + GND out 26 available like this:

  • one is connected to GPIO 10 (SPIO_MOSI)
  • GPIO 9 (SPIO_MISO)
  • GPIO 8 (SPI_CE0)
  • GPIO 17
  • 5V, GND

I found no comments whatsoever which pin is used for what.

The device needs to identify NFC tag and the answer chosen (ie, scanner which read NFC tag).

Now the questions are can I reuse some (all) of the pins used to transfer NFC tag information and do I need to use some logic, for example, Charlieplexing to identify scanner?

  • Can you give a better link to the NFC scanner you plan to use than some PDF document? Ideally give us the details in your answer instead of in an external link, so this question stays readable and relevant even if the link document disappears? – Phil B. May 21 '15 at 10:21
  • That PDF is the user manual of the scanner. I guess, I could try extracting the relevant details. – julka May 21 '15 at 10:36
  • Why not just buy some USB NFC readers? – user1133275 May 23 '15 at 22:49
2

According to the documentation, the device you link can be used as an SPI device. Unfortunately, with the default pins for SPI, as far as I know, you only get 2 Chip Select pins, so you can drive maximum 2 cards this way when using standard available libraries. If you want to drive all 4, you cannot rely on those libraries and will need to do some bit-banging (unless my quick google search skipped something of course), but it only requires 2 extra GPIO pins (Easily available) or can even be done with the original 2 pins if you use a demultiplexer IC (0,0 = card 1; 0,1 = card 2; 1,0 = card 3 and 1,1 = card 4).

Now for some alternatives:

  1. Have you thought about giving your contestants 4 different tags, one for each answer? That way you can bring your setup down to 1 reader, no reading conflicts, and you replicate just the cheapest component in your setup (the RFID tag)
  2. You might want to look into different RFID readers - This one from Adafruit does UART, SPI and I2C. Since all of those mechanisms are available on the Pi (and it supports 2 devices via SPI) you could put one via UART, one via I2C and 2 via SPI. The card seems to have 2 select pin headers on it as well, I'm not sure if this would allow you to set different I2C addresses, but if it does and depending on how many different addresses it supports, you might be able to plug all of those on the same I2C bus and use them this way.

UPDATE: The two select headers are to select SPI, UART or I2C mode, not to set the I2C address. That address is fixed at 0x48 for all PN532 based cards, so you cannot put two of them on the same I2C bus, not even if you buy them from different board suppliers.

  • Can I send data to say UART pin from several cards and use demultiplexing logic (additional GPIO pins) to extend the number of scanners it can support? Assume only one scanner reads a tag at any single time. – julka May 21 '15 at 11:07
  • UART is a serial protocol - it is really designed for communication between 2 devices, one on each end, not one-to-many. Even if you managed to multiplex devices, they wouldn't be able to identify themselves as being different, so how would you determine from which NFC reader the response comes? – Phil B. May 21 '15 at 13:58
  • I am a total newbie when it comes to hardware. I only needed "use friggin I2C that allows you to speak to multiple slaves as raspberrypi.org/forums/viewtopic.php?f=44&t=20852 suggests". – julka May 21 '15 at 17:50
  • I2C indeed allows you to control multiple devices on the same bus, BUT, if those devices are the same make & model, you need to be sure that you can set a separate I2C address for each of them, otherwise they both (or all 4) listen to the same address and you get conflicts, or cannot determine which reader the signal comes from. The NFC card you mention does not have an I2C connection, the one I mentioned from Adafruit does. – Phil B. May 21 '15 at 17:58
  • 3
    This post over at the Adafruit forums confirms you cannot change the I2C address on the PN532. – Phil B. May 21 '15 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.