# Reading QR Codes with the Tiny Code Reader

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/124/030/medium800/sensors_PXL_20230825_210358377.MP.jpg?1692998299 Trinkey wired to a Tiny Code Reader, plugged into a laptop)

The [Tiny Code Reader](https://www.adafruit.com/product/5744) is a small hardware module that's intended to make it easy to scan QR codes. It has an image sensor and a microcontroller with pre-trained software and outputs information from any identified codes over I2C.

There's [a detailed developer manual](https://usfl.ink/tcr_dev) available, but this guide has sample code that shows you specifically how to get the module up and running using CircuitPython on a [Trinkey](https://www.adafruit.com/product/5056), and output any recognized code as text to the attached computer as if the module was a keyboard. For example, you can show it a QR code containing the text "Hello World!" and that text will be automatically typed in to your laptop.

Both the TCR and Trinkey have Stemma QT/Qwiic ports, so they can be connected with a standard cable and no soldering is required to complete this project.

## Parts
### Adafruit Trinkey QT2040 - RP2040 USB Key with Stemma QT

[Adafruit Trinkey QT2040 - RP2040 USB Key with Stemma QT](https://www.adafruit.com/product/5056)
It's half USB Key, half Adafruit QT Py, and a lotta&nbsp;RP2040_..._it's&nbsp; **Trinkey QT2040** , the circuit board with an RP2040 heart and Stemma QT legs. Folks are loving the [QT Py 2040](https://www.adafruit.com/product/4900) we made, but maybe you...

In Stock
[Buy Now](https://www.adafruit.com/product/5056)
[Related Guides to the Product](https://learn.adafruit.com/products/5056/guides)
![Video of Trinkey RP2040 plugged into a laptop. An OLED display is connected and shows a graphic keyboard cat animation.](https://cdn-shop.adafruit.com/product-videos/640x480/5056-04.jpg)

### Tiny Code Reader from Useful Sensors

[Tiny Code Reader from Useful Sensors](https://www.adafruit.com/product/5744)
The&nbsp;[Tiny Code Reader](https://usfl.ink/tcr)&nbsp;from&nbsp;[Useful Sensors](https://usefulsensors.com/)&nbsp;is a small, low-cost hardware module that reads QR codes. It's designed to be a simple way to provision a...

In Stock
[Buy Now](https://www.adafruit.com/product/5744)
[Related Guides to the Product](https://learn.adafruit.com/products/5744/guides)
![Angled shot of small green QR code reader sensor breakout.](https://cdn-shop.adafruit.com/640x480/5744-05.jpg)

### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)
![Angled of of JST SH 4-Pin Cable.](https://cdn-shop.adafruit.com/640x480/4399-00.jpg)

# Reading QR Codes with the Tiny Code Reader

## Setup

Are you new to using CircuitPython? No worries,&nbsp;[there is a full getting started guide for the Trinkey board here](https://learn.adafruit.com/adafruit-trinkey-qt2040/circuitpython "Welcome to CircuitPython"). Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython.&nbsp;[You can learn about Mu and installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor "Mu tutorial").

The Trinkey comes with a Stemma QT connector, so the only wiring you'll need to do is plugging the recommended cable (or equivalent) into the reader and the board port. The connectors will only attach in the correct orientation, which is with the slightly exposed contact pads closest to the board.

# Reading QR Codes with the Tiny Code Reader

## Code

Once you've finished setting up your Trinkey with CircuitPython and have it plugged into your computer and the Tiny Code Reader, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **Download Project Bundle** button in the window below. It will download to your computer as a zipped bundle.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Reading_QR_Codes/code.py

## Upload the Code and Libraries to the Trinkey

After downloading the Project Bundle, plug your Trinkey into the computer's USB port with a known good USB data+power cable. If your computer only has USB C ports, you will need a [USB A to C adapter](https://www.adafruit.com/product/4175). You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called **CIRCUITPY**. Unzip the folder, and copy the following items from the CircuitPython 8.x folder to the Trinkey's **CIRCUITPY** drive.

- **lib** folder
- **code.py**

Your Trinkey **CIRCUITPY** drive should look like this after copying the **lib** folder and the **code.py** file.

![](https://cdn-learn.adafruit.com/assets/assets/000/124/070/medium800/sensors_Screenshot_2023-08-27_at_2.51.50_PM.png?1693173154)

# Reading QR Codes with the Tiny Code Reader

## Use

Your Trinkey should now be set up to type the contents of QR codes into your computer! To test it, go to a site like [qr-code-generator.com](https://www.qr-code-generator.com/) and type in some text. A QR code should be displayed, and if you create a blank document in a text editor and give it keyboard focus, when you show the QR code to the Tiny Code Reader you should see the contents get typed in.

https://youtu.be/edTVumZBDP4

## Going Further

The great thing about QR codes is that you can use them to share any short text strings without needing a special app, since they're just images that can be printed out, emailed, or texted. This means that if you have information you want to input into your project, but don't want to include a keyboard in your system, a TCR can be a helpful alternative. The [full developer guide](https://usfl.ink/tcr_dev) has [more examples](https://github.com/usefulsensors/tiny_code_reader_docs/blob/main/README.md#useful-sensors-examples), but here are some suggested use cases.

### WiFi Provisioning

On Android, [you can just go to WiFi settings, choose share](https://www.theverge.com/23561652/android-ios-wifi-password-share-how-to), and it will display a QR code containing the name and password of the network you're currently connected to.&nbsp;[It's also possible to do the same thing on iOS](https://osxdaily.com/2021/07/08/how-share-wi-fi-password-qr-code-shortcuts/) but it's a bit more fiddly. If you have a project that you want to connect to WiFi without reflashing or using a keyboard, you can read these QR codes to [extract the network name and password](https://github.com/usefulsensors/tiny_code_reader_wifi_micropython/blob/main/main.py#L52). This can be extended to may different kinds of configuration, as long as the information fits in a short text string.

### Access Control

Instead of using a keypad with a PIN code to lock a box or door, why not use a password saved in a QR code? You can have a much longer secret since users don't have to remember it, and even multiple different passwords with different access levels. For example, you could program a door lock with a code that only works on a particular day between 9am and 5pm if you wanted to give a contractor temporary access.

### E-ink Badges and Displays

E-ink displays are great because they don't use any power to maintain a picture. This makes them ideal for things like conference badges, price labels, or meeting room names, since the contents don't need to change frequently and so a device can run for months or years on a small battery. It's not always easy to update them though, since network protocols like Bluetooth or WiFi require extra hardware and fiddly setup to connect, and a keyboard won't fit the form factor.

Adding a Tiny Code Reader that's triggered on a button press makes it easy to update displays with new information, since the process just involves creating a QR code with the text you want and pressing a button to scan it. [This Badger RP2040 project](https://github.com/usefulsensors/tiny_code_reader_badger) shows one way of doing that. Even better, e-ink displays are great at displaying QR codes too, so it's even possible to share information between devices by scanning displays, for example to share contact information from a conference badge.


## Featured Products

### Adafruit Trinkey QT2040 - RP2040 USB Key with Stemma QT

[Adafruit Trinkey QT2040 - RP2040 USB Key with Stemma QT](https://www.adafruit.com/product/5056)
It's half USB Key, half Adafruit QT Py, and a lotta&nbsp;RP2040_..._it's&nbsp; **Trinkey QT2040** , the circuit board with an RP2040 heart and Stemma QT legs. Folks are loving the [QT Py 2040](https://www.adafruit.com/product/4900) we made, but maybe you...

In Stock
[Buy Now](https://www.adafruit.com/product/5056)
[Related Guides to the Product](https://learn.adafruit.com/products/5056/guides)
### Tiny Code Reader from Useful Sensors

[Tiny Code Reader from Useful Sensors](https://www.adafruit.com/product/5744)
The&nbsp;[Tiny Code Reader](https://usfl.ink/tcr)&nbsp;from&nbsp;[Useful Sensors](https://usefulsensors.com/)&nbsp;is a small, low-cost hardware module that reads QR codes. It's designed to be a simple way to provision a...

In Stock
[Buy Now](https://www.adafruit.com/product/5744)
[Related Guides to the Product](https://learn.adafruit.com/products/5744/guides)
### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)

## Related Guides

- [Adafruit Trinkey QT2040](https://learn.adafruit.com/adafruit-trinkey-qt2040.md)
- [Trinkey True Random Number Generator](https://learn.adafruit.com/trinkey-qt2040-true-random-number-generator.md)
- [DIY Trinkey No-Soldering USB Air Quality Monitor](https://learn.adafruit.com/diy-trinkey-no-solder-air-quality-monitor.md)
- [Program RP2040 in Arduino](https://learn.adafruit.com/rp2040-arduino-with-the-earlephilhower-core.md)
- [Customizing USB Devices in CircuitPython](https://learn.adafruit.com/customizing-usb-devices-in-circuitpython.md)
- [CircuitPython Day 2020 Countdown Clock](https://learn.adafruit.com/circuitpython-day-2020-countdown-clock.md)
- [Circuit Playground Express Serial Communications](https://learn.adafruit.com/circuit-playground-express-serial-communications.md)
- [Adafruit bq25185 USB / DC / Solar Charger with 5V Boost Board](https://learn.adafruit.com/adafruit-bq25185-usb-dc-solar-charger-with-5v-boost-board.md)
- [Scroll an SMS Text Message on your RGB Matrix](https://learn.adafruit.com/scroll-an-sms-text-message-on-your-rgb-matrix.md)
- [No-Code IoT Door Alarm with WipperSnapper](https://learn.adafruit.com/no-code-iot-door-alarm-with-wippersnapper.md)
- [NeXT Computer Keyboard to USB HID with CircuitPython](https://learn.adafruit.com/next-computer-keyboard-to-usb-hid-with-circuitpython.md)
- [HalloWing Magic 9 Ball](https://learn.adafruit.com/hallowing-magic-9-ball.md)
- [3D Printed Wearable Video Goggles](https://learn.adafruit.com/3d-printed-wearable-video-goggles.md)
- [I2C Addresses and Troublesome Chips](https://learn.adafruit.com/i2c-addresses.md)
- [CircuitScheme - Lisp on CircuitPython](https://learn.adafruit.com/scheme-in-circuitpython.md)
