cancel
Showing results for 
Search instead for 
Did you mean: 

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

ADist
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

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.

View solution in original post

11 REPLIES 11
Brian TIDAL
ST Employee

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
Associate II

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.

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
Associate II

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
ST Employee

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
Associate II

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

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
Associate II

Error..:confounded_face: 0690X000006Dt1JQAS.png

Brian TIDAL
ST Employee

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.