Create my own QR code

Hi, I want to create my own QR code with the configuration in my platform (using qrtools in python) but I'm not sure which is the encryption in ODK collect, somebody can help me?

If I understand correctly, you would like to generate a configuration QR code from which multiple devices can be configured as described here. Is that right?

That QR code uses a json representation of the settings with a structure such as

  "general": {
    "protocol": "google_sheets",
    "constraint_behavior": "on_finalize"
  "admin": {
    "edit_saved": false

There is no encryption, the json is just compressed with zlib. You can read more about the implementation at and there's a ticket to document this more thoroughly at


Thanks, it works. Here the code in python:

user_data = json.dumps(user_data)
qr_data = user_data.encode('zlib_codec').encode('base64_codec')
myCode = QR(data=qr_data)

1 Like

Hi Allan, I realise this is an old thread, but I have been trying to generate QR codes in Python but ODK never reads them and says the image does not contain QR information (it does). How did you get yours to work? Example code below:

settings = {"general": {"protocol": "google_sheets","constraint_behavior": "on_finalize"},"admin": {"edit_saved": False}}
userSettings = json.dumps(settings)
qr_data = zlib.compress(userSettings)
myCode = qr.add_data(qr_data)
img = qr.make_image(fill_color="black", back_color="white")"test.png","PNG")

Any pointers would be really useful, thanks.


Hi @JoeRyding! Note that after you compress the JSON, you then have to base-64 encode it. My knowledge of Python is limited, but it looks like @Allan_Coto did that above.

Hope that helps!

1 Like