Select Page

#### Written by Deirdre Westenbrink

You can see them almost everywhere nowadays: QR codes. They can be used for all kinds of things: showing you the menu in a restaurant, getting wifi and even paying for something via a ‘Tikkie’. The first time I saw such a QR code, I wondered immediately how it works, as you scan the QR code and immediately a website pops up. Hence, in this article I will tell you what kind of data is hidden in a QR code and how this can be recognized.

### What is a QR code?

So, what actually is a QR code? It is a type of barcode and by scanning it, you can access the information encoded in it. In standard barcodes, information is encoded in the width and distance of vertical lines. However, in QR codes, information is encoded in the arrangement of squares, where each square represents either a 1 or a 0. The type of matrix barcode was invented in 1994 by the Japanese automotive company Denso Wave. The idea behind a QR code is that it is an easy way to store information and that it creates an image that can be scanned by any modern smartphone. Then, it will most often redirect the smartphone to a website. However, QR codes can redirect to other media too (e.g. videos or images).

### Different kinds of QR codes

#### Size

First, we have that nowadays there are forty versions of QR codes. The versions are based on the width and height of the data modules, which are the little black and white squares that make up the QR codes. Version 1 is 21 x 21 and version 40 is already 177 x 177. Here, each version has a higher information capacity than the previous version.

#### Error correction levels

Not only data, but error correction is placed in a QR code. The QR code error correction means that a QR code has the ability to restore data to itself when it is damaged. It is a mathematical formula that is part of the QR code creation process and it converts the QR code into a polynomial that can be accessed if the code is damaged. There exist four levels of QR error code correction: level L, level M, level Q and level H, which are respectively able to backup 7%, 15%, 25% and 30% of the QR code’s data. However, not all QR codes have error correction level H, since if the correction level is lower, there is more space left for size and data.

#### Data type

There are four types of data that a QR code can store: numeric characters, alphanumeric characters, binary characters and kanji characters. The maximum storages of these are respectively, assuming a version 40 with error correction level L (or 40-L), 7.089, 4.296, 2.953 and 1.817. In practice this means that a QR code can include numbers, letters, punctuation and symbols.

### Data placement in a QR code

The data in QR codes is stored in a way that certain data is always at the same place. In the picture below, we see a QR code of version 4 (a 33×33 matrix). At first we have the finder patterns. These are three position markers that let your phone know it is scanning a qr code. Around the qr code is a ‘quiet zone’. This is needed in order to let your scanner be aware of where the edges of the QR code are. Then, the timing patterns tell the scanner where the columns and rows of black and white dots are placed. After that, the format information tells the scanner what type of information will be encoded (e.g. a website url, sms message etc.). Then the alignment pattern acts as an alignment marker. In some larger QR codes, more of these scanners can be found to ensure a more accurate alignment. Then, we are left with the message and error correction data.

So, what does our QR code actually say? This is found in the message and error correction data, as mentioned in the previous section. We begin at the bottom right and finds a mode indicator over there. This tells us what data type the rest of the encoded data is. Then, we find the character count indicator, which shows us how many characters the total encoded data is. We then continue by following the zig-zag path along the standard data modules, where we retrieve all the encoded information until we reach the stop indicator. Then, we follow our path to the error correction data modules.

To answer this question: probably not. However, now you do know more about how QR codes work and what Mathematics lie behind QR codes. So, next time you scan a QR code with your phone, you do not have to wonder how that actually works anymore!

Sources:

https://www.sproutqr.com/blog/how-do-qr-codes-work

https://atcm.mathandtech.org/EP2021/invited/21891.pdf

https://www.fastprint.co.uk/blog/quick-response-codes-what-are-they-and-how-do-they-work.html