PN532 Ethernet ESP8266/SPI error

Hi! At this moment I’m working on a project that needs a NFC module with Ethernet communication, I’m using the ESP8266 as a central microcontroller.

I’ve selected the PN532 as a NFC module because with this module I can read the UID of credit card, but pay card, passport and more … As my microcontroller is the ESP8266 I only can use the SPI communication with the PN532 because the I2C is not supported.

The Ethernet module that I’m using is ENC28j60, with this module I can query web services and it works ok.

Each module works okay with my microcontroller, but the problem is when I try to use both modules in the same code.

If I initialize first the Ethernet (ENC28j60) module and after the NFC module (PN532) then in the loop I can read NFC tags but I can’t send petitions to the web service.

When I initialize first the NFC module (PN532) and after the Ethernet module (ENC28j60) I can sent petitions to the web service but I can’t read NFC tags.

Below my sketch.

#include <UIPEthernet.h>
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_SPI pn532spi(SPI, 2);
NfcAdapter nfc = NfcAdapter(pn532spi);

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;

char *WebServiceServer = "";
String petition = "/comments?postId=1";
String Response = "";

void setup()

    Ethernet.begin(mac);  // initialize the Ethernet module

    nfc.begin(); // initilize the NFC module 

void loop()

    if (nfc.tagPresent())
        Serial.println("tag present");
        Response = readResponse();

In this case, I can read NFC tags but I can’t send petitions to my web service.

I think that the PN532 library modifies the SPI communication and this is the reason why the ethernet don’t work ok with this module.

In my project, I can change this modules but I prefer don’t do that cause the PCB is already done.

I hope you could help me. Thanks!