NFC and Ethernet/SD shield stacked on Mega

So I'm using this shield ... - http://linksprite.com/wiki/index.php5?title=NFC_PN532_Shield ..but I'm looking to expand to use an Ethernet/SD card shield also. I'm aware they cannot both use the same SS pin, so I looked into if one of them could use another other than D10, when I came across that the SS pin on the mega was 53, but I've been using 10 absolutely fine. However 9 does not work.

Is 53 and 10 the only SS pin on the mega? And does anyone know of some compatible sd/ethernet shields that I could stack that did not use d10 as SS?

Thanks,

Tom :)

You can use any unused digital pin as an SS signal. The easiest way will probably be to bend Pin 10 on the NFC shield and wire it to some unused pin. Then you need to adjust the software to use the selected pin.

johnwasser: You can use any unused digital pin as an SS signal. The easiest way will probably be to bend Pin 10 on the NFC shield and wire it to some unused pin. Then you need to adjust the software to use the selected pin.

But the shield is connected to d9 which isn't used for anything else but when I try and use this as the SS pin it doesn't work?

Do you have the ICSP connector fed through one device or the other? Both use the ICSP connector for the SPI data lines. This header will do the job if you remove the ICSP header from one of the devices and replace it with this unit. https://www.circuitsathome.com/products-page/components/stackable-2x3-header Insure you do not cut off the pins on the top of the shield like the shield you currently have. They must insert into the second shield.

SurferTim: Do you have the ICSP connector fed through one device or the other? Both use the ICSP connector for the SPI data lines. This header will do the job if you remove the ICSP header from one of the devices and replace it with this unit. https://www.circuitsathome.com/products-page/components/stackable-2x3-header Insure you do not cut off the pins on the top of the shield like the shield you currently have. They must insert into the second shield.

The ICSP header is connected to the NFC shield but not fed through, but I thought the shield use digital pins 10-13 for SPI.

Neither shield has anything connected to D11-D13. Both use the ICSP connector for the SPI data lines. http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-06-schematic.pdf https://s3.amazonaws.com/linksprite/Shields/NFC_shield/NFC_Shield-SCH.pdf

edit: And that would certainly not be the case for the Mega. D11-D13 are just normal I/O pins. It is D50-D52 that are the SPI data pins on the Mega. That is why most new shields use the ICSP connector for SPI data lines.

SurferTim: Neither shield has anything connected to D11-D13. Both use the ICSP connector for the SPI data lines. http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-06-schematic.pdf https://s3.amazonaws.com/linksprite/Shields/NFC_shield/NFC_Shield-SCH.pdf

edit: And that would certainly not be the case for the Mega. D11-D13 are just normal I/O pins. It is D50-D52 that are the SPI data pins on the Mega. That is why most new shields use the ICSP connector for SPI data lines.

OK so I need to de-solder the ICSP header on the NFC shield and re-solder a header like the one you linked? But how to I get over the SS pin issue, if both shields can only use Pin 10?

That is easier to fix than you think. You must do what johnwasser suggested. Bend D10 on the RF532 shield so it does not insert into the ethernet shield, and jumper it to D9 with a short piece of wire. Then change the setup on the nfc instance.

#define SCK 52
#define MOSI 51
#define SS 9
#define MISO 50

PN532 nfc(SCK, MISO, MOSI, SS);

The NFC532 shield must be on top of the ethernet shield for this to work.

SurferTim: That is easier to fix than you think. You must do what johnwasser suggested. Bend D10 on the RF532 shield so it does not insert into the ethernet shield, and jumper it to D9 with a short piece of wire. Then change the setup on the nfc instance.

#define SCK 52
#define MOSI 51
#define SS 9
#define MISO 50

PN532 nfc(SCK, MISO, MOSI, SS);



The NFC532 shield must be on top of the ethernet shield for this to work.

Ok thats great, I now have d9 working as ss by putting a wire from the headers from d10 to d9. I take it that wouldn't work if I had the ethernet shield below it?

No. The ethrnet library is not as easy to change the slave select.

SurferTim: No. The ethrnet library is not as easy to change the slave select.

How would I connect pin 10 on the nfc shield to pin 9 on the arduino if there is a shield already connected to it?

Sorry for all the questions

Also I've heard of issues with the W5100 chipset not allowing other spi devices, do you know if the W5200 has the same issues?

The. W5100 doesn't have an issue. Don't know for certain about the w5200, but would guess no issue with it either.

Edit: the Ethernet library has a small bug. Ethernet.begin() leaves the w5100 slave select LOW (active). You must set it to HIGH after the begin call.

SurferTim: The. W5100 doesn't have an issue. Don't know for certain about the w5200, but would guess no issue with it either.

Edit: the Ethernet library has a small bug. Ethernet.begin() leaves the w5100 slave select LOW (active). You must set it to HIGH after the begin call.

Do I need to use this library/ follow these instructions? - https://github.com/jmgjmg/PN532

After reading around this is looking way more complicated than I thought, I may just buy a sd breakout board and leave the ethernet out of my project, which sucks but it isn't essential.

EDIT or buy an ethernet breakout board aswell, but would that leave me with the same issues?

dathtom: How would I connect pin 10 on the nfc shield to pin 9 on the arduino if there is a shield already connected to it?

The D9 pin is connected to the Arduino through the ethernet shield. Place a small jumper wire from D10 to D9 on the NFC shield and it will connect ok. D9 is not used by the ethernet shield.

dathtom: Do I need to use this library/ follow these instructions? - https://github.com/jmgjmg/PN532

Follow those instructions. They are the same as what johnwasser and I recommended, except it appears to use D3 instead of D9, but the theory is the same.

SurferTim:

dathtom: How would I connect pin 10 on the nfc shield to pin 9 on the arduino if there is a shield already connected to it?

The D9 pin is connected to the Arduino through the ethernet shield. Place a small jumper wire from D10 to D9 on the NFC shield and it will connect ok. D9 is not used by the ethernet shield.

dathtom: Do I need to use this library/ follow these instructions? - https://github.com/jmgjmg/PN532

Follow those instructions. They are the same as what johnwasser and I recommended, except it appears to use D3 instead of D9, but the theory is the same.

Thank you so much for your help :) I bought an SD breakout for the time being since I have time constraints but if I have time to expand it later I'll try that.