How do QR codes work

morning monkey
4 min readJul 17, 2023

--

“Quick Response” codes are everywhere but how do they work!

The first QR code

The origin of QR codes dates back to 1994 when they were created by a Japanese company called Denso Wave, which is a subsidiary of the Toyota Group. Denso Wave developed QR codes to address the limitations of traditional barcodes, which had limited data capacity and could only encode numeric and alphanumeric characters.

The primary goal behind QR code development was to create a code that could store more data and be decoded more efficiently. The name “QR code” stands for “Quick Response code”, emphasising the code’s ability to be quickly decoded by scanners and other devices.

The development of QR codes was driven by the need for faster and more accurate data handling in various industries, including manufacturing, logistics, and retail. Denso Wave aimed to create a code that could store more information, handle a broader range of data types, and be scanned quickly from any angle. QR codes were initially used to track vehicle parts during the manufacturing process, but their usage expanded rapidly as their benefits became apparent.

Image generated by Stable Diffusion

How does a QR code work

A QR code is a type of two-dimensional barcode that stores information in a machine-readable format. QR codes are commonly used for various purposes, such as encoding URLs, contact information, product details, or any other type of data that can be represented in alphanumeric characters.

When you create a QR code, you input the data you want to encode. This could be a website URL, a text message, a phone number, an email address, or any other information you want to share.

Once the data is entered, the QR code generator converts it into a pattern of black and white squares (modules). These squares are arranged in a square grid, and the arrangement and size of the squares form the code’s unique pattern.

QR codes typically include built-in error correction capabilities. This means that even if the code is partially damaged or obscured, it can still be successfully read and decoded. The error correction allows QR codes to remain functional even if they are printed on materials that might be subject to wear or damage.

How does a built-in error correction work

Before the error correction process begins, the data to be encoded in the QR code is divided into smaller blocks or “codewords.” Each codeword contains a fixed number of data bits, and it is from these codewords that the QR code’s pattern of black and white squares or “modules” is generated.

The Reed-Solomon algorithm calculates a set of error correction codewords based on the original data codewords. These error correction codewords contain redundant information and are derived from mathematical calculations involving the original data. The error correction codewords are interleaved or mixed with the original data codewords. This process ensures that the redundant information is spread throughout the QR code, rather than being grouped together.

QR codes offer different error correction levels, typically denoted by alphanumeric characters (L, M, Q, or H). Each level specifies the number of error correction codewords included in the QR code. Higher error correction levels include more redundancy, making the QR code more resistant to errors but also increasing its size.

If the QR code has been damaged or partially obscured, the scanner uses the error correction codewords to detect and correct errors in the data. The redundancy in the error correction codewords allows the scanner to reconstruct the original data accurately, even in the presence of errors.

Decoding the QR code

To read the information stored in a QR code, you need a QR code scanner or reader. The QR code scanner captures an image of the QR code. The scanning software then processes the image to identify the pattern of black and white squares.

Once the pattern is recognized, the scanning software decodes the data stored in the QR code. This could be a URL that opens a website, a text message, contact information that can be saved to your address book, or any other information the QR code was designed to represent.

What about a barcode

QR codes can store significantly more data than traditional barcodes. QR codes are two-dimensional codes, while barcodes are one-dimensional. The 2D structure of QR codes allows them to store more information, such as URLs, contact information, or even small documents, whereas barcodes are typically limited to a string of numbers and/or letters.

QR codes use a unique pattern of black and white squares (modules) arranged in a square grid, while barcodes use a series of parallel lines and spaces. QR codes also incorporate positioning squares in the corners to help scanners identify the code’s orientation.

QR codes can be scanned from any direction, which means the QR code does not need to be aligned perfectly with the scanner. Barcodes, on the other hand, must be scanned from left to right to read the data accurately.

As mentioned above, QR codes have built-in error correction capabilities, allowing them to be read even if a part of the code is damaged or obscured. Barcodes typically do not have built-in error correction, making them more susceptible to reading errors if they are damaged or poorly printed.

QR codes can be read by specialised QR code scanners, smartphone cameras, or other imaging devices. Barcodes, however, require specific barcode scanners that can interpret the 1D barcode pattern.

--

--

morning monkey

Fascinated by 🌍 the world we live in 🌍. From tech to finance to economics the list goes on - here’s my path towards better understanding 💃🏻