Hey friends, I have been thinking about this for a while, and I have finally been able to find some motivation and time to bring this new kind of letter to you. In this series (which I’m calling How it Works), I will be looking into some common products and tools that we use regularly and learning about how it works. This could be in its design, engineering, or strategic sense, and I will try to keep it concise with a lot of detail.
Just know this is not some educational content but more of what might satisfy your curiosity (or add to it) and provide a direction for you to learn more about the product or tool. This is the first of this series, and I am excited to share this with you!
How do QR Codes Work?
QR codes, as you all know, have become a tool of convenience, and we see them all around us. QR stands for Quick Response and is basically a 2-D barcode with patterns of black and white squares (that are called modules) storing encoded information.
How are these better than traditional barcodes? Well, QR codes have much more capacity, around 7000 numeric characters or 2900 binary bytes. These codes also use advanced error correction algorithms like the Reed-Solomon algorithm. This algorithm adds redundancy to the data modules so that there is no data loss if there is partial damage to the QR code.
To generate a QR code, a specific encoding scheme is decided to convert the data, like alphanumeric or binary. The data is typically formatted as a string of characters, which is then converted into a binary code using a specified encoding scheme, such as ASCII or Unicode.
The encoded data is divided into segments according to the different format specifications like data capacity and error correction level. The different segments or series of data are called codewords.
Then, the matrix of black and white modules is generated, using format information such as version number and alignment and timing patterns. Each module represents a binary value, with the black modules representing 1 and the white modules representing 0. The codewords are arranged into patterns, with each bit of each codeword corresponding to a specific module in the matrix.
Finally, masking is applied to the matrix to improve readability. It involves applying a specific XOR pattern to the matrix to ensure that the pattern is controlled. Without masking, the alignment and timing patterns could be random and can confuse the code scanners or readers.
After this pattern is applied, the resulting masked matrix is evaluated to determine if it meets specific criteria, like having a minimum number of modules in each row and column and the level of contrast between dark and light modules. Post masking, the QR code output is generated.
When reading a QR code, certain image processing algorithms like edge detection and binarization are used to locate the QR code and extract the modules. The masking process is reversed, and the Reed-Solomon error collection algorithm helps correct any errors in the data. Finally, the encoded data is extracted and decoded to process and use as intended.
The three big squares on the corners of the QR code help the readers determine the orientation of the QR code and enable quick reading. These are known as the finder patterns. The modules just outside the finder patterns inform the reader about the format of the data, like whether it is a Wi-Fi password or a URL.
Learn more on this
There’s a lot of developments on QR codes and more advanced tech. If you find this interesting, here are a few articles as starting points to learn more.
QR Codes: How Old Tech Is Driving New Innovation In A Touchless World
SnapTags - logos that are interactive over smartphone and text
Near Field Communication against QR Codes
Well, that’s all for how QR codes work. You can definitely go deeper into the technical aspects of the matrix generation, masking, encoding, and decoding processes. Hopefully, you learned something new and interesting about this very common tool we use almost every day. I sure did!
This is just something I am writing as I learn. So, if you have any feedback on how I can improve writing the How it Works series for you, please leave a comment.
✌️If you liked what you read, please leave a like and consider sharing!