cancel
Showing results for 
Search instead for 
Did you mean: 

Read the RFID of a card with NFC03A1

JBott
Associate II

I read all the .cpp and .h library but I can't find any routine that shows the RFID of the card, can you help me ?

1 ACCEPTED SOLUTION

Accepted Solutions
Rene Lenerve
ST Employee

Hi juju.botton1,

I didn't manage to make your project compiled on my PC, I don't know why something has probably corrupted while I opened it under my environment.

I've noticed something that could explain some of your problems. In your project with the Wifi module, it seems that you missed to copy some functions. in stm32l4xx_it.c there are timer interrupt functions and irq that I didn't find. In the main.c, MX_TIM2_Init (3 and 4 also) are missing. Some defines in main.h are missing. in stm32l4xx_hal_msp.c there some MSP initializations missing too.

Hope this can help you.

Regards.

View solution in original post

27 REPLIES 27
Rene Lenerve
ST Employee

Hi juju.botton1,

For an ISO14443A, the UID is collected during anti-collision. You can try using the ISO14443A_MultiTagHunting function in lib_iso14443Apcd file to help you.

Hope this can help you

Best Regards.

JBott
Associate II

Thank you for your answer, I tried to use this routine, and as I understand it, it put the data in the uint8_t *pUIDout but when I try to display *pUIDout It's always 0 and never the UID of the card

Rene Lenerve
ST Employee

Hi juju.botton1,

Before reading or writing the tag you will need to select a protocol on the nfc reader. The process is to send the select protocol command to the reader.

For that you can use the ISO14443A_Init() function available in lib_iso14443pcd.c/.h. This function is not call by the ISO14443A_MultiTagHunting function, that's why you didn't received the UID I think.

Hope it can help you.

Regards.

JBott
Associate II

Hi,

I used the example in the STM32duino library because the X-NUCLEO-NFC3 is not available for my board (STM32L476RG) and when I scan my NFC card it displays me that this is a NFC type 2 card. As I want to display the UID of the card, I wrote this in the TRACK_NFCTYPE2 case

ISO14443A_Init();

ISO14443A_MultiTagHunting(pNbTag, pUIDout);

SerialPort.print(*pUIDout);

but it still displays 0 on the output

Rene Lenerve
ST Employee

Hi,

I tried with a STM32F401 Nucleo board (not arduino but ST nucleo boards) and it worked correctly. Returning the correct UID from the tag (with ISO14443A_MultiTagHunting function), and detecting as a Type 2 Tag.

I didn't understand which board you are using with which firmware?

Regards.

JBott
Associate II

Hi,

I have this board

https://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-ultra-low-power-mcus/stm32l4-series/stm32l4x6/stm32l476rg.html

And this NFC module

https://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-nfc03a1.html

As the X-NUCELO-NFC3 examples are not available for my board I can't run them, so I tried the arduino example which work but only to detect the NFC type but not display the UID but I need the UID

Rene Lenerve
ST Employee

Hi,

the link you wrote is for the STM32L476 chip not the board, so I guess it is the https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-l476rg.html Nucleo board.

What I suggest so, is to download the X-CUBE-NFC3 software package (if you don't already downloaded it, https://www.st.com/content/st_com/en/products/embedded-software/st25-nfc-rfid-software/x-cube-nfc3.html) and add the STM32L476 MCU to it. As the Nucleo boards are similar in terms of pin assignment it should be easy to do it.

Attached you will find the files and folders to copy on your X-CUBE-NFC3 software package. Before doing this save your modifications if any or it will erase some of your work.

I don't know which IDE you are using so i've done it under keil.

Hope this can help.

Regards.

JBott
Associate II

Hi,

You're right this is the Nucleo board I'm using.

I read the code in the X-CUBE-NFC3 and it is the same than in the Arduino library, it only displays the NFC type, but I want to display the UID of the card

I'm using the Arduino IDE which is the only one I'm used to code with. I already tried the exemple X_NUCELO_NFC03A1_HelloWorld which only gives the NFC type. You told me the routine to display the UID is "voidISO14443A_MultiTagHunting ( uint8_t* pNbTag, uint8_t *pUIDout );", maybe can you explain me how this one work. As I understand it I have to give two args that I declare and when the routine is finished I display these ones ? So the *pUIDout should contains the UID

Here's how I use it:

uint8_t* pNbTag;

uint8_t *pUIDout;

ISO14443A_MultiTagHunting(pNbTag, pUIDout);

SerialPort.print(*pNbTag);

SerialPort.print(*pUIDout);

Both print function displays 0, maybe I use it the wrong way

Rene Lenerve
ST Employee

Hi juju.botton1,

I sent you this code, because I use Keil and I tried it with a type 2 tag + nucleo L476 + nfc03. It was returning the UID with the ISO14443A_MultiTagHunting function.

I added it in the file lib_95HFConfigManger.c (not present in my zip attached previously).

  /******* NFC type 2 and 4A ********/
  if ((tagsToFind&TRACK_NFCTYPE2) || (tagsToFind&TRACK_NFCTYPE4A))
  {
    PCD_FieldOff();
    HAL_Delay(5);
    ISO14443A_Init( );
    ISO14443A_MultiTagHunting(&pNbTag, pUIDout);
    if(ISO14443A_IsPresent() == RESULTOK)
    {			
      if(ISO14443A_Anticollision() == RESULTOK)
      {	
        if (((ISO14443A_Card.SAK&0x60) == 0x00) && (tagsToFind&TRACK_NFCTYPE2)) /* TT2 */
          return TRACK_NFCTYPE2;
        else if (((ISO14443A_Card.SAK&0x20) != 0x00) && (tagsToFind&TRACK_NFCTYPE4A))/* TT4A */
          return TRACK_NFCTYPE4A;
      }
    }
  }
  

I will have a look how to do it with Arduino IDE.

Hope this can help you.

Regards.