The $4 Raspberry Pi Pico, and its $6 Wi-Fi enabled sibling the Raspberry Pi Pico W have proven to be an excellent foundation for great projects and this QR code display project from Predrag Mijatovic is inspired. The simple aim of the project is to display a QR code that enables a device to connect to Wi-Fi.
Mijatovic's project "qr_wifi" displays a QR code to enable guests to connect to a guest Wi-Fi network. The QR code stores the SSID, security (WEP/WPA) and password details for the network connection. All the user has to do is scan the code with their device's camera and their device will connect.
What interests us the most is the approach taken which sees a Raspberry Pi Pico accessory, specifically Waveshare's Pico OLED 1.3 inch (64 x 128 pixels) screen display the QR code. All of the code for the project is written in MicroPython and in the video we can see Mijatovic generate the QR code using qrencode, a useful terminal command to generate QR codes from data. The QR code is written to a text file as ASCII text.
The returned QR code is 50 columns wide and 25 rows tall, so Mijatovic cleverly uses sed and regular expressions to duplicate the rows to make everything square. This is essential as QR codes contain error checking, and an incorrectly sized code will prevent users connecting to Wi-Fi. A little more regular expression magic and the QR code is ready for the final MicroPython script.
Dropping the QR code into the MicroPython code (lines 160 and 161) of main.py will see the code run every time the Pico is powered up.
This awesome project is a credit to Mijatovic and it would be great to see it applied to other boards. For example both Pimoroni's Badger 2040 and Tufty 2040 would be excellent devices to reproduce this project.
For more details qr_wifi visit Mijatovic's GitHub repository.