Skip to content

Instantly share code, notes, and snippets.

@GammaGames
Last active February 11, 2023 20:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GammaGames/7736c7741879e32b5ad2c8b587216445 to your computer and use it in GitHub Desktop.
Save GammaGames/7736c7741879e32b5ad2c8b587216445 to your computer and use it in GitHub Desktop.
Generate wifi qr code in python3
import pyqrcode, sys, base64
if len(sys.argv) < 2:
print("Usage: python3 wifi.py [network] [password]")
quit()
network = sys.argv[1]
if len(sys.argv) > 2:
protocol = "WPA/WPA2"
pwd = sys.argv[2]
else:
protocol = "nopass"
pwd = ""
qr = pyqrcode.create(f"WIFI:S:{network};T:{protocol};P:{pwd};;")
png = qr.png(f"{network}.png", scale=5)
@GammaGames
Copy link
Author

Before running you need a few dependencies, run this to get them:

pip3 install pyqrcode
pip3 install pypng

@MrNerus
Copy link

MrNerus commented May 24, 2021

Greetings sir!
How do i find the code like "WIFI" as type or ":S", ":T", ":P" or other codes. What are other examples with meanings?

@GammaGames
Copy link
Author

I'm not sure where to find more formats, you can probably find the spec somewhere, but Wikipedia has the format for the wifi network string.

@Ryan-M-Smith
Copy link

Greetings sir! How do i find the code like "WIFI" as type or ":S", ":T", ":P" or other codes. What are other examples with meanings?

I stumbled upon this gist while googling the same thing. I found this wiki article on zxing/zxing. I tested some of the formats in the document in QR codes and they work as expected.

I know this is a little late, but I hope this can be helpful to people finding this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment