# BLE Cat Thermal Printer with MEMENTO

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/127/967/medium800/hacks_edited_P1440372.jpg?1708720475)

Picture it: Toys "R" Us, 1998. Sonic has yet to run on a Nintendo system and there is only one PlayStation. Your eye catches the new [Game Boy Printer](https://en.wikipedia.org/wiki/Game_Boy_Printer) behind a security cage and you think about how cool it would be to print out your Pokémon stats to show off to your friends at recess.

Almost 30 years later and everything old is new again. You can use the MEMENTO camera board with an internet famous [BLE cat thermal printer](https://hackspace.raspberrypi.com/articles/bluetooth-cat-thermal-printer-review)&nbsp;to instantly print photos with the [classic "Gameboy" grayscale filter](https://en.wikipedia.org/wiki/Game_Boy_Camera).

https://youtube.com/shorts/n3cJVcf8VYE

The ESP32-S3 on the MEMENTO connects to the cat printer over BLE with the [CatGFX library](https://github.com/TheNitek/CatGFX). The MEMENTO runs a "Gameboy" filter on the incoming frames from the onboard camera module. When you press the shutter/boot button, the image is sent to the cat printer for printing.

![hacks_printingOnMemento.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/965/medium640thumb/hacks_printingOnMemento.jpg?1708720385)

You can choose to print your images with a Polaroid-style frame around the picture. You can press the select button to enable or disable the frame.

![hacks_frameYn.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/962/medium640thumb/hacks_frameYn.jpg?1708720356)

On startup, the MEMENTO display will let you know if there are any initial connection problems with the printer. You can also press the down button once the code is running to disconnect and reconnect to the printer.

![hacks_reset.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/988/medium640thumb/hacks_reset.jpg?1708721740)

## Cat Printer

There are many versions of the BLE cat printer out there in the world. This project is aimed at the MX06 variant of the printer, which at the time of writing seems to be the most common type.

### Part: BLE Cat Thermal Printer
quantity: 1
BLE Cat Thermal Printer - MX06 variant
[BLE Cat Thermal Printer](https://www.amazon.com/dp/B0BP6GMVMJ?)

## Parts
### MEMENTO - Python Programmable DIY Camera - Bare Board

[MEMENTO - Python Programmable DIY Camera - Bare Board](https://www.adafruit.com/product/5420)
Make memories, or just a cool camera-based project,&nbsp;with **Adafruit's MEMENTO Camera Board**. It's a development board with everything you need to create programmable camera and vision projects: with a camera module, TFT preview screen, buttons, SD card slot and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5420)
[Related Guides to the Product](https://learn.adafruit.com/products/5420/guides)
![Video of a DIY camera on a lazy susan.](https://cdn-shop.adafruit.com/product-videos/640x480/5420-05.jpg)

### Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh

[Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh](https://www.adafruit.com/product/4236)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 420mAh for a total of about 1.55 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4236)
[Related Guides to the Product](https://learn.adafruit.com/products/4236/guides)
![Lithium Ion Polymer Battery 3.7v 420mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/4236-04.jpg)

### Pink and Purple Woven USB A to USB C Cable - 1 meter long

[Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers, and more.&nbsp;&nbsp;[If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5153)
[Related Guides to the Product](https://learn.adafruit.com/products/5153/guides)
![Angled shot of coiled pink and purple USB cable with USB A and USB C connectors.](https://cdn-shop.adafruit.com/640x480/5153-02.jpg)

# BLE Cat Thermal Printer with MEMENTO

## Software

![](https://cdn-learn.adafruit.com/assets/assets/000/127/968/medium800/hacks_edited_P1440405.jpg?1708720509)

The Arduino code for the MEMENTO and cat printer is available as a pre-compiled .UF2 file that you can drag and drop onto your MEMENTO board.

[Memento_Cat_Printer.uf2](https://cdn-learn.adafruit.com/assets/assets/000/127/868/original/Memento_Cat_Printer.uf2?1708465879)
## Load the UF2
 **Click the link above to download the UF2 file.**

Save it wherever is convenient for you.

![hacks_downloadUf2.png](https://cdn-learn.adafruit.com/assets/assets/000/127/867/medium640/hacks_downloadUf2.png?1708481676)

![](https://cdn-learn.adafruit.com/assets/assets/000/127/869/medium800/hacks_resetRed.jpg?1708483101)

Plug your board into your computer, using a known-good data-sync USB cable, directly, or via an adapter if needed.

Double-click the **reset** button (highlighted in red above), wait about a half a second and then tap reset again.

You will see a new disk drive appear called&nbsp; **CAMERABOOT**.

&nbsp;

Drag the **UF2** file to&nbsp; **CAMERABOOT**.

![hacks_camBoot.png](https://cdn-learn.adafruit.com/assets/assets/000/127/870/medium640/hacks_camBoot.png?1708483157)

![](https://cdn-learn.adafruit.com/assets/assets/000/127/993/medium800thumb/hacks_connect.jpg?1708722183)

The code will begin running by initializing the MEMENTO and then connecting to the cat printer. After a successful connection, you'll see the camera frame show on the display with the gameboy filter.

## Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/MEMENTO/Memento_Cat_Printer/Memento_Cat_Printer.ino

## How the Code Works
The&nbsp;`gameboy()` function is pulled from the [bitmaptools CircuitPython module](https://github.com/adafruit/circuitpython/blob/main/shared-module/bitmaptools/ __init__.c#L774C1-L862C2). It uses the [Atkinson dithering](https://en.wikipedia.org/wiki/Atkinson_dithering) algorithm to create the iconic grayscale pixelated image. The function takes a `bool` argument called `createForPrinter`. If it is `true`, then a `bitmap` is prepared for printing and is sent to the printer. It also checks if a frame is included for printing. Otherwise, only the `RGBBitmap` is prepared for the display.

In the `setup`, the PyCamera library is initialized, followed by the CatGFX printer library. Once a connection is established over BLE with the printer, the `loop` begins. In the `loop`, the filtered camera preview is blitted to the screen. If you press the shutter button, then the filtered image is printed. You can press the select button on the MEMENTO to toggle the frame on or off for printing. You can also press the down button to reconnect to the printer if you lose connection.

# BLE Cat Thermal Printer with MEMENTO

## Connecting to the Cat Thermal Printer

![](https://cdn-learn.adafruit.com/assets/assets/000/127/981/medium800thumb/hacks_printSaucer.jpg?1708721185)

First, turn on the cat printer. You'll see the blue LED blinking on the printer. Then, turn on the MEMENTO. You'll see "CONNECTING.." on the screen. After it connects, you'll see the Gameboy filter previewing the camera image. The blue LED will be solidly lit on the printer.

![hacks_connect.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/984/medium640thumb/hacks_connect.jpg?1708721346)

If the MEMENTO can't establish a connection with the printer, it will reset and try again. If you notice that the MEMENTO has reset a few times without connecting, try power cycling the cat printer.

![hacks_reset.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/987/medium640thumb/hacks_reset.jpg?1708721722)

# BLE Cat Thermal Printer with MEMENTO

## The Journey to Printing

![](https://cdn-learn.adafruit.com/assets/assets/000/127/980/medium800thumb/hacks_printerCloseUp.jpg?1708721107)

I wanted to document some of the troubleshooting steps that I took to get the cat printer printing images from MEMENTO. It would have been lovely if everything had "just worked" but it took some sleuthing and experimentation.

First off I compiled the example in the CatGFX library for MEMENTO and tested to see if it could connect to the printer and successfully print at all. The example prints text and some circles.&nbsp;

![hacks_P1440373.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/970/medium640/hacks_P1440373.jpg?1708720555)

After that success I brought in the PyCamera library and added in some button presses to initiate printing. This worked for printing text and shapes. Next was trying to get images printing.

![hacks_P1440375.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/971/medium640/hacks_P1440375.jpg?1708720568)

Since thermal printers print in black and white, I initially tried converting the default framebuffer to a grayscale bitmap and sending that to the printer on a button press. This resulted in printing glitchy lines.

![hacks_P1440379.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/972/medium640/hacks_P1440379.jpg?1708720585)

What I needed to do was capture a grayscale image from the start. Luckily Jeff Epler had implemented a "gboy" Gameboy-style filter in [bitmaptools in CircuitPython](https://github.com/adafruit/circuitpython/blob/main/shared-module/bitmaptools/ __init__.c#L774C1-L862C2). Since it was written in C, it was very straightforward to bring into Arduino. I added a simple [`refresh()`](https://github.com/adafruit/Adafruit_PyCamera/blob/main/Adafruit_PyCamera.cpp#L696) function to the PyCamera library to allow the screen to update with the bitmap generated with the filter.

![hacks_IMG_1071.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/974/medium640/hacks_IMG_1071.jpg?1708720606)

Now the moment of truth: would the bitmap print? And on the first try it was a success! I was so excited. But then, it was terrible. It would stop printing halfway thru an image. The printer would connect properly, it would receive the buffer to print, it would start printing but would stop before completing the task. The MEMENTO would think it was still printing and essentially be frozen, requiring a reset. The percentage that printed was different every time.

![hacks_P1440377.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/975/medium640/hacks_P1440377.jpg?1708720619)

I tried a few different things to solve this. I experimented with the BLE connection settings, adjusted the buffer size, implemented hard resets after printing, tried a different thermal printer library with cat printer support, used `drawPixel` rather than `drawBitmap` but alas, the same behavior always occurred. It being a Friday, I collected my various scraps of half-printed thermal paper and I [committed my progress](https://github.com/adafruit/Adafruit_PyCamera/pull/2) with notes, making peace with the fact that this project probably wouldn't work.

On Monday it was suggested that I try adding in some delays to the CatGFX library, since there is nothing in the library to account for failed or delayed BLE packets. Adding in over the top 1 second delays between almost every command resulted in a successful, although comically slow, print. Cautiously optimistic, I worked to reduce the delays and dialed in a compromise between speed and reliability, getting the delays down to about `5 ms` where needed. This modified version of the library is included in the code in the code repository and was used to compile the UF2.

![hacks_IMG_1105.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/978/medium640/hacks_IMG_1105.jpg?1708720977)


## Featured Products

### MEMENTO - Python Programmable DIY Camera - Bare Board

[MEMENTO - Python Programmable DIY Camera - Bare Board](https://www.adafruit.com/product/5420)
Make memories, or just a cool camera-based project,&nbsp;with **Adafruit's MEMENTO Camera Board**. It's a development board with everything you need to create programmable camera and vision projects: with a camera module, TFT preview screen, buttons, SD card slot and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5420)
[Related Guides to the Product](https://learn.adafruit.com/products/5420/guides)
### Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh

[Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh](https://www.adafruit.com/product/4236)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 420mAh for a total of about 1.55 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4236)
[Related Guides to the Product](https://learn.adafruit.com/products/4236/guides)
### Pink and Purple Woven USB A to USB C Cable - 1 meter long

[Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers, and more.&nbsp;&nbsp;[If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111)

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

## Related Guides

- [Adafruit MEMENTO Camera Board](https://learn.adafruit.com/adafruit-memento-camera-board.md)
- [Memento Photo Capture with itsaSNAP](https://learn.adafruit.com/memento-photo-capture-with-itsasnap.md)
- [Remote Shutter Button for MEMENTO](https://learn.adafruit.com/memento-shutter.md)
- [MEMENTO Focus Stacking](https://learn.adafruit.com/memento-focus-stacking.md)
- [DIY IoT Doorbell Camera with MEMENTO](https://learn.adafruit.com/diy-iot-doorbell-camera-with-memento.md)
- [MEMENTO Wireless Remote with TouchOSC](https://learn.adafruit.com/memento-wireless-remote.md)
- [3D Printed Camera Case for MEMENTO](https://learn.adafruit.com/memento-3d-case.md)
- [IoT Bird Feeder with Camera](https://learn.adafruit.com/iot-window-bird-feeder-with-camera.md)
- [OpenAI Image Descriptors with MEMENTO](https://learn.adafruit.com/openai-image-descriptors-with-memento.md)
- [Set up Web Workflow on the Adafruit MEMENTO](https://learn.adafruit.com/set-up-web-workflow-on-the-adafruit-memento.md)
- [Facial Detection and Recognition with MEMENTO](https://learn.adafruit.com/facial-detection-and-recognition-with-memento.md)
- [Face Tracking Robot with MEMENTO](https://learn.adafruit.com/face-tracking-robot-with-memento.md)
- [ePaper Camera](https://learn.adafruit.com/epaper-camera.md)
- [AdaBox 021](https://learn.adafruit.com/adabox021.md)
- [TensorFlow in your browser: Object Detection with Bounding Boxes](https://learn.adafruit.com/tensorflow-in-your-browser-object-detection-with-bounding-boxes.md)
