Search code examples
pythonpython-imaging-librarywifiqr-code

How can I generate a wifi QR code with pillow and qrcode library in Python?


I think there's a way to generate a wifi qr with pillow and qrcode library in Python, but I couldn't figure out how.


Solution

  • Yes there is. QR codes are just images that are easy for a computer to decode via taking a picture into something useful.

    QR codes are just text/strings encoded into an image.

    Python has a library called qrcode.

    Mobile phone support a specific format of text that tells it to try and connect to a wifi network. This wiki shows an example of what that connection string would look like.

    So here is the steps.

    1. Create a wifi connection string that mobile phones support.
    2. Pass that string into qrcode to generate a PIL image.
    3. Do what you want with that PIL image.