working rfid on hwv2, latest arduino-esp

This commit is contained in:
2021-11-27 11:07:16 +01:00
parent c5291f5566
commit bb9c4c8228
7 changed files with 29 additions and 23 deletions

View File

@@ -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);
}
}
}
//*****************************************************************************************//