Hacking Adafruit NFC shield for Arduino Leonardo compatibility

Submitted by fabio on Mon, 2012-07-09 10:59.

Yesterday night, me and Federico Vanzati (one of the guys working for Officine Arduino at Fablab Torino) had a good time hacking the NFC shield by Adafruit so that it could work with the new Arduino Leonardo.

The hacking started when we connected the Leonardo to the NFC and discovered that I2C, the default hardware communication bus used by the shield to communicate with the Arduino, was not working on the Leonardo. This shield, even if already designed for Arduino UNO R3 pinout, wasn't working with the Arduino Leonardo at all! This blog post is a small summary of what we did to address these issues.

Adafruit NFC shield hacked for Arduino Leonardo compatibility

We started investigating the problem.. the first strange thing worth noting is that this shield, even if it comes with the various Open Hardware logos on it, it doesn't actually have any shematics nor EDA CAD designs available The designs were actually available on Adafruit github but simply not linked from the product page, that's why we missed them. So, we had to kind of reverse engineering the shield in order to understand the problem.

So, the first problem we discovered is that the IRQ pin of the PN532, used to signal the microcontroller on a successful read, is connected to pin Digital 2 on the shield.. this is not good at all with the Leonardo since D2 is also I2C SDA making communication impossible. Fixing this was as simple as cutting out the trace going from the IRQ pin into the D2 pin on the shield.

We decided to use a two ways on-on switch (see picture below) connecting IRQ to D2 in one position and IRQ to D8 in the other position.. the idea was being able to switch between D8 and D2 when used with UNO or Leonardo respectively. On a second thought, it is probably better to move that to another pin usable on both the UNO and Leonardo.

The next problem we had to address was a pin conflict: this shield connects I2C SDA and SCL both on the new SDA and SCL pins on the new Arduino UNO R3 pinouts (top left near the various digital pins) as well on the legacy A4 and A5 pins used for I2C in legacy Arduino Duemilanove and previous boards. Fixing this was as simple as cutting out the traces connecting I2C to A4 and A5.

With a small modification to the reference code from the Adafruit NFC library (attached below), instructing the library to use D8 instead of D2 as IRQ connection, we finally had a perfectly functioning NFC shield with I2C on the Arduino Leonardo!

Suggestion for Adafruit: in case backward compatibility with legacy boards is needed, I'd use a 2 ways on-on switch (eg: JS202011SCQN) allowing the connection to A4 and A5 when needed on legacy boards. Solder jumpers will work too.

AttachmentSize
toys_rfid.ino3.26 KB
Posted in:

Corrections :)

Submitted by adafruit (not verified) on Mon, 2012-07-09 15:07.

Hi there, thanks for trying this out. The shield schematics and board layout are here on github under a Creative Commons Attribution/Share-Alike license
https://github.com/adafruit/Adafruit-PN532-RFID-NFC-Shield

We did not have access to the Leonardo when designing this shield, so we did not know that digital 2 & 3 would be I2C pins. We may change the default IRQ pin connection to be digital 4 in the future. But as you saw, its not a difficult change to make.

We hope to soon test the dozens of shields, libraries, and tutorials we have on the Leonardo.

Thanks for your comment

Submitted by fabio on Mon, 2012-07-09 15:28.

Thanks for your comment Limor.. Sorry, we didn't know about the github hw sources.. we only looked in the product page which currently seems that only has a link to the old NFC breakout board schematics but not to the shield designs on github.

I've updated the article pointing to the hw sources.

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a personal or company website insert its address in the form http://www.example.com/ .
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <small> <del> <img> <h2> <h3> <h4> <b> <video> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may insert videos with [video:URL]
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options