Does this project spark your interest?

Become a member to follow this project and don't miss any updates


"Chad" - The NFC Voting System

Using NFC NTAG203 tags as voting tokens

Similar projects worth following
The goal of the project is to develop a standalone voting kiosk that uses UID from NTAG203 nfc tags to allow a user to vote only one time. This is implemented in two steps:

1. UID from all possible voting tags are read in and dumped to a C header file which is then flashed to the microcontroller's program memory

2. In voting mode a tag's UID is checked against the array in program memory. If found, the index is checked from a bit-packed array in EEPROM for persistent storage of which tags have and have not been used to cast a ballot.

I was under a tight time constraint for this project. I had about 16 days to ship the complete rig (under best-case shipping conditions). I ended up getting it finished in just 11 days!

​The Origins

When we decided to throw a party in LA (which became know as ​The Gathering) I wanted it to be more than just free t-shirts and beer. Laser Graffiti popped to mind and I was glad that Ben was willing ​to take the lead on that project. ​But I figured there should be more; something that people could take home with them. I had under one month to pull it together so custom PCBs would be a stretch. The idea for NFC tags sprouted up mainly because we don't see them in very many hacks. Why? After all, the tech is pretty cool. I discovered it's because there aren't any easily found hardware libraries that are NFC standard compliant. More on this in a bit. Here's an image of the 500 custom printed cards I ordered for The Gathering.


What do you do to make the NFC tags you're handing out even cooler? Embed stuff on them that is awesome. Well, that was the plan. Now you've got something on the card, but if you can't use it at the party why are we handing them out? We were already using this event to judge interest in having a larger Hardware Hacking event in the area. Using the cards to vote on the overall theme of that future even seemed perfect. I ordered an NFC reader and some test tags (printing was going to take several weeks) to get to work.

Library Failure

In my mind I figured I'd study the specification and datasheet for the PN532 card reader and write my own library. After an hour of trying to control the reader with my Bus Pirate I realized this was a good way to spend months on a project when all i had was a couple of weeks (sixteen days to be specific). I switched to getting a proof-of-concept put together using an Arduino and ​known code from the good folks at SeeedStudio by way of our friends at Adafruit. Had I know that ElecFreaks was using the code examples from these other two companies I would have order from them instead just to support their open source efforts. Oh well, next order!​

The Library can read the hardware Unique ID from the NTAG203 hardware, but that's it. It can't read or write a data payload to the cards. It does support the Mifare cards, which I understand are a deprecated protocol and not standards compliant (which is why I opted to order NTAG203 instead).

This is a huge issue that the Hackaday community should address. I know that ​libnfc supports these tags. So porting the code to a manufacturer-agnostic microcontroller library should be fairly trivial given enough time! At some point I'll put out a call on Hackaday to do this, and offer up free cards and shirts to readers who want to work as a team toward open sourcing such a project.

Changing the Plan

It would have been cooler to have unique data on each card. I was thinking of a hex query string at the end of a URL which would provide a unique invite and a fairly robust anti-voting-fraud option. But that was when I thought I could program all of the cards quickly with the hardware I was using (pull a unique query string from EEPROM for each card write, use the query string as the voting token identifier). Here's ​the build log where I was thinking about that, and ​another before I received the NTAG203 test tags in the mail.

To get around this I hacked my own project before I even built anything. As I mentioned previously, the cards have a UID which is a feature from their RFID origins.​ ​I coded a proof-of-concept that read the 7-byte UID and printed it to the terminal. Later, this was turned into a jumper-enabled mode that prints the UIDs as a C header file. When the 500 cards arrived it only took me about 10 minutes to scan all of them, save the output as a header file, and write it back to the Arduino as a lookup table to ensure that each card could be used just once for voting.

To save space in EEPROM I used a bit-packed array to track the tokens. When the card is read, the lookup table is searched for a matching UID. The index at which it is found is then used as the "address" in...

