2024-07-03 09:53 AM
Hier ist die englische Übersetzung deines Textes:
---
Hello everyone,
I am quite new to the STM family. I am currently working on a project where I need to send data to and read data from an NFC tag using an NFC reader (NFC07A1). This data should then be sent via Bluetooth to another microcontroller and output there via USART.
I have already familiarized myself with data input and output via USART. However, I first tried to read the UID of a tag. A UID is always displayed without using a tag. It turned out that it is the UID of the NFC07A1 because I read the UID of the reader using an Android app (just mirrored). As soon as I use my phone as a tag and hold it to the reader, an error message appears. Any other tag I have tried is not even recognized. Only the phone, but it is not readable.
This is the code to read the UID:
```c
void MX_NFC7_ReadUID(void)
{
char uid_str[50]; // Buffer to hold the formatted UID string
// Check if the NFC reader is ready
if (NFC07A1_NFCTAG_IsDeviceReady(NFC07A1_NFCTAG_INSTANCE, 3) == NFCTAG_OK)
{
// Read the UID of the NFC tag
if (NFC07A1_NFCTAG_ReadUID(NFC07A1_NFCTAG_INSTANCE, &uid) == NFCTAG_OK)
{
HAL_Delay(100); // Small delay to ensure the tag is detected properly
// Format the UID into the string
sprintf(uid_str, "UID: %08lX %08lX\r\n", (unsigned long)uid.MsbUid, (unsigned long)uid.LsbUid);
HAL_UART_Transmit(&huart2, (uint8_t*)uid_str, strlen(uid_str), HAL_MAX_DELAY);
NFC07A1_LED_Off(BLUE_LED);
NFC07A1_LED_On(GREEN_LED);
}
else
{
sprintf(uid_str, "Error reading UID.\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)uid_str, strlen(uid_str), HAL_MAX_DELAY);
NFC07A1_LED_On(YELLOW_LED);
}
}
else
{
sprintf(uid_str, "NFC reader not ready.\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)uid_str, strlen(uid_str), HAL_MAX_DELAY);
NFC07A1_LED_On(YELLOW_LED);
}
}
```
Can someone please tell me where the error lies? I am totally at my wit's end.
Thank you very much.
Best regards,
Solved! Go to Solution.
2024-07-04 12:16 AM
Hello Tamti,
I think there is a misconception here: NFC07 is an NFC tag and not an NFC reader. It will not be able to read other tags.
It is a so-called dynamic tag as it has also a wired interface to be able to exchange data with an NFC reader.
BR, Ulysses
2024-07-04 12:16 AM
Hello Tamti,
I think there is a misconception here: NFC07 is an NFC tag and not an NFC reader. It will not be able to read other tags.
It is a so-called dynamic tag as it has also a wired interface to be able to exchange data with an NFC reader.
BR, Ulysses
2024-07-04 12:37 AM
Hello Ulysses,
thank you very much for your Reply. I had the NFC01a1 before, but had difficulties to get the library included. So i asked my prof for advise and he gave me this other device.
Looks like i got the wrong device.
You helped me a lot.
BR, Tamti
2024-07-04 12:51 AM