Skip to main content
ADist
Associate II
February 22, 2019
Solved

How to detect UID from NFC TAG via NFC03A1 with STM32 F401RE

  • February 22, 2019
  • 9 replies
  • 6360 views

I can not detect the UID through the CR95HF_TagDetect sample program. The program only detects the tag type but not the UID as described on page 15/21 of the UM2045 document (Figure 7). Where is this program described whose output is described in figure 7? Thanks to those who want to answer me.

This topic has been closed for replies.
Best answer by Brian TIDAL

Hi,

here is the modified main.c file (in C language, your modification are not valid).

Rgds

BT

9 replies

Brian TIDAL
Technical Moderator
February 22, 2019

Hi,

here is the User Manual in line with the X-CUBE-NFC3 1.4.0 that you are currently using.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ADist
ADistAuthor
Associate II
February 22, 2019

Thanks but i have a problem.

I would like to make a door opener with a relay via the NFC03A1 module. To do this I need the tag identification code. But I can not take it. What example files should I use? I do not need the TYPE of TAG but the CODE UID or HEX CODE.

Brian TIDAL
Technical Moderator
February 22, 2019

Hi,

based on X-CUBE-NFC3 1.4.0, you can use:

  • ISO15693_GetUID() for NFCV tags (beware that the UID bytes are transmitted least significant byte first, so the order is inverted...)
  • read fields UID and UIDsize from ISO14443A_Card structure for NFCA Type2 and Type 4 (add extern ISO14443A_CARD ISO14443A_Card;)
  • read field PUPI from ISO14443B_Card structure for NFCB (add extern ISO14443B_CARD ISO14443B_Card;)

For example, if you dump (ISO14443A_Card.UID, ISO14443A_Card.UIDsize); in case TRACK_NFCTYPE4A, you will have:

TRACK_NFCTYPE4A NFC tag detected nearby 02A30000C79071

where 02A30000C79071 is the tag UID (double size UID)

Feel free to share more details on your applications such as the type of tag you plan to use.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ADist
ADistAuthor
Associate II
February 27, 2019

I tried but I can not compare the UID on teraterm far.

I have a type 2 tag. What should I enter here to make the uid appear on the terminal?

 case TRACK_NFCTYPE2:

   {

    LED_Off(GREEN_LED1);

    LED_On(BLUE_LED2);

    TagDetected = true;

     

    if(terminal_msg_flag == true )

    {

     terminal_msg_flag = false ;

      

     /*---HT UI msg----------*/

     sprintf( dataOut, "\r\n\r\nTRACK_NFCTYPE2 NFC tag detected nearby " );

     HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 500 );

    }

   }

   break;

    

Thanks

Brian TIDAL
Technical Moderator
February 27, 2019

Hi,

just modify the HT UI msg code to add a call to Dump the UID

 /*---HT UI msg----------*/
 sprintf( dataOut, "\r\n\r\nTRACK_NFCTYPE2 NFC tag detected nearby " );
 HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 500 );
 HexDump(ISO14443A_Card.UID, ISO14443A_Card.UIDsize);

Add the following simple function in main.c:

static void HexDump(uint8_t *s, uint8_t lg)
{
 static char dataOut[3];
 
 while (lg-- > 0)
 {
 sprintf( dataOut, "%2.2X", *s++);
 HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 500 );
 }
}

This should display the hex value of the UID on the terminal.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ADist
ADistAuthor
Associate II
February 27, 2019

Okay i modify UIT msg code

  1. /*---HT UI msg----------*/
  2. sprintf( dataOut, "\r\n\r\nTRACK_NFCTYPE2 NFC tag detected nearby " );
  3. HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 500 );
  4. HexDump(ISO14443A_Card.UID, ISO14443A_Card.UIDsize);

and i add this on main.c

  1. static void HexDump(uint8_t *s, uint8_t lg)
  2. {
  3. static char dataOut[3];
  4. while (lg-- > 0)
  5. {
  6. sprintf( dataOut, "%2.2X", *s++);
  7. HAL_UART_Transmit( &UartHandle, ( uint8_t * )dataOut, strlen( dataOut ), 500 );
  8. }
  9. }

ERROR MESSAGE

But ISO14443A_Card is not diclared

Brian TIDAL
Technical Moderator
February 27, 2019

Hi

as explained in my answer from February 22, 2019 at 6:01 PM, you have to add extern declaration:

extern ISO14443A_CARD ISO14443A_Card; 

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ADist
ADistAuthor
Associate II
February 27, 2019

Error..:confounded_face: 0690X000006Dt1JQAS.png

Brian TIDAL
Brian TIDALBest answer
Technical Moderator
February 27, 2019

Hi,

here is the modified main.c file (in C language, your modification are not valid).

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ADist
ADistAuthor
Associate II
February 27, 2019

Thanks a lot. It work!!!!!! :D

Brian TIDAL
Technical Moderator
March 5, 2019

Hi,

for your information, the updated X-CUBE-NFC3 package is now available on st.com (make sure to refresh your browser cache before downloading: the zip file should contain STM32CubeExpansion_NFC3_V2.0.0 folder). This package is based on RF Abstraction Layer (RFAL) providing a common API for ST25R95 (CR95HF), ST25R3911 and ST25R2916 readers. The nucleo demo is also common.

This updated package is aligned with UM2045 v2.0. and the demo displays the UID.

We recommend to use this package for new developments.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.