Featured PostsHackerspaceMain Stories

FamiLAB Vending Machine is Now Compatible With Any NFC Tag

Ever since I got my NFC implant(s), I’ve wanted a way to pay with them. Normally, this would be impossible due to the fact that the security and technology in the type of NFC tags used for PayPass financial transactions are radically different from the chips in my hands. In some cases however, I can put a system between my chips and the payment facilities in order to translate for me. In this instance, this brought up a problem; the vending machine at the lab isn’t mine, and I don’t want to go drilling holes in it or worrying about hooking things up to talk to it that could possibly fry it. Enter a new possibility:

A little while ago, I saw a video about a new product called loop, Which is a coil of wire that sits in your phone case or in a small keyfob and emulates credit card swipes by behaving as an electromagnet and generating a magnetic field that changes direction rapidly. A credit card reader will see these reversals in the same way that it normally detects magnetic flux reversals from a credit card swipe. Making an electromagnet isn’t hard, it’s just a coil of wire. I made mine by cutting the housing off a solenoid I got from Skycraft. Once I had that in place, the next step is to get it talking to the credit card reader.

First of all, I figured it would probably be wise to know what I’m trying to accomplish, in theory. This paper is fantastic, I suggest you take the time to read it. After doing so, you will know everything there is to know about how credit cards work and what’s on them. This article was a fantastic follow up that got less into the mechanics and more into what the data encoded on cards actually means. Armed with this knowledge, I moved on to working on how to get that information into the credit card reader.

I found some code at that was very helpful in getting me started writing data through the coil. Obviously an Arduino can’t drive the voltages and current I needed, so I piped a 24v wall wart through a solid state relay (a regular relay wouldn’t be fast enough to reproduce the bits accurately). I could now *feel* the data being sent out through the coil (using my fingertip magnets) but the credit card reader wasn’t detecting the bits being written through the coil as a card swipe. A little more research netted me this article that went into necessary detail about the LRC.

The LRC is a checksum character that is not normally considered to be part of the card read. This is one last character that is added onto the end of the string, calculated as detailed in that article. Its purpose is simply to have a way to check if the string read in properly, since the LRC character can be checked, then the calculation can be performed by the reader and the two can be compared. If any of the characters in the card string change, then the way the calculation is performed means that the LRC will change and it will be regarded as a bad read. In my early stages of working with card data, before I wrote code to calculate the LRC for me, I found it was faster to just stick a character on the end (it’s hex, so there are only 16 possibilities) and just fire it through the coil to see if it’s valid. I did calculate out the LRC by hand once, but only once, and that was enough for me. Fortunately now I have code written to calculate the LRC, and it is automatically called when you pass a credit card string to writeCardString().

Now I had my first successful transmission of credit card data into the vending machine! I grabbed a prototype box, a mega 2560, dc>dc converter, and  a pn532 shield/mini pro to read NFC data. (All courtesy of the wonderful gadgetcat.com) and threw it all together.

Side note: An issue I have run into before with the PN532 shield is that the way the NFC library works, the loop() function in the Arduino will halt when you ask the PN532 to start looking for a chip. It will wait for a chip…and wait, and wait, and never time out. There is supposed to be an interrupt request pin on the shield to allow you to only look for/read a chip when one is present, but I have never had any luck getting it to work. Rather than pull my hair out any further trying to make that behave, I decided to pick up a mini pro for $8 and attach it to the bottom of the pn532 shield. This way, the mini pro will be blocked waiting for a NFC tag to appear and then read. When a tag does appear, I can just send the relevant tag info over serial to the main Arduino, which has not been blocked since it only has to read in serial data. For this project, I have finally finished code for both the mini pro side of things, as well as converted my serial read code into a nice convenient module that I can reuse in future projects.

(You have to hang the mini pro off the bottom because some of the pin holes aren’t on a 0.1″ grid, and thus will short if you put them over top of the evenly spaced holes on the shield. The mini you can put right on the proto area, but the mini is more expensive.)

The result? Sweet, sweet wallet-free payment bliss:

Code available at:

I promise nothing as to how nicely it’s written, but it works.)

(For the portion that goes on the mini pro and sends UIDs over serial when NFC tag is presented)

Parts list:

NFC Forum Compatible Implantable Tags From Dangerous Things
The solenoid was a small 24v from Skycraft @ $3
The solid state relay was rated at up to 60vdc, driven by 2.5 – 10v dc. $5 @ Skycraft
Random 24vdc power supply I found around the lab
Cat6 cable for signal from/power to the PN532 board

5 thoughts on “FamiLAB Vending Machine is Now Compatible With Any NFC Tag

  • Congrats on the Hack-a-day post from a fellow Orlandian!

    • Thanks! Feel free to come visit the lab and see it sometime!

  • russell

    Never heard of familab before but I saw you got the solenoid at skycraft and I knew you had to be in Orlando. Been going to sky craft since I was a kid with my father. Most awesome place ever. Awesome project.

    • Yeah, ditto. Feel free to drop by! Open houses are first Tuesday of every month, that’s when you’ll see all the cool stuff. We have lots from Skycraft in here.

  • Nicely done!! ^^ I was kind of wondering if what happens if the user does not press the confirmation button. Does it confirm the transaction as time out basis?

Comments are closed.