Open DavidMR91 opened 2 years ago
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
//Adafruit_PN532 nfc(PN532_SS_1);
Which one is being used for the PN532? Since they are sharing the SPI bus, use hardware SPI with the PN532.
Also make sure the Ethernet library is able to share the SPI bus and manages its chip select pin correctly.
define PN532_MISO (50)
define PN532_MOSI (51)
define PN532_SCK (52)
define PN532_SS (34)
//#define PN532_RESET (3) // Not connected by default on the NFC Shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //MAC Address IPAddress ip(192,168,1,5); //arduino IP EthernetClient client; const int ledPin = LED_BUILTIN; String UID_CARD; String attendance_status; String user_card; Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS); //Adafruit_PN532 nfc(PN532_SS_1);
void setup(void) { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); Serial.begin(250000); while (!Serial) delay(10); // for Leonardo/Micro/Zero nfc.begin(); Serial.println("Mesin Absen Gabut"); delay(2000); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print("Didn't find PN53x board"); while (1); // halt } // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// configure board to read RFID tags nfc.SAMConfig(); Ethernet.begin(mac, ip); Serial.print("Local IP: "); Serial.println(Ethernet.localIP()); Serial.println("Waiting for an ISO14443A Card ..."); }
void loop(void) { uint8_t success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) { // Display some basic information about the card Serial.println("Found an ISO14443A card"); Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes"); Serial.print(" UID Value: "); nfc.PrintHex(uid, uidLength); Serial.println("");
} }