Create a QRcode from ODK collect

What I would like ODK to do for me :grin:
It is to be able to create a QRcode / barecode from entries of the questionnaire after validation to print this Code directly in the field and to label the samples

Hi Dan,

  • Can you provide a few more details about your workflow?
  • What kind of survey are you completing?
  • What are the samples you need to label?
  • What is the future purpose of the QR code? That is, when the QR code is scanned later, what data is read out of it? Just a unique identifier code?
  • What is the hardware you plan to use for printing?

Hello danbjoseph,

I will try to be clear and precise ;-))
My work has been carried out for 40 years in West Africa as an engineer alongside researchers on tropical diseases, and I have always tried to find solutions to the problems (numerous and diverse) encountered during our missions in the field.

Currently I propose the ODK solution for the creation of digital forms for the capture on the ground especially for its facility of creation, even if the proposed model is not perfect (input interface not very ergonomic, retrieval of the input data not easy Aggegate / briefcase, export of data different between aggregate and briefcase, ...) but we see that the system is constantly improving and it is really encouraging.

To return to the problematic of the subject, our samples are of all kinds but must increasingly meet specific criteria traceability, sampling to analysis in the local and / or European laboratory. And the Nagoya protocol further strengthened this aspect.

For this we need to have a sample identification that would be easily usable, easily "transmissible", easily reusable without transcription errors => bare code or better QRCode.

The information recorded will be of various types but will contain:

  • a code of 3 to 5 digits resulting from the input on ODK,
  • the name of the investigator (or code),
  • date and hour ?),
  • a GPS point (or location information),
  • and other information allowing a perfect identification of the location of the sample,
  • information about the sample (variable number)

But there is not yet a finalized decision on the data to be used, it is a process that is being analyzed at the level of our unit and the institute.

The QRcode must be built on the device at the end of the entry after validation of the input (to allow to correct before creation) and it will be transmitted by bluetooth to a printer (zebra for example) allowing to print in real time the QRCode on sticky paper to label the samples.

All is far from defined but the creation of a QRCode or barCode from a form entered would already be an advance.
The other solution would be an application that could be launched by ODK, which could read the forms entered by ODK,
select the topics and create the barCode or QRCode.

Well, sorry, I did not make the short but I hope I was clear.



Thanks. All those details help clarify your needs.

I'm not very familiar with the QR code specifications but that seems like a fair amount of information to encode (unless you incorporate some sort of compression of the data first; something like how ODK handles the bulk configuration QR codes as described here).

Have you considered just using a unique ID encoded in the QR code and then using that to link the sample to a row in your aggregate database? You could pre-print QR codes with the unique IDs (something like 0001,0002,...) and then as part of the survey form attach and scan one. You'll be able to then later check the ID code on the sample and match it to a row in your database.

Does a mobile device also need to be able to scan a code and pull up the sample information (without internet connectivity)? Your use case seems like a type of inventory management and could maybe be better addressed using the ODK2.0 set of tools.


ODK collect is able to generate a QR code (here), it only remains to link topics Of a form to do the same. (Always easier to say)
I have aps still look at the ODK 2.0 tools (lack of time and I do not yet fully master ODK 1.x)


In order for this to work, you would need to encourage / enforce that the form limits the size of the total responses to fit in the size limits of QR codes. This means limitations on length of responses to text questions, no questions collecting photos/videos, etc.

1 Like

@Alex_Dorey wasn't it you who mentioned doing a QR code submission in a fork at some point?

@Couret_Daniel I think what you're describing is actually possible to do today. Have you looked at this resource? You should be able to generate a code that includes several values by using a calculate to combine them. Do note the estimated character maximum of 240 which would need to be verified for your printer and paper.

1 Like

Hello Alex and Hélène,

It is obvious that the length of the string (concatenation of information) is dependent on the bare code used.
For the printer (and especially the printer Zebra) I have not yet studied enough their possibilities, however the characteristics that they propose are standard and the mimiatation does not seem to me to be as restrictive.
It is possible that there are 2 categories of printers:

  1. the concatenated data is sent and the printer constructs the bar code before printing it,
  2. we build the bar code, we send an image of the barcode and the immovable imprime the image;

I would be much more interested in the 2nd solution knowing that ODK Collect is able to build a QR-code image.:grin:

And I attach a small reminder of the capacities of 2 bar code 2D that interest me (with example):

QR code
Numeric characters: maximum 7 089
Alphanumeric characters: maximum 4,296
Binary (8-bit): maximum 2,953 bytes
Kanji / Kana: maximum 1,817 characters

My QR Code :grin:

The code consists of 3 to 90 lines.
A row is composed of 1 to 30 columns of data.
If necessary, a mechanism called "Macro PDF417" allows more data to be distributed over several barcodes.
The error correction level is 0 to 8.


It has been done as a proof of concept in Enketo, but it did not make sense as a feature for the general public. If you are interested, the code is here.

Your intention is to print the QR code to a zebra printer? Can you print from a web view, such as a form in Enketo?

Hi Alex,
Odk Colect 1.8 is able to create a QRCode (here), it remains
For the QRCode to:

  • define in the form the headings that will be used for the QRCode,
  • use the same code / program to create a QRCode,
  • save the QRCode as an image,
  • print it by bluetooth on a zebra on the ground
    And do the same for: PDF417, and the bar code 1D :grin:
    (It's all simple lol)

And if it is the printer that creates the Barcode:
As Helene says, create the text that will be sent to the printmaker with the appearance "print"


Can you please start by trying the existing functionality using a calculate and the Zebra app to generate the code and reporting back on whether it can work for you (as I described here)?

thanks for the information.
I keep it in reserve if necessary.

Hi Hélène,
Unfortunately I do not have a zebra printer. (Within 2 or 3 months)
And I have not yet studied finely the differences between the models.


Maybe I missed it but I have not seen how one could "create a QRcode from ODK Collect". What I mean is maybe an xlsform or xml step-by-step.

I would like to use ODK Collect to generate a QR or Barcode that I could print using a Zebra printer.


Please try the documentation about the Zebra print widget and how to define a QR code for printing.

Thanks @LN,

I will try this out and see if it meets my usecase needs.