The typical UPC-A barcode is visually represented by strips of bars and spaces, that encode a 12-digit number. A QR code (Quick Response Code) is a matrix barcode that can contain up to 4296 characters.
For Pi or Arduino projects QR codes could be used to document what the module is doing, or “if lost please call…”, or web links.
Create Your Own QR Codes
There are a number of different tools available to create your own QR codes. One of the simplest methods is to use Google Charts, and it is called by:
The important parameters are:
cht=qr – chart type = qr
chs=x – chart size, and
chl= – the data or URL to encode
An example of encoding “Hello World” in a 100×100 QR would be:
http://chart.apis.google.com/chart?chl=Hello+World&chs=100×100&cht=qr
A simple web form that can be used to create QR codes
<html>
<head>
<title>Create QR Codes</title>
</head>
<body>
<h1>Create QR Codes</h1>
<form action="http://chart.apis.google.com/chart" method="get">
Text to embed in QR Code</br>
<textarea name="chl" style="height:100px;width:300px;"></textarea>
</br>Image Size :</br>
<select name="chs">
<option value="100x100">100x100</option>
<option value="150x150">150x150</option>
<option value="200x200">200x200</option>
<option value="250x250">250x250</option>
<option value="300x300" selected>300x300</option>
<option value="350x350">350x350</option>
<option value="400x400">400x400</option>
<option value="500x500">500x500</option>
</select>
<input type="hidden" name="cht" value="qr"></br>
<p><input type="submit" value="Create QR Code"></p>
</form>
</body>
</html>
After the image is generated it can be printed, cut to size and then taped to your equipment. If you have a number of Arduino or Pi modules QR codes could be an easy way to determine what is loaded on each module.
Create an Android QR Reader App
MIT’s AppInventer is a great option for Android smart phones and tablets.
For our application we used the following components:
- 1 Button – to start QR scanning
- 1 Textbox – to show QR scan results
- 1 Button – to call a browser if the QR code is a Web link
- 1 BarcodeScanner – to turn on the camera and process the QR code
- 1 ActivityStarter – to launch the web browser
The logic starts by defining the camera to be used for the QR scanning, and setting the ActivityStarter.Action to be a browser (android.intent.action.VIEW).
The BarcodeScanner1.AfterScan block puts the decoded QR data into the textbox. If the QR code starts with “http” then the “Open Link” button is enabled.
Once our custom QR reader app is on our device we can start to customize it to our needs. The picture below shows the basic app reading a 100×100 QR code used on an Arduino project. Some future considerations that could be added to this simple app could things like: recording the geographic location of the device or is the data valid.
QR Codes and the Internet of Things (IoT)
For projects with a lot of sensors or devices QR codes can be helpful to identify and document what each device is used for. If the device is a source of data then a QR code could link to that specific devices data.
The picture below is an example of a solar powered weather device. The ESP8266 based Arduino module uses MQTT to send data back to a Pi node running Node-Red. The QR code on the side of the enclosure has a link to the Node-Red web page.