Skip to content

Add a post-it printer feature for Google Home with Raspberry, a chines 200dpi thermal printer and IFTTT.

License

Notifications You must be signed in to change notification settings

Tb7386/GA_Post-it_thermal_printer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Google Assistant memo thermal printer

Add a post-it printer feature for Google Home with Raspberry, a chines 200dpi BLE thermal printer and IFTTT.

GA_Printer

This scripts enables printing on chiness copy of Peripage A6. Due to the use of Python this script should be portable to any environment supported by PyBluez. This script only print text.

Introduction

Projet provide a low-cast post'it printing solution. Hardware needed :

  • RaspberryPi or any other product with network, Bluetooth Low Energy communication and support Python 3 and Bluez.
  • Chiness thermal printer BLE 200dpi ~20$ on Aliexpress
  • Google Home (or any device with Google Assistant)

Software used :

  • Raspberry Pi OS (if Raspberry Pi is used)
  • Python 3.7
  • PyBluez
  • IFTT

Thermal printer communication

Chiness copy of Peripage A6 is an inexpensive portable thermo printer. It provides by Bluetooth Low Energy.

Trame is composed by

Header data lenght ?? DATA CRC8 end of line
51:78:XX:00 05 00 82:7f:7f:7e:82 60 ff

Header XX :

  • bf : Print 384 dot
  • a1 : move forward paper (eg: data=01:00 => 1 dot forward)

Print data (eg 82 -> 1000 0010) :

  • bit[0] : 1 = Black, 0 = White
  • bit[2-7] : number of dot

Installation

Prerequisites

Install dependencies

apt install git python3-pip python3-gattlib libopenjp2-7

Clone project and Python dependencies

git clone https://github.com/Tb7386/GA_Post-it_thermal_printer.git
pip3 install -r ./GA_Post-it_thermal_printer/requirements.txt

CLI Usage

Turn ON printer. The printer doesn't need to be associated.

python3 ./GA_Post-it_thermal_printer/ga_printer.py OPTIONS

OPTIONS

usage: ga_printer.py [-h] [-t TEXT] [-p PORT] [-s SIZE] BTMAC

Print an text to a thermal printer

positional arguments: BTMAC BT MAC address of printer (type FIND to scan BLE devices)

optional arguments:

  • -h, --help : show this help message and exit
  • -t TEXT, --text TEXT : Text to be printed
  • -p PORT, --port PORT : HTTP port
  • -s SIZE, --size SIZE : Font size

First find Bluetooth mac address of printer

python3 ./GA_Post-it_thermal_printer/ga_printer.py FIND

Result

name: , address: 73:2D:48:3E:C9:BE
name: GB03, address: 7A:4D:3B:FD:FE:ED
name: , address: 70:C8:63:81:D2:4B

Print text

python3 ./GA_Post-it_thermal_printer/ga_printer.py 7A:4D:3B:FD:FE:ED -t "hello world"

You can define font size with "-s" option (font size default = 50)

Start HTTP server

python3 ./GA_Post-it_thermal_printer/ga_printer.py 7A:4D:3B:FD:FE:ED -p 8080

Start a HTTP server with TCP 8080 listen port. You can define font size with "-s" option (font size default = 50)

HTTP server print all text receive with POST request

ADD Google Assistant feature

IFTT can send POST HTTP request with voice command.

Prerequisites

  • Create a account on IFTTT
  • Link your Google account on IFTTT
  • NAT your RaspberryPI HTTP server on your internet box
  • If necessary configure a dynamic DNS service

Configure new APPLET

/!\ Free IFTTT account can use only 5 applets

Create new applet

image

Click IF ADD button

image

Search Google Assistant service

image

Select Say a phrase with a text ingredient trigger

image

Configure trigger. Text print is $

image

Click THEN THAT ADD button

image

Search Webhooks service

Search Webhooks service

Choose Make a web request action

image

Configure action.

  • IP : is public IP addess of RaspberryPi HTTP server (Public IP of internet box)
  • PORT : is NAT port to access RaspberryPi HTTP server

image

Save and enjoy your new feature. Say :

  • "OK Google, print memo buy bread"
  • "OK Google, print invoice"

Autors

License

Project under license MIT - see LICENSE.md file for more informations

About

Add a post-it printer feature for Google Home with Raspberry, a chines 200dpi thermal printer and IFTTT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages