-
1Step 1
Installing Required Packages
We will need to have support for git, Python, and the Onion OLED Expansion Python Module.
opkg update opkg install git git-http python-light python-codecs pyOledExp
-
2Step 2
Downloading the Code
Now we need to download the Python code that actually does all the work:cd /root git clone https://github.com/OnionIoT/oledQrCodeGenerator.git
-
3Step 3
Running the Code
Now we have to make some QR codes! Navigate into the repo directory:<span class="hljs-built_in">cd</span> oledQrCodeGenerator
And run the program, the argument to the script is the text that will be encoded in the QR code pattern:
root<span class="hljs-variable">@Omega-18C2:</span>~/oledQrCodeGenerator# python main.py <span class="hljs-string">'Wow, my first QR Code'</span> > Encoding <span class="hljs-number">21</span> characters<br>> Generated QR <span class="hljs-attribute">Code</span>: <span class="hljs-number">31</span>x31 pixels > Doubled QR Code <span class="hljs-attribute">size</span>: <span class="hljs-number">62</span>x62 > Initializing display > Setting display mode to inverted > Writing buffer data to display
This will encode the data and display the resulting QR code on the OLED Expansion:
-
4Step 4
Using the code as a Python Module
You can use the oledQRCodeGenerator module in your own Python projects!Example:
import oledQrCodeGenerator oledQrCodeGenerator.dispQrCode('Hello!')
Note that your Python script will have to be in the same directory as oledQrCodeGenerator in order for it to work properly. -
5Step 5
Tutorial Complete!
You can now use a smartphone to read the QR code on the OLED:• On Android, we've successfully used the QR Code Reader App
• On iOS, we've had success with the QR Reader App
Happy hacking!
The code in the qrcode directory is from lincolnloop's python-qrcode:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.