I am trying to use this library to print QR codes using Arduino. There is a limit on the number of characters allowed in the string to be printed.

printQR("This is the string to be QR encoded !!! Tralalala. Some other random characters !!!");

When I scan the generated QR code, the string seems to be truncated. Did anyone run into this before? Or is there any way to get around this issue by raising the number of characters allowed in the string?

Thank you.

  • What is the limit, exactly? 47? – Nick Gammon Jul 19 '15 at 6:08

The code in the library truncates to 47 characters for some reason:

void printQR(String message) {


  // create QR code
  message.toCharArray((char *)strinbuf,47);

The buffer is actually 116 bytes, oddly.

unsigned char strinbuf[116];

It's a little unclear why the limit of 47, or 116, was chosen.

You could try changing that line in qrprint.cpp to increase the number from 47 to at least 115.


After reading some of the comments, I doubt that will help. The QR code looks like it is generated into an internal array, which would have to have some size limits due to the amount of RAM available. The current array size is:

unsigned char qrframe[600];

That is already 1/3 of the available memory on a Uno.

  • Does the library actually support version 10 or larger QR codes though? – Ignacio Vazquez-Abrams Jul 19 '15 at 5:41
  • Also, the 116 limit is for pure numeric codes (115/3*8=48). – Ignacio Vazquez-Abrams Jul 19 '15 at 5:44
  • 1
    I think I've identified why the string is truncated. The reason (for 47) is a bit more obscure. I couldn't find any documentation about which version they library produces, and therefore whether that is in fact the upper limit. See Information about QR codes. Version 2, ECC level L, alphanumeric, has a limit of 47 characters. – Nick Gammon Jul 19 '15 at 6:14
  • This is also a reason why I dislike "magic numbers" in the middle of code. Why 47? Why not 46 or 48? A comment on that line explaining why the number 47 is there would be very useful. – Nick Gammon Jul 19 '15 at 9:02
  • Thank you @NickGammon for the clarification. The thing is that I am using this library in order to convert larger strings into printed QR codes. I tried increasing the numbers in the source code but that generated odd QR figures that are neither scannable nor compliant to QR standards. I would like to know if anyone ran into this before and what is the correct way to generate version 7 QR codes or higher. If it could be of help the library is build on top of github.com/tz1/qrduino . Thank you – georgehelou Jul 20 '15 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.