QR Codes: The Accessible, Reliable RFID Replacement

8 min read


"if we employed Near Field Communication (NFC) technology...no one with an Apple iPhone would be able to participate" [1]

This is a problem faced by many developers today. Although Apple has opened up their NFC communication chip to allow for READING only, it is still far from being as usable as an inter-device communication facility compared to the samsung galaxy suite of phones. [2]

As of iOS 11 Apple has introduced Core NCF which will allow a reader mode for encoded NFS Tags, "Apple will limit the NFC capabilities to only reading encoded NFC tags; unencoded tags will not be recognized by the iPhone." [3]

Inter-device Communication

When you think about inter-device communication, a couple of technologies come to mind. Infrared, Bluetooth and 4G have been around and are all tried and tested. They are still heavily used for applications across mobile hardware manufacturers globally. Our trouble however stems from a lack of consistency between mobile hardware and OS specifications.

Infrared technology is an aging tech that was prevalent in phones and mobile devices during the mid-2000's. This tech is lacklustre at best, requiring both devices have infrared transceivers as well as a direct (UV light free) line of sight between each other. Additionally, the data throughput for this tech is, to put it nicely...slow.

Next up we have Bluetooth. Bluetooth has made some massive improvements and is a fantastic standard for communication between devices. These days a Bluetooth speaker, headphones or car connection is considered standard. It is a fantastic platform but it has its drawbacks like needing to 'pair' devices. Pairing 2 mobile devices together to transfer pictures is not as easy as pairing your phone with a set of headphones.

Bluetooth stacks are often not interoperable between OS’s and sometimes even devices. This is mainly in relation to communications between Android and iOS devices and even some Android devices to other Android devices.

Finally, we have 4G. Though we do have Dropbox or Google drive for file transfer. In my opinion few have done it as well as an application called Bump. The app allowed you to select a file to transfer, and TAP devices together to transfer the file. It utilised 4G for transfer, and GPS/Haptic controllers for identification of the devices that are transferring / being transferred to.

How to transfer without Wireless technologies?

This begs the question, how is it that we can communicate between devices without wireless tech. 4G is fantastic for transfers, however, given the Australian telecommunication network, not always reliable (especially in rural areas).

This is where we get to the crux of this article. QR Codes.


QR Codes can be utilised to allow the transferal of data from one device to another via the use of the device's screen and the opposing device's camera, without the use of Bluetooth, 4G and Infrared etc.

QR Codes are commonly used for product tracking, item identification, time tracking, document management, and general marketing. Their advantages over typical barcodes are plentiful. They can be read in all different orientations, contain error correction, and can store much more information than a standard barcode. They are also not centralised or allocated by an authority, allowing the developer full freedom to generate as many QR codes as they like.

Although not well known a 1 inch QR code can contain up to 2953 bytes of uncompressed data, and with BZIP Compression, this can be increased up to ~8kb of data. [4]

Worked example

And now we get to the fun part. We see exactly how we can utilise QR Codes for transerring JSON objects between devices. Our hypothetical app has a form for fishermen to fill in information about shark sightings, and then it has the ability to be transferring to a fisheries officer whilst they are still out on their boats. This precludes the use of 4G as it is far offshore, and also hinders the use of Bluetooth as the fisherman may not have a device that communicates with the fisheries officer. We also can't ask 2 sailors to spend time pairing devices whilst rocking from side to side in 2m swells (I know there are other issues here too, this is a fictitious example but I'm sure there are far more plausible examples where this could be useful ☺).

Step 1: Create your first PhoneGap application
Thanks to the wonders of the internet, there is already a tutorial on how to create your first PhoneGap application.

Step 2: Install and configure the QR Code plugin for PhoneGap
Again we stand on the shoulders of people with much more time on their hands, and head to GitHub. Here we find the PhoneGap plugin called BarcodeScanner.
This plugin allows you to create and read QR codes across all devices in a PhoneGap application.

Step 3: Convert to JSON
So now we have our app and library set up, let's wade into the murky waters of code.

Take for example the following API result set (coming from api.fish.wa.gov.au [5]).
First port of call is to take the javascript object and convert it to JSON.

var j = GetJavascriptSightingObjectFromForm();

Let's see what is in variable "j":

    "RawDataId": 18605,
    "ObjectId": "768",
    "Distance": null,
    "DistanceUnit": null,
    "InteractionValue": "Detected",
    "InteractionId": "4",
    "TownProximity": null,
    "LocationValue": "Garden Island (north end)",
    "SightingNumbervalue": null,
    "ReportDateTime": null,
    "SightingDateTime": "2016-07-09T21:21:00",
    "SightingSizeValue": null,
    "SightingSpeciesValue": "bronze whaler",
    "OwnerValue": "Fisheries advise",
    "LocationDetail": null,
    "LocationX": 115.6428,
    "LocationY": -32.1441


Step 4: Minify and/or Compress
Next up we need to shrink this data down to a smaller size. For smaller objects (like this one) we need only minify out the whitespace:

{"RawDataId":18605,"ObjectId":"768","Distance":null,"DistanceUnit":null,"InteractionValue":"Detected","InteractionId":"4","TownProximity":null,"LocationValue":"Garden Island (north end)","SightingNumbervalue":null,"ReportDateTime":null,"SightingDateTime":"2016-07-09T21:21:00","SightingSizeValue":null,"SightingSpeciesValue":"bronze whaler","OwnerValue":"Fisheries advise","LocationDetail":null,"LocationX":115.6428,"LocationY":-32.1441}

For larger items we can also run it through a BZIP Compression [6]:


Compression ratio: 159 % Original size: 437 bytes Result size: 275 bytes

Step 5: Generate a QR Code:
Taking the Compressed text string above, and send it through our QR Code generator we get this:


Step 6: Reverse the steps.
Just complete steps 1 - 5 in reverse to decode the QR Code.


Here we have shown that transfers between mobile devices can be as simple as showing someone your screen and have completed a worked example of utilising the QR Code as a method of transfer. Of course additional performance improvements can be made to this process, however the idea is pretty much the same.

Simple changes can be made to allow much more information to be sent within the same example;
1) You could rename the javascript transfer object variables, full names are not required for transfer.

    "a": 18605,
    "b": "768",
    "c": null,
    "d": null,
    "e": "Detected",
    "f": "4",
    "g": null,
    "h": "Garden Island (north end)",
    "i": null,
    "j": null,
    "k": "2016-07-09T21:21:00",
    "l": null,
    "m": "bronze whaler",
    "n": "Fisheries advise",
    "o": null,
    "p": 115.6428,
    "q": -32.1441

2) You could remove the null variables from the object.

    "a": 18605,
    "b": "768",
    "e": "Detected",
    "f": "4",
    "h": "Garden Island (north end)",
    "k": "2016-07-09T21:21:00",
    "m": "bronze whaler",
    "n": "Fisheries advise",
    "p": 115.6428,
    "q": -32.1441

3) If you require more data than a single QR Code, simply allow multiple scans to build up your dataset.

Think outside the box

Yes, as developers we are usually limited by the technology we have at our disposal, but try to think outside the box and utilise unique and interesting parts of technology. This will ultimately make the use of your app an easy and enjoyable experience.

*Side note: Chirp SDK does a very similar type of data transferral to our QR Code method provided above but utilises subsonic audio.* [7]

[1] - http://www.rfidjournal.com/articles/view?16238
[2] - https://www.androidauthority.com/how-to-use-s-beam-android-168272/
[3] - https://blog.atlasrfidstore.com/nfc-ios-11
[4] - https://stackoverflow.com/questions/11065415/how-much-data-information-can-we-save-store-in-a-qr-code
[5] - http://api.fish.wa.gov.au/webapi/Introduction
[6] - http://www.txtwizard.net/compression
[7] - https://www.chirp.io/

Related Insights
Friday 3rd May 2019
Kentico Recognised as a Leading WCM Platform
Wednesday 24th April 2019
Most Hacked Websites Report Findings Released