Successfully Scanned NFC Tag with Argon and MFRC522

boron
argon
xenon
Tags: #<Tag:0x00007fe2224c7b90> #<Tag:0x00007fe2224c7820> #<Tag:0x00007fe2224c7398>

#1

I have NXP NTag213 NFC tags that I need to scan on my particle mesh boards to get the UID and NDEF data from the tag to replace Android phones currently reading the tags (https://schooltag.org). I recently discovered this won’t be possible using the native NFC capabilities in the mesh products (Xenon, Argon, Boron).

I purchased a Mifare RC522 Card Reader and I was able to read the NFC tag using the MFRC522 (v 0.1.4) available as a searchable library in the Web IDE and Particle Workbench. I had to use different Pin mapping than is documented in the library which is for the Spark Core. I’ve created a Pull Request to the library with the changes used.

  • RC522:Argon
  • MOSI: MO
  • MISO: MI
  • SCK : SCK
  • SS : Pin A2 (Configurable)
  • RST : Pin D2 (Configurable)

I’m posting this here in case anyone else needs it, to separate from the long original discussion of getting the MFRC522 library to work and to encourage any feedback about how the solution may be improved since I am not an embedded programmer.

Thanks to all who contributed to the the library and original discussion.

Aaron


#2

Good job! I just read through the previous topic. It is very disappointing that the Gen 3 devices will not be able to support NTAG and I am very appreciative that you have got to the bottom of the issue as that has saved me some later disappointment and wasted time.

I had a requirement to integrate miFare card access to ‘unlock’ a device - I used these: https://www.amazon.co.uk/Asiproper-PN532-Module-Android-Communication/dp/B07D9J76RN/ref=pd_lutyp_crtyp_simh_1_5/277-2959855-8777415?_encoding=UTF8&pd_rd_i=B07D9J76RN&pd_rd_r=2d6aff44-563d-45fe-94d5-53626020637f&pd_rd_w=A6Uzx&pd_rd_wg=uAZJV&pf_rd_p=05ed913e-2ea5-41f1-8d2c-034b89b76fb3&pf_rd_r=21XPHVVFVK93TBTD2NT9&psc=1&refRID=21XPHVVFVK93TBTD2NT9 The advantage of this board is that it supports I2C (also Serial and SPI). I used I2C - it means you can have the module further from the MCU compared to SPI. The disadvantage is that it appears to require a IRQ line. I wrote a rudimentary library for the PN532 that supports I2C and allows miFare type cards and tags to be read.


#3

@armor, I have one of those boards, the PN532 NFC board, can you share your library for this?


#4

You should be able to use the Adafruit_PN532 community library. It supports both I2C and SPI buses. The I2C requires SDA, SCL, IRQ and RSTO lines - I found that only IRQ is necessary and since I only wanted I2C bus support effectively cut down the basics of this library just to read the card number/ID which was all I wanted.


#5

That’s basically what I’m looking for. I’ll check out the library.


#6

@Armor, I’ve been going at this all day, I can’t seem to get the PN532 to read. I thought it may have been something in the I2C settings on the board, but after flashing an I2C scanning app, everything seems to be in working order for that. I’ve also tried flashing a serial log handler app and checking for anything when scanning a card. Nothing except the I2C scanning app seems to return anything. Any ideas?


#7

@Mjones Here is a picture of the setup I am using at the moment.
The IRQ line goes to pin A1.
I2C uses D0, D1.

Worth checking the micro switches are set properly - these can be problematic and then it won’t work.


#8

I’ve got the switch set right according to your picture. I thought you were using a gen3 device, that may be part of my problem


#9

I can’t see why the Gen3 devices would not work. Not had any issues with I2C on Xenons. What I have noticed with this PN532 board is that the bus selection switches sometimes do not work - try a DMM to check the switch is closed. Other than that - have you checked the connection of the I2C and IRQ to the board? What I2C address are you using?


#10

One thing to consider: None of the I2C pins are 5V tolerant so you should not use any I2C board that has pull-ups to 5V.
If your sensor needs 5V to run, you should add level shifting.


#11

You beat me to it! I just checked and the PN532 is tolerant of 3V3 and 5V. Another thing that isn’t clear from the photo I posted is that there are 2K2 ohm pull-up resistors to 3V3 on the PCB - have you got those?


#12

I’m using 3v3 from the xenon to power the PN532, I didn’t know they weren’t 5v tolerant so I guess I got lucky this time (point taken to make sure to read all documents before proceeding with a project).
@armor I do not have the resistors, so it looks like I’ll need to order some before I can continue.


#13

That will be why it wasn’t working :wink:


#14

I do have a relay board from NCD with built in pull ups on D0 and D1, I’ll check the mapping along with the gen2 to gen3 adapter I have to see if that will be compatible. Thanks for the input.


#15

Everything was great, I flashed a sketch to test my i2c so that d7 would blink when it was running. Everything checked out fine but still no sign it was reading a card. So I started checking voltages on my i2c lines, when suddenly my d7 led went out. Good news, the pullup resistors on my board do go to 3v3. Bad news, my meter lead slipped and touched the 5v pin next to it so i2c 1 is gone now on my xenon. Luckily particle gave us a second i2c on this.