Add a post-it printer feature for Google Home with Raspberry, a chines 200dpi BLE thermal printer and IFTTT.
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.
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
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
- RaspberryPi with RaspberriPi OS Lite Bullseye
apt install git python3-pip python3-gattlib libopenjp2-7
git clone https://github.com/Tb7386/GA_Post-it_thermal_printer.git
pip3 install -r ./GA_Post-it_thermal_printer/requirements.txt
Turn ON printer. The printer doesn't need to be associated.
python3 ./GA_Post-it_thermal_printer/ga_printer.py 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
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
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)
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
IFTT can send POST HTTP request with voice command.
- 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
/!\ Free IFTTT account can use only 5 applets
Create new applet
Click IF ADD button
Search Google Assistant service
Select Say a phrase with a text ingredient trigger
Configure trigger. Text print is $
Click THEN THAT ADD button
Search Webhooks service
Choose Make a web request action
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
Save and enjoy your new feature. Say :
- "OK Google, print memo buy bread"
- "OK Google, print invoice"
- Thomas BERGER Tb7386 @Tb7386
Project under license MIT
- see LICENSE.md file for more informations