ENC28J60 Ethernet module connected to SPI pins. PN532 connected to I2C pins.
Ethernet module works well with socket programming until nfc searches for a card. When updateNFC function called, ethernet module stops responding my packets that comes from my computer. I followed library to detect what code block causes this. When PN532 library trys to use Wire library the problem occurs. How can i solve this problem.
Libraries
#include <UIPEthernet.h>
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
EthernetUDP udp;
Setup
Serial.begin(9600);
delay(1000);
Serial.print("--> Initialize NFC: ");
Serial.println(!nfc.begin());
Serial.print("--> Initialize Network: ");
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
Ethernet.begin(mac, IPAddress(192,168,2,200));
Serial.println(udp.begin(5000));
Loop
loopCounter++;
if(loopCounter % 250 == 0){
updateNFC();
}else{
updateEthernet();
}
Update Ethernet
// Listen a port and echo comming message...
Update NFC
Serial.println("Scan a NFC tag...");
if (nfc.tagPresent()){
NfcTag tag = nfc.read();
tag.print();
}
An Example Output from Console