Adafruit PN532 NFC reader v1.0 and rpi

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Kojebric
 
Posts: 3
Joined: Wed Aug 14, 2013 3:38 am

Adafruit PN532 NFC reader v1.0 and rpi

Post by Kojebric »

Hello everyone,

I have bought a adafruit PN532 NFC + RFID shield version 1.
1. So I want to connect to my raspberry pi by UART.
There is a lot written how to do it on version 1.3 but on version 1 is confusing. On board it says:
"For I2C leave SEL0 and SEL1 open, For SPI close SEL0 and SEL1".
On schematic it says UART SEL0 -> 0 SEL1 -> 0, ... http://www.adafruit.com/datasheets/PN53 ... c_v1.0.pdf
And there is also a note that SEL0 and SEL1 are wrong connected on PN532 chip.

So what is the proper soldering recipe for V1.0 for all possible combination?

Now I have SEL0 open and SEL1 close.

2. To connect to RPi, I think that I only need four pins. RX, TX, GND and VCC (5v). Is this correct?
When I connect it, my PWR led lights green, and BUSY light red. I put the card on and nothing changes. What is the meaning of busy led? On schematic here are no LEDs.
My current connection
Adafruit PI
5v 5v
GND GND
SDA RX
SCL TX

I'm using Raspbian and libnfc library, install by this guide http://learn.adafruit.com/adafruit-nfc- ... ing-libnfc

Now when I call nfc-list, it says no NFC device found. Libnfc is 1.7.0-rc7.

Thanks and BR

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit PN532 NFC reader v1.0 and rpi

Post by adafruit_support_rick »

The shield is a little more difficult to interface to the Pi than the breakout, because of the voltage differences

For UART, you want SEL0 closed and SEL1 open.

You can power the shield from 5V, but DO NOT connect to the Pi's RX without using a level shifter! 5V input signals can damage the Pi.

SDA->RX and SCL->TX are correct. You will also need to connect IRQ to a Pi input. Once again, make sure to use a level shifter on this line.

The BUSY light should always be lit. It will turn off only while a card is being read.

The IRQ line indicates when card data is available. Offhand, I believe it tracks inversely with the BUSY light, and is active high.

You may also want to connect the RST line. This would be an output signal from the Pi.

Kojebric
 
Posts: 3
Joined: Wed Aug 14, 2013 3:38 am

Re: Adafruit PN532 NFC reader v1.0 and rpi

Post by Kojebric »

Thanks for reply, now my pi and shield is working. But SEL1 must be close and SEL0 must be open ;)

But now i have a different problem :)

I was playing around with MiFare card which came with the sheild and I have done some stupid thing.

My procedure:

nfc-mfclassic r a test
cp test ./Backup
vi test
(remove 4 char, and aded 4 more)

od -x test

Code: Select all

0000000 0da2 bca6 08b5 0004 7369 6973 3635 3034
0000020 0000 0000 0000 0000 0000 0000 0000 0000
*
0000060 ffff ffff ffff 07ff 6980 0000 0000 0000
0000100 0000 0000 0000 0000 0000 3231 5833 0000
0000120 0000 0000 0000 0000 0000 0000 0000 0000
0000140 0000 0000 0000 0000 0000 0000 0000 ff00
0000160 ffff ffff ffff 8007 0069 0000 0000 0000
0000200 0000 0000 0000 0000 0000 0000 0000 0000
*
0000240 0000 0000 0000 0000 0000 0000 0000 ff00
0000260 ffff ffff ffff 8007 0069 0000 0000 0000
0000300 0000 0000 0000 0000 0000 0000 0000 0000
*
0000340 0000 0000 0000 0000 0000 0000 0000 ff00
0000360 ffff ffff ffff 8007 0069 0000 0000 0000
0000400 0000 0000 0000 0000 0000 0000 0000 0000
*
0000440 0000 0000 0000 0000 0000 0000 0000 ff00
0000460 ffff ffff ffff 8007 0069 0000 0000 0000
0000500 0000 0000 0000 0000 0000 0000 0000 0000
*
0000540 0000 0000 0000 0000 0000 0000 0000 ff00
0000560 ffff ffff ffff 8007 0069 0000 0000 0000
0000600 0000 0000 0000 0000 0000 0000 0000 0000
*
0000640 0000 0000 0000 0000 0000 0000 0000 ff00
0000660 ffff ffff ffff 8007 0069 0000 0000 0000
0000700 0000 0000 0000 0000 0000 0000 0000 0000
*
0000740 0000 0000 0000 0000 0000 0000 0000 ff00
0000760 ffff ffff ffff 8007 0069 0000 0000 0000
0001000 0000 0000 0000 0000 0000 0000 0000 0000
*
0001040 0000 0000 0000 0000 0000 0000 0000 ff00
0001060 ffff ffff ffff 8007 0069 0000 0000 0000
0001100 0000 0000 0000 0000 0000 0000 0000 0000
*
0001140 0000 0000 0000 0000 0000 0000 0000 ff00
0001160 ffff ffff ffff 8007 0069 0000 0000 0000
0001200 0000 0000 0000 0000 0000 0000 0000 0000
*
0001240 0000 0000 0000 0000 0000 0000 0000 ff00
0001260 ffff ffff ffff 8007 0069 0000 0000 0000
0001300 0000 0000 0000 0000 0000 0000 0000 0000
*
0001340 0000 0000 0000 0000 0000 0000 0000 ff00
0001360 ffff ffff ffff 8007 0069 0000 0000 0000
0001400 0000 0000 0000 0000 0000 0000 0000 0000
*
0001440 0000 0000 0000 0000 0000 0000 0000 ff00
0001460 ffff ffff ffff 8007 0069 0000 0000 0000
0001500 0000 0000 0000 0000 0000 0000 0000 0000
*
0001540 0000 0000 0000 0000 0000 0000 0000 ff00
0001560 ffff ffff ffff 8007 0069 0000 0000 0000
0001600 0000 0000 0000 0000 0000 0000 0000 0000
*
0001640 0000 0000 0000 0000 0000 0000 0000 ff00
0001660 ffff ffff ffff 8007 0069 0000 0000 0000
0001700 0000 0000 0000 0000 0000 0000 0000 0000
*
0001740 0000 0000 0000 0000 0000 0000 0000 ff00
0001760 ffff ffff ffff 8007 00bc 0000 0000 0a00
0002000
nfc-mfclassic w a test
//Success
nfc-mfclassic r a test2
//Reading out 64 block |!
failed to read trailer block 0x3f

nfc-mfclassic r A test2
//...., Done, 4 of 64 blocks read
...

So read somewhere that I should try
mifare-classic-format
and i got:
Formating 16 sectors [..mifare-classic-format: No known authentication key for sector 1

So how can i restore the card to initial state?

User avatar
ktownsend
 
Posts: 1447
Joined: Thu Nov 05, 2009 2:18 am

Re: Adafruit PN532 NFC reader v1.0 and rpi

Post by ktownsend »

I'm afraid no one here really has much hands-on experience with libnfc, so you'll probably have to head over to the libnfc forum for questions relating to their code. I've only used it briefly just to test communications, but I really don't have a very good understanding of the API or current state of the library itself, and 99.9% of the time we use our own internal embedded code ... but libnfc has a fairly active community.

If you've unwittingly changed the keys on your cards, though, and don't know what they are ... you're basically out of luck and you'll be better off just getting a new card. There are tools you can use to figure out the keys for Mifare Classic cards since the encryption mechanism has some faults (MFCUK, etc.), but for the cost of a card versus the time it would take, a couple new cards might make more sense.

Kojebric
 
Posts: 3
Joined: Wed Aug 14, 2013 3:38 am

Re: Adafruit PN532 NFC reader v1.0 and rpi

Post by Kojebric »

Thanks for reply.

My question is now on libnfc forum: http://www.libnfc.org/community/post/4708/#p4708
In case that some else gets into the same troubles as I did.

If you know some other lib that I can use on Raspberry, which is gonna fix my problem, please say.

I will buy new NFC tags, but I must know what I did wrong, that I don't repeat the same mistake and get more familiar with the system.
I ran MFOC and there was no error, all keys were found. All sectors had default key, just sector 15 had some special key, which was discovered.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit PN532 NFC reader v1.0 and rpi

Post by adafruit_support_rick »

Kojebric wrote:But SEL1 must be close and SEL0 must be open
I just want to clarify this for future reference - I just found out that the "SEL0" and "SEL1" silk-screen labels are reversed on the current batch of NFC Shields (the NFC breakout-board labels are correct). This will be fixed in the next batch going into production.

In my earlier post, I based my response on the actual schematic. In the future, the UART configuration will be as I stated it: To operate the NFC shield in UART mode, you want SEL0 closed and SEL1 open.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”