Creating a dynamic NFC Tag with Arduino and the TI

Creating a dynamic NFC tag, e.g. a NFC Tag that looks like a static tag to an Android/Windows Smartphone but whose content (e.g. URL) can be changed dynamically, is a bit complicated if you’re not using the Android APIs and accept the “form factor” of a smartphone. There are commercial solutions available, like the DTAG100 but you pay an extra $100 for not knowing how to update an NFC chip. So figuring out how to program a dynamic NFC Tag has been a long time goal of mine. Finally, I’ve something to share.

IMG_20130902_090543

What you see above is the RF430CL330H from Texas Instruments (TI). Actually, you see the target board that includes the chip in the middle. The target board adds some electrical components such as a few resistors and capacitors here and there that are required to make the chip work correctly. Also, the target board adds a built-in NFC antenna and makes it really easy to connect wires to it. The wires shown are connected to an Arduino.

To understand how to program the NFC chip, you have to dive into a few protocols and standards. The NFC target board communiates with the Arduino via I2C, a pretty well-known communication protocol that only consumes 2 wires on an Arduino and is therefore very popular. It is all byte-based, so you read and write from registers to communicate with the NFC chip. We’ll not go into detail here, but the above link to the NFC chip would give you the register info for the NFC chip.

Next up is NDEF – NDEF is the NFC Data Exchange Format – a standard by the NFC Forum. It defines, which byte-array exactly makes up a valid NFC message – for a URL for example. It’s again bytes, lot’s of bytes. Around 40 for a smaller 10 character URL. The hard part here is the composition of the bytes. “http://” in a typical URL is for example replaced with a single byte, as it saves space and NFC tags typically cannot hold a lot of data.

Together with Ten Wong, whom I met via the TI Forums and we later communicated along on Google+, I was able to put it all together. He also wrote a library which abstracts the NFC chip. There is one pretty bad issue with the Arduino Wire library, which does the I2C Communication: it will send a stop-bit after 20 or so characters. The problem is that the NDEF message is > 40 bytes. That was causing the messages to be broken. Which files to change exactly can be seen here.

My final addition to this mix was to make the Arduino communicate via a serial connection to a PC or Mac and update the NFC chip with the URL received via Serial. The format is this:

^www.hybris.com^

I am omitting the http:// at this point and only support http:// URLs. Changing that is not very hard though.

Finally, here is the code that is required to make this all work. It is processing code, Arduino Uno and Mega compatible. It will assume the TI NFC Target board is connected as shown in the pic above to I2C and the +3.3V and GND.

The loop() method is waiting for the first ^ and will then call the updateURL method, which will read all data from Serial till another ^ is received. This method is also calculating the dynamic NdEF byte array and then finally hands it over to Ten’s library for storage on the NFD chip.

The cost of the setup is around $15 for the dynamic nfc chip on the target board, plus an Arduino. If you buy a clone, you can get one for around $10 which brings the total solution to a price point of around $25 plus shipping. Of course, this is prototyping and mass producing this probably costs a few dollars only.

Tell us what you think:

5 thoughts on “Creating a dynamic NFC Tag with Arduino and the TI

  1. Dear Sir,

    I am doing a similar project using the rf430cl330h but instead of arduino I use usb. It still communicates with iic. I have many difficulties making it work. I would like to ask you one question to verify my connections on the circuit. Could you please tell me which pins do you have connected, where did you connect them and why? On your photo it seems like all the pins are used and it confused me. Thank you in advance.

    Kind regards,
    Marinos Loukaidis

  2. Sai says:

    Hello Sven, Thank you for providing such a great resource. I want to hook up my Arduino Uno to the NFC board as well but I don’t see how you did that. Could you please upload a picture of the back of the board with its connections to the arduino?

    Thanks!

    • Sven Haiges says:

      Hi Sai, this is quite an old post, so sorry I can’t provide a pic right now I guess. But I remember that I hooked it up to an Arduino Micro, which is very similar to an Arduino Leonardo. I remember the tricky part is to check the Wire and Interrupt Pins for your board. SDA/SCL are on pin 2 and 3 I think. Interrupt 1 is then used, too, which needs to be on a different pin (1 is Pin3, a bit strange now that I look at it). I hope I could help you at least a tiny bit…

      • Sai says:

        Hello Sven, thank you it does help. I wired my board with a header too but having trouble with programming the device. The code you provided is not working for me. What files are you including? I tried running this code and also separately tried running Ten Wong’s code as well. Both do not work.

        I would really appreciate your guidance on this.

        Regards,
        Sai

Comments are closed.