So, I've got this setup where I'm using a PN5180-NFC alongside an ESP to read 14443 tags. It's functional, but I'm encountering a bit of a problem with the read distance. Essentially, I'm finding that I need to bring the tag within a centimeter of the reader for reliable accuracy, which isn't quite cutting it for my project.
I'm wondering if anyone has any insights on how I might extend this read distance? I've been looking into RF amplifiers, but the papers I found I struggled to understand them. Any advice or pointers would be greatly appreciated!
Below is my code:
#include <PN5180.h>
#include <FastLED.h>
#include <PN5180ISO14443.h>
//Vermelho
int intensidadeR_bom = 255;
int intensidadeG_bom = 0;
int intensidadeB_bom = 0;
//Amarelo
int intensidadeR_mau = 255;
int intensidadeG_mau = 255;
int intensidadeB_mau = 0;
//Verde
int intensidadeR_mau2 = 0;
int intensidadeG_mau2 = 255;
int intensidadeB_mau2 = 0;
String inputStr;
int input;
String red = "RED";
String yel = "YEL";
String gre = "GRE";
String Off = "off";
#define LED_PIN1 32 // pino onde liga o LED 0 que é o primeiro
#define NUM_LEDS 3 // numero de leds na serie
CRGB leds[NUM_LEDS];
#define PN5180_NSS 5
#define PN5180_BUSY 4
#define PN5180_RST 2
PN5180ISO14443 nfc14443(PN5180_NSS, PN5180_BUSY, PN5180_RST);
uint8_t previousUid[10]; // Initialize with zeros
void setup()
{
FastLED.addLeds<WS2812, LED_PIN1, GRB>(leds, NUM_LEDS); // inicializa o controlador WS2812 no pino correspondente e o numero de leds
delay(100);
Serial.begin(1000000);
nfc14443.begin();
nfc14443.reset();
nfc14443.setupRF();
ledsOff();
}
void loop()
{
uint8_t uid[10];
nfc14443.reset();
nfc14443.setupRF();
if (nfc14443.isCardPresent())
{
uint8_t uidLength = nfc14443.readCardSerial(uid);
if (memcmp(uid, previousUid, uidLength) != 0 )
{
for (int i = 0; i < uidLength; i++)
{
Serial.print(uid[i], HEX);
Serial.print(":");
}
Serial.println("");
// Update the previous UID
memcpy(previousUid, uid, uidLength);
ledsOn();
return;
}
}
}
// Routine to dump a byte array as a continuous HEXimal number to Serial.
void printHEX(byte *buffer, byte bufferSize) {
for (byte i = 0; i < (bufferSize); i++) {
Serial.print(buffer[i], HEX);
Serial.print(":");
}
Serial.println("");
}
void ledsOff()
{
leds[0] = CRGB(0, 0, 0);
FastLED.show();
leds[1] = CRGB(0, 0, 0);
FastLED.show();
leds[2] = CRGB(0, 0, 0);
FastLED.show();
}
void ledsOn()
{
inputStr = Serial.readString();
if (inputStr == ((String)red)) {
leds[0] = CRGB(intensidadeR_bom, intensidadeG_bom, intensidadeB_bom);
FastLED.show();
leds[1] = CRGB(intensidadeR_bom, intensidadeG_bom, intensidadeB_bom);
FastLED.show();
leds[2] = CRGB(intensidadeR_bom, intensidadeG_bom, intensidadeB_bom);
FastLED.show();
} else if ( inputStr == ((String)yel)) {
leds[0] = CRGB(intensidadeR_mau, intensidadeG_mau, intensidadeB_mau);
FastLED.show();
leds[1] = CRGB(intensidadeR_mau, intensidadeG_mau, intensidadeB_mau);
FastLED.show();
leds[2] = CRGB(intensidadeR_mau, intensidadeG_mau, intensidadeB_mau);
FastLED.show();
} else if (inputStr == ((String)gre)) {
leds[0] = CRGB(intensidadeR_mau2, intensidadeG_mau2, intensidadeB_mau2);
FastLED.show();
leds[1] = CRGB(intensidadeR_mau2, intensidadeG_mau2, intensidadeB_mau2);
FastLED.show();
leds[2] = CRGB(intensidadeR_mau2, intensidadeG_mau2, intensidadeB_mau2);
FastLED.show();
} else {
ledsOff();
}
}