Help with read distance PN5180 with ESP32

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();
  }
}

I've never used these antennas, but you can find them a lot on the web.

image

1 Like

Reading tags is never as good as reading cards, in terms of read distances. It's very much dependent on the quality of your PN5180 module... and you did not say what module you are using.

Reason is that there are hardware design issues that can impact performance.

But first check to see what voltage you are using to provide power to the antenna. I believe you can use 5V for the antenna. This provides a performance boost, even if the logic levels are 3v3.

If that does not help then you might need to check that the matching circuit used on your PN5180 board is properly tuned and has been designed to suit the module's antenna. If poor then little chance of improving read distance.

On the software side, you can make some small changes to the PN5180 transmit strength by changing some register settings on the PN5180. Need to check the datasheet - I did not.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.