Read more »

  • 1 × Piezo Buzzer Salvaged from a motherboard
  • 1 × Rotary Encoder Uses grey code
  • 3 × LEDs
  • 1 × PN532 based NFC reader/writer Used in SPI mode
  • 1 × Arduino duemilanove
  • 1 × HD44780 Character LCD 20 characters wide, 4 line, backlit
  • 500 × NTAG203 Type NFC tags (voting tokens) Custom printed for The Gathering

  • Labels and Out the Door

    Mike Szczys01/11/2014 at 00:12 0 comments

    Here's the test. The LEDs are waaaaay too bright. I sanded the clear domes on them down which helped a bit. This LCD display doesn't ahve the best visibility, but it looks better in person than shown above.

    This is the final picture I took before removing the base and bubble-wrapping it for shipping to The Gathering in LA. I heard today that the package arrived which is great. I should have no problem fixing anything that might have broken. If it had been lost in shipping that would be a different story.

  • Soldering Complete

    Mike Szczys01/10/2014 at 22:44 0 comments

    So here's the deal. One of my prejudices against Arduino is that it's an expensive board to leave with a project. But this is kind of a one-time thing so I was happy to find the Seeed Studio protoype shield for like $7.95 at the local Radio Shack. What I didn't bank on is the shield is larger than the Arduino footprint. No worried, I grabbed my tin snips and hacked off the left side of the board (beveled teh corners to get around the LCD mounting hardware).

    From there it was just a matter of point-to-point soldering. I did the LCD first since there are mutliple voltage and ground connections for that one. From there it was pretty simple to finish up the rest of the wiring. This did end up taking around two hours. But mostly because I was trying to be nice and neat with my cable routing.

    I used the header sockets that came with the prototyping shield as a connector for the LCD and NFC reader. I just bend over the PCB mount tails and soldered the wires directly to them.

    Not bad, of course I forgot to clean the fingerprints off of the LCD screen and underside of the acrylic before I got this far. I can't get a cotton swab in between there so I'll just have to deal with that imperfection.

    Here it is attached to the base. I did fire it up after soldering each component just to make sure I didn't hook anything up wrong. I just need to tweak the firmware. The dial adjusts the LEDs reverse of what it should. I'm not certain if this was a mistake in wiring the rotary encoder, or the LEDs, but it's an easy fix.

  • Let's build this thing

    Mike Szczys01/10/2014 at 22:28 0 comments

    Mechanical assembly always takes longer than I think it will. I figured one evening would be all it takes to build this thing, but by the time I figured out the size of the acrylic, cut a wood base for it, tested the layout of the components, then drilled and mounted everything I had run out of time.

    I reclaimed a chunk of protoboard for the Piezo. The IC breakout board on the left will be used for the rotary encoder. In this image you can see the three holes at the bottom of the acrylic for screwing it to he wooden base (there's a 15 degree bevel on that piece of wood).

    Much later in the evening I have everything mounted using nylon stand-offs (easy to cut with a utility knife and cheap at the hardware store) and 40-4 machine screws, washers, lock washers, and nuts. My hardware store only sells this stuff in stainless so it's a bit more expensive but still worth it to source them just down the street.

    You have to look closely to see the 3 LEDs. Radio Shack sells some plastic grommets for a 1/4" hole that the 5mm LEDs just snap into. Off to bed, soldering will happen tomorrow (full disclosure, I'm writing this up after the fact as build mode was all consuming of my time).

View all 8 project logs

  • 1

    Grab the code from this Github. You need to uncomment the uniqueSet array and index tracker in the code for the first time your compile the firmware. Compile and upload to the Arduino.

  • 2

    Use the git install method to add Seeed Studio NFC library:

  • 3

    Reset the ballot count (and records of which tokens have voted) by shorting pin3 to ground and pressing reset.

View all 8 instructions

Enjoy this project?



hackhead79 wrote 04/02/2014 at 22:14 point
Pretty nifty project and looks like NFC is really fun technology to play with! :)

  Are you sure? yes | no

erenemre wrote 01/22/2014 at 17:21 point
It was fun to vote using this little guy!

  Are you sure? yes | no

James Hobson wrote 01/12/2014 at 17:06 point
Looks great!

  Are you sure? yes | no

Similar Projects