working rfid on hwv2, latest arduino-esp
This commit is contained in:
@@ -1,26 +1,31 @@
|
||||
#include "rfid.h"
|
||||
|
||||
|
||||
PN532_SPI pn532spi(SPI, NFC_SS, NFC_SCK, NFC_MISO, NFC_MOSI);
|
||||
NfcAdapter nfc = NfcAdapter(pn532spi);
|
||||
|
||||
uint32_t lastRFID = 0;
|
||||
|
||||
//*****************************************************************************************//
|
||||
void initRfid()
|
||||
{
|
||||
//int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
|
||||
// int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
|
||||
nfc.begin(true);
|
||||
Serial.println(F("rfid init done")); //shows in serial that it is ready to read
|
||||
Serial.println(F("rfid init done")); // shows in serial that it is ready to read
|
||||
}
|
||||
|
||||
//*****************************************************************************************//
|
||||
void handleRfid()
|
||||
{
|
||||
if (nfc.tagPresent())
|
||||
uint32_t timeNow = millis();
|
||||
if (lastRFID - timeNow > RFIDINTERVAL)
|
||||
{
|
||||
NfcTag tag = nfc.read();
|
||||
String uid = tag.getUidString();
|
||||
Serial.println(uid);
|
||||
|
||||
if (nfc.tagPresent())
|
||||
{
|
||||
NfcTag tag = nfc.read();
|
||||
String uid = tag.getUidString();
|
||||
Serial.println(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
//*****************************************************************************************//
|
||||
|
||||
|
||||
Reference in New Issue
Block a user