Ameba Arduino: [RTL8195AM] NFC - Access the content of NFC Tag
- Ameba x 1
- Smartphone with NFC feature x 1
There are many NFC application in Google Play, for example:
These applications can read the NDEF content of NFC Tags, as well as write NDEF content to NFC Tags. In this example, we will show you how to read and write the NFC Tag.
Open the sample code in “File” -> “Examples” -> “AmebaNFC” -> “StoreTagContent”. Compile and upload to Ameba, then press the reset button.
Here we use NFC Tools as example.
Open the application, select the “READ” tab at the top of the page. Then bring the phone near to Ameba. If the NFC connection is established, the data of the NFC Tag would be displayed in the App. Scroll down the page, you can see a “Hello World” message.
Next, select the “WRITE” tab at the top of the page. Click “Add a record” -> “Text”, and enter “new msg”, click “OK”, “Write”. Then bring the phone near the NFC Tag of Ameba.
If the write is successful, you can see a completed message.
Switch the tab back to “READ” to check the message is written to Ameba.
The “text/plain” content is modified to “new msg”. Note that the content would preserve even if Ameba is turned off.
NfcTag.appendRtdText("Hello World!")to add plain text NDEF content, then call
NfcTag.begin()to enable the NFC Tag.
In the sample code, we copy the buffer of the NFC Tag to the buffer of flash memory every time the NFC Tag is modified, and call
FlashMemory.update()to update to flash memory.
Next time the Ameba is turned on, we copy the buffer of flash memory to the buffer of NFC Tag.