Skip to main content
Visitor II
November 29, 2019
Solved

NDEF writing/reading via I2C in X-Nucleo- NFC04A1(ST25DV)

  • November 29, 2019
  • 35 replies
  • 4436 views

Hi I'm trying to write text via NDEF library to be available to read from EEPROM by phone nfc aplication. Also I want to read text send by phone directly to EEPROM. I tried to change NDEF_URI example method to implement NDEF_WriteText and NDEF_ReadText method and write some text into ST25DV EEPROM and read from but honestly I have no idea what's wrong with my conception. Could you show me some code where you are using these methods?

    This topic has been closed for replies.
    Best answer by Rene Lenerve

    Hi @NewOne​ ,

    Here is a simple example to write a simple Text NDEF message and read it after.

     /* Init ST25DV driver */
     while( NFC04A1_NFCTAG_Init(0) != NFCTAG_OK );
     
     /* Reset Mailbox enable to allow write to EEPROM */
     NFC04A1_NFCTAG_ResetMBEN_Dyn(0);
     
     NfcTag_SelectProtocol(NFCTAG_TYPE5);
     
     /* Check NDEF presence, if no init mem in Tag Type 5 */
     if( NfcType5_NDEFDetection( ) != NDEF_OK )
     {
     /* If CCFile is not present add it to memory */
     CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E1_CCFILE;
     CCFileStruct.Version = NFCT5_VERSION_V1_0;
     CCFileStruct.MemorySize = ( ST25DV_MAX_SIZE / 8 ) & 0xFF; // ST25DV_MAX_SIZE = 0x200 => 4Kb memory
     CCFileStruct.TT5Tag = 0x01;
     /* Init of the Type Tag 5 component */
     while( NfcType5_TT5Init( ) != NFCTAG_OK );
     }
     
     /* write text message to EEPROM */
     while( NDEF_WriteText( "NDEF Text message" ) != NDEF_OK );
     
     NDEF_Text_info_t Text;
     sRecordInfo_t record;
     uint8_t p_ndef_buffer[64];
     
     /* read NDEF file */
     NDEF_ReadNDEF(p_ndef_buffer);
     /* Extract record info */
     NDEF_IdentifyBuffer(&record,p_ndef_buffer);
     
     /* Read Text in record */
     NDEF_ReadText( &record, &Text );

    Hope this could help you.

    Regards.

    35 replies

    Explorer
    March 30, 2023

    Hi,@Rene Lenerve​ 

    I use the NDEF.URI sample code, but the memory for the tag is empty. I found my problem. I did not connect ST1 to the 3.3v position correctly,whether I need to do this in order to read NDEF messages correctly.0693W00000bhCtMQAU.png

    ST Employee
    March 30, 2023

    Hi @帅罗.1 (Community Member)​,

    Great that you found the issue for the NFC7. This ST1 connector is used to select power for the ST25DVxxKC (3.3V comming from the nucleo MB1136C or Energy Harvesting coming from the RF Field). Be careful, regarding your screenshot you need to shunt the centered pin with the right-pin (3.3V), otherwise ST25DVxxKC will not be powered (and you will redirect both power supplies, the EH pin to the 3.3V).

    Kind Regards.

    0693W00000bhDCJQA2.png

    Explorer
    March 30, 2023

    Hi,@Rene Lenerve​ 

    If I need to use the NDEF_URI sample code and display massage by ST25 NFC Tag, I also need to connect ST1 to the 3.3v position correctly.

    Kind Regards.

    ST Employee
    March 30, 2023

    Hi @帅罗.1 (Community Member)​,

    I'm not sure to understand your point and I'm not sure you have understood correctly my explanation. You only need to connect the jumper ST1 as per the picture I shared previously. This will powered the ST25DVxxKC to allow I²C communication (ST25DVxxKC Vcc connected to 3.3V). The RF communication is always available as it is powered by the RF Field. The EH pin is an output and used to power another small device by harvesting energy from the field. You can found more information in the DataSheet of the ST25DVxxKC.

    Hope this will help you.

    Kind Regards.

    Explorer
    March 31, 2023

    Hi,@Rene Lenerve​ 

    Thank you for your help, I have successfully solved the problem, wish you a happy life!

    Kind Regards.