• Stars
    star
    642
  • Rank 69,626 (Top 2 %)
  • Language
    C++
  • License
    Other
  • Created over 7 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

QR code generation library in C, optimized for low-power devices, such as Arduino.

QRCode

A simple library for generating QR codes in C, optimized for processing and memory constrained systems.

Features:

  • Stack-based (no heap necessary; but you can use heap if you want)
  • Low-memory foot print (relatively)
  • Compile-time stripping of unecessary logic and constants
  • MIT License; do with this as you please

Installing

To install this library, download and save it to your Arduino libraries directory.

Rename the directory to QRCode (if downloaded from GitHub, the filename may be qrcode-master; library names may not contain the hyphen, so it must be renamed)

API

Generate a QR Code

// The structure to manage the QR code
QRCode qrcode;

// Allocate a chunk of memory to store the QR code
uint8_t qrcodeBytes[qrcode_getBufferSize()];

qrcode_initText(&qrcode, qrcodeBytes, 3, ECC_LOW, "HELLO WORLD");

Draw a QR Code

How a QR code is used will vary greatly from project to project. For example:

  • Display on an OLED screen (128x64 nicely supports 2 side-by-side version 3 QR codes)
  • Print as a bitmap on a thermal printer
  • Store as a BMP (or with a some extra work, possibly a PNG) on an SD card

The following example prints a QR code to the Serial Monitor (it likely will not be scannable, but is just for demonstration purposes).

for (uint8 y = 0; y < qrcode.size; y++) {
    for (uint8 x = 0; x < qrcode.size; x++) {
        if (qrcode_getModule(&qrcode, x, y) {
            Serial.print("**");
        } else {
            Serial.print("  ");
        }
    }
    Serial.print("\n");
}

What is Version, Error Correction and Mode?

A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read).

The version of a QR code is a number between 1 and 40 (inclusive), which indicates the size of the QR code. The width and height of a QR code are always equal (it is square) and are equal to 4 * version + 17.

The level of error correction is a number between 0 and 3 (inclusive), or can be one of the symbolic names ECC_LOW, ECC_MEDIUM, ECC_QUARTILE and ECC_HIGH. Higher levels of error correction sacrifice data capacity, but allow a larger portion of the QR code to be damaged or unreadable.

The mode of a QR code is determined by the data being encoded. Each mode is encoded internally using a compact representation, so lower modes can contain more data.

  • NUMERIC: numbers (0-9)
  • ALPHANUMERIC: uppercase letters (A-Z), numbers (0-9), the space ( ), dollar sign ($), percent sign (%), asterisk (*), plus (+), minus (-), decimal point (.), slash (/) and colon (:).
  • BYTE: any character

Data Capacities

Version Size Error Correction Mode
Numeric Alphanumeric Byte
1 21 x 21 LOW412517
MEDIUM342014
QUARTILE271611
HIGH17107
2 25 x 25 LOW774732
MEDIUM633826
QUARTILE482920
HIGH342014
3 29 x 29 LOW1277753
MEDIUM1016142
QUARTILE774732
HIGH583524
4 33 x 33 LOW18711478
MEDIUM1499062
QUARTILE1116746
HIGH825034
5 37 x 37 LOW255154106
MEDIUM20212284
QUARTILE1448760
HIGH1066444
6 41 x 41 LOW322195134
MEDIUM255154106
QUARTILE17810874
HIGH1398458
7 45 x 45 LOW370224154
MEDIUM293178122
QUARTILE20712586
HIGH1549364
8 49 x 49 LOW461279192
MEDIUM365221152
QUARTILE259157108
HIGH20212284
9 53 x 53 LOW552335230
MEDIUM432262180
QUARTILE312189130
HIGH23514398
10 57 x 57 LOW652395271
MEDIUM513311213
QUARTILE364221151
HIGH288174119
11 61 x 61 LOW772468321
MEDIUM604366251
QUARTILE427259177
HIGH331200137
12 65 x 65 LOW883535367
MEDIUM691419287
QUARTILE489296203
HIGH374227155
13 69 x 69 LOW1022619425
MEDIUM796483331
QUARTILE580352241
HIGH427259177
14 73 x 73 LOW1101667458
MEDIUM871528362
QUARTILE621376258
HIGH468283194
15 77 x 77 LOW1250758520
MEDIUM991600412
QUARTILE703426292
HIGH530321220
16 81 x 81 LOW1408854586
MEDIUM1082656450
QUARTILE775470322
HIGH602365250
17 85 x 85 LOW1548938644
MEDIUM1212734504
QUARTILE876531364
HIGH674408280
18 89 x 89 LOW17251046718
MEDIUM1346816560
QUARTILE948574394
HIGH746452310
19 93 x 93 LOW19031153792
MEDIUM1500909624
QUARTILE1063644442
HIGH813493338
20 97 x 97 LOW20611249858
MEDIUM1600970666
QUARTILE1159702482
HIGH919557382
21 101 x 101 LOW22321352929
MEDIUM17081035711
QUARTILE1224742509
HIGH969587403
22 105 x 105 LOW240914601003
MEDIUM18721134779
QUARTILE1358823565
HIGH1056640439
23 109 x 109 LOW262015881091
MEDIUM20591248857
QUARTILE1468890611
HIGH1108672461
24 113 x 113 LOW281217041171
MEDIUM21881326911
QUARTILE1588963661
HIGH1228744511
25 117 x 117 LOW305718531273
MEDIUM23951451997
QUARTILE17181041715
HIGH1286779535
26 121 x 121 LOW328319901367
MEDIUM254415421059
QUARTILE18041094751
HIGH1425864593
27 125 x 125 LOW351721321465
MEDIUM270116371125
QUARTILE19331172805
HIGH1501910625
28 129 x 129 LOW366922231528
MEDIUM285717321190
QUARTILE20851263868
HIGH1581958658
29 133 x 133 LOW390923691628
MEDIUM303518391264
QUARTILE21811322908
HIGH16771016698
30 137 x 137 LOW415825201732
MEDIUM328919941370
QUARTILE23581429982
HIGH17821080742
31 141 x 141 LOW441726771840
MEDIUM348621131452
QUARTILE247314991030
HIGH18971150790
32 145 x 145 LOW468628401952
MEDIUM369322381538
QUARTILE267016181112
HIGH20221226842
33 149 x 149 LOW496530092068
MEDIUM390923691628
QUARTILE280517001168
HIGH21571307898
34 153 x 153 LOW525331832188
MEDIUM413425061722
QUARTILE294917871228
HIGH23011394958
35 157 x 157 LOW552933512303
MEDIUM434326321809
QUARTILE308118671283
HIGH23611431983
36 161 x 161 LOW583635372431
MEDIUM458827801911
QUARTILE324419661351
HIGH252415301051
37 165 x 165 LOW615337292563
MEDIUM477528941989
QUARTILE341720711423
HIGH262515911093
38 169 x 169 LOW647939272699
MEDIUM503930542099
QUARTILE359921811499
HIGH273516581139
39 173 x 173 LOW674340872809
MEDIUM531332202213
QUARTILE379122981579
HIGH292717741219
40 177 x 177 LOW708942962953
MEDIUM559633912331
QUARTILE399324201663
HIGH305718521273

Special Thanks

A HUGE thank you to Project Nayuki for the QR code C++ library which was critical in development of this library.

License

MIT License.

More Repositories

1

aes-js

A pure JavaScript implementation of the AES block cipher and all common modes of operation for node.js or web browsers.
JavaScript
1,430
star
2

pyaes

Pure-Python implementation of AES block-cipher and common modes of operation.
Python
453
star
3

nightminer

Simple Python CryptoCurrency mining client
Python
197
star
4

scrypt-js

Pure JavaScript implementation of the scrypt password-based key derivation function.
JavaScript
140
star
5

GMEllipticCurveCrypto

Elliptic Curve Cryptography library for iOS (ECDSA and ECDH)
Objective-C
122
star
6

pycoind

Pure-Python full node and libraries for bitcoind-based crypto-currencies (eg. bitcoin, litecoin, etc)
Python
121
star
7

ethers-airdrop

A simple tool and library to deploy and manage a Merkle Air-Drop.
JavaScript
93
star
8

lurch

Lurch is an Ethereum VM para-virtualization (ish) written in EVM bytecode.
Assembly
83
star
9

pyscrypt

Pure-Python implementation of Scrypt PBKDF and scrypt file format library.
Python
81
star
10

ethers-meow

A simple command-line interface and library for CryptoKitties using ethers.js.
JavaScript
73
star
11

Takoyaki

ENS the fun and easy way; like a box of cereal, there is a toy at the bottom.
TypeScript
37
star
12

will-o-the-wisp

Intentionally self-destructive Ethereal on-chain-ish Wallet. (Proof-of-Concept bootstrap technique with CREATE2)
JavaScript
35
star
13

meeseeks-app

Safely load verified IPFS content on its own domain with browser Cross-Origin Policy protection.
HTML
28
star
14

multicall

A simple multicall contract and library wrapper to aggregate Ethereum calls.
TypeScript
22
star
15

flatworm

A very simple documentation generation tool.
JavaScript
18
star
16

gas-ticker

Oracle for tracking effective gas prices.
JavaScript
17
star
17

gremlins

A simple and easy-to-use language and compiler for querying blockchain data.
TypeScript
11
star
18

account-scanner

A simple example of a multi-call contract for token scanning.
JavaScript
11
star
19

BLECast

A custom protocol and library for iOS to send messages to Arduino over BLE advertising data.
C
10
star
20

sprinkles

NFTHack 2021 project: Sprinkles
C
8
star
21

GMClipper

An Objective-C wrapper for the Clipper polygon clipping and offsetting library.
C++
7
star
22

waxlit

The WaxLit experimental blogging libraries and front-end
HTML
6
star
23

distinguished-format-strings

Deprecated. This idea has been obsoleted in favour of described data (see link).
JavaScript
5
star
24

ethers-studio

Initial experimental project for Ethers Studio.
TypeScript
5
star
25

reticulate

Package manger for the ethers monorepo and ancillary packages.
TypeScript
4
star
26

coindjs

JavaScript implementation of Bitcoin (Namecoin, etc) full node and libraries for node.js.
JavaScript
4
star
27

vanity-contract

Miner for generating Vanity Contract Addresses.
C
3
star
28

hatch

Hatches ENS-controlled long-lived Wisp-like Proxies.
Solidity
3
star
29

ethdenver2024

ETHDenver 2024 Hackathon Project
1
star
30

promise-rationing

Promise-like interface to limit how many concurrent promises are executed.
JavaScript
1
star
31

sandbox

Random little things here and there, that I don't know where else to put.
JavaScript
1
star
32

USCC-2017

My entry for the Under-Handed Solidity Coding Competition 2017 (2nd place)
JavaScript
1
star