Skip to content

Instantly share code, notes, and snippets.

@fellwell5
Created March 4, 2021 23:04
Show Gist options
  • Save fellwell5/df618276728409ee7b3e06658323901d to your computer and use it in GitHub Desktop.
Save fellwell5/df618276728409ee7b3e06658323901d to your computer and use it in GitHub Desktop.
#Install for tinyprinter on Raspberry Pi 4 (8 GB)
#2021-03-02
#Set configuration with sudo raspi-configuration (locale, enable ssh, ..)
#Disable IPv6 https://cwesystems.com/?p=231
#Import SSH Keys
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install git python3-pip build-essential libbluetooth-dev libhidapi-dev libatlas-base-dev python3-skimage llvm-dev cython3 python3-skimage llvm python3-numpy python3-numba
pip3 install cython pybluez pilkit watchgod colorama
#I installed it to my user directory /home/pi which can be accessed with ~
cd ~
git clone https://github.com/KTamas/sirius-client.git
git clone https://github.com/tinyprinter/python-paperang.git
cd python-paperang
cp config.example.py config.py
nano config.py #Secondline should be edited to macaddress=""
python3 printer.py # yay, it works!
#now to the sirius-client
cd ../sirius-client
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - # 14 is the newest version 2021-03-02 (get latest LTS version from https://nodejs.org/en/download/)
sudo apt-get install nodejs
sudo npm install --global yarn
sudo npm install -g ts-node
yarn install
yarn ts-node bin/client.ts run --uri wss://littleprinter.nordprojects.co/api/v1/connection -p ~/my-printer.printer -d filesystem
#Your little printer should be now connected to Nord's littleprinter instance
#Let's run sirius-client and python-paperang as a service :)
#Download the two service files:
wget https://pastebin.com/raw/nq2PGBy6 -O sirius-client.service
wget https://pastebin.com/raw/H1694PwP -O python-paperang.service
#I cloned the two repositories to my home directory of the pi user
#If you haven't done this then you have to change the paths and the user and group to your settings in the service files
#Move both of them in the /etc/systemd/system/ directory
sudo mv sirius-client.service /etc/systemd/system/sirius-client.service
sudo mv python-paperang.service /etc/systemd/system/python-paperang.service
#Enable the services
sudo systemctl enable sirius-client.service
sudo systemctl enable python-paperang.service
sudo systemctl start sirius-client.service
sudo systemctl start python-paperang.service
#You can check the status of the services if you want
sudo systemctl status sirius-client.service
sudo systemctl status python-paperang.service
#Now everything is set up and ready :)
#HEADLESS MODE:
#If you want to let your Raspberry Pi 4 run without a display you
#have to uncomment the following line in /boot/config.txt
sudo nano /boot/config.txt #Search for #hdmi_force_hotplug=1 and remove the #
#And you have to set a default resolution in raspi-config
#Information: https://raspberrypi.stackexchange.com/a/109282+
[Unit]
Description=python-paperang
[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/pi/python-paperang/littleprinter.py
Restart=always
WorkingDirectory=/home/pi/python-paperang
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
[Unit]
Description=sirius-client
[Service]
ExecStart=/usr/bin/yarn ts-node bin/client.ts run --uri wss://littleprinter.nordprojects.co/api/v1/connection -p /home/pi/msprinter.printer -d filesystem
Restart=always
WorkingDirectory=/home/pi/sirius-client
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment