Contact us
Insight

QR Codes: The Accessible, Reliable RFID Replacement

8 minutes December 1, 2023
Phil Allen Founder and Strategist
Follow
We explore the hurdles in existing inter-device communication technologies, leading to the innovative use of QR codes as a reliable alternative. 

Utilising Near Field Communication (NFC) technology is a challenge for widespread participation, particularly among Apple iPhone users [1]with numerous developers currently encountering this issue. Despite Apple's initiative to unlock their NFC communication chip for reading purposes, its functionality remains less versatile for inter-device communication when compared to the Samsung Galaxy suite of phones [2].

With the advent of iOS 11, Apple introduced Core NCF, enabling a reader mode specifically for encoded NFC Tags. However, it's crucial to note that Apple's NFC capabilities are restricted to reading only encoded NFC tags, and unencoded tags will not be acknowledged by iPhones [3].


Inter-device communication 


When we consider how devices talk to each other, a few technologies come to mind: Infrared, Bluetooth, and 4/5G. These have been around for a while and are widely used across mobile devices on a global level. However, our challenge lies in the inconsistency between mobile hardware and operating system specifications.

Infrared technology, once popular in the mid-2000s, is now quite outdated. It's not very effective, requiring both devices to have infrared transceivers and a direct, UV light-free line of sight. Plus, the data moves pretty slowly with this technology.

Then there's Bluetooth, which has improved a lot and is a great standard for device communication. Nowadays, Bluetooth is considered standard for speakers, headphones, and car connections. However, it has its disadvantages, such as the need to "pair" devices. Pairing two mobile devices to share pictures isn't as straightforward as connecting your phone to headphones.

Bluetooth stacks often don't work well together between different operating systems and sometimes even between devices. This is especially true when trying to communicate between Android and iOS devices, and even some Android devices with others.

Lastly, there's 4G, which we use for file transfer through services like Dropbox or Google Drive. An app called Bump, did a particularly good job with this. It allowed you to pick a file, tap devices together, and transfer the file. Bump used 4G for the transfer and GPS/Haptic controllers to identify the devices involved in the transfer.




How to transfer without wireless technologies? 


This raises the question: How can we communicate between devices without relying on wireless technology? While 4G is excellent for transfers, its reliability can be inconsistent, especially in rural areas within the Australian telecommunication network.

Here, we delve into the core of this article—QR Codes.

QR code for dapth.com


QR Codes offer a solution for transferring data from one device to another using the device's screen and the opposing device's camera, eliminating the need for Bluetooth, 4G, and Infrared, and more. 

Commonly used for product tracking, item identification, time tracking, document management, and general marketing, QR Codes come with various advantages over traditional barcodes. They can be read from different angles, include error correction, and have a higher storage capacity than standard barcodes. Additionally, QR Codes are not centralised or controlled by any authority, providing developers with the freedom to generate as many QR codes as needed.

Despite being less recognised, a 1-inch QR code can store up to 2953 bytes of uncompressed data, and with BZIP Compression, this capacity can be expanded to approximately 8kb of data [4].



Worked example 


Now, let's dive into the exciting part where we explore how to leverage QR Codes for transferring JSON objects between devices. 

Imagine our fictional app designed for fishermen to input information about shark sightings. The app can then seamlessly transfer this data to a fisheries officer even while they are out on their boats. This becomes particularly useful in offshore locations where 4G signals are distant, and Bluetooth may not be feasible due to potential device incompatibility and the challenges of pairing devices in the midst of rocking waves (acknowledging the fictitious nature of this example, but envisioning practical scenarios where such a system could be beneficial).

Step 1: Creating your first PhoneGap application

 Thanks to the wonders of the internet, there's already a tutorial on crafting your inaugural PhoneGap application available at 

http://docs.phonegap.com/getting-started/3-create-your-app/desktop/.


Step 2: Installing and configuring the QR Code plugin for PhoneGap 

Again, we lean on the expertise of those with more time on their hands and venture to GitHub. Here, we discover the PhoneGap plugin named BarcodeScanner at 

https://github.com/phonegap/phonegap-plugin-barcodescanner

This nifty plugin empowers you to generate and read QR codes seamlessly across all devices within a PhoneGap application.


Step 3: Converting to JSON 

Now that our app and library are set up, let's wade into the realm of code. Take, for instance, the following API result set retrieved from api.fish.wa.gov.au [5]. Our initial move is to transform the JavaScript object into JSON.

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();
JSON.stringify(j);

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,


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]:

H4sIAAAAAAAA/12RUUvDMBSF/0rJk8I2ktp1tc9FKYiTrQ59TJvLeiW9GWm66sT/bnR0rUJecu45H/ckn2wj+0w6mSuWiiTmyxlbl29QuR+BreKEzViGrZNUAUup03q8PxO6QcvJgZWVQ0M7qTvvZRk4zwHF/kx/uZHXCtPTkzXv2KD7GDAPppJTxr20CijIWy1JBVdkrKsDIHXtAVvc1w5p/9g1JdjjOXHGbODgnb4XFNhc1CEw6izkIp7z1ZzfFqFI/eF8Qt7iCXZT7mVwgAqhHbYsraETBH0tNVifX/cEdhjeYVuD9e5AqiO2wMaW/oUk6v/dX/xPiOUijsJkFF9ZOr8JFyKKxNc3O46oWbUBAAA=

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.


Improvements

In this section, we've illustrated that mobile device transfers can be as uncomplicated as displaying your screen. We've successfully demonstrated the utilisation of QR Codes as a transfer method. While further refinements for performance are conceivable, the fundamental concept remains consistent.

Small adjustments can significantly increase the amount of information transmitted within the same example:

1.    Consider renaming the variables of the JavaScript transfer object; comprehensive names aren't necessary for the 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 

Developers often face constraints imposed by the available technology. It’s important to explore unconventional and captivating aspects 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/

 Contact Us