Voucher Service Pro for UniFi is a modern and extremely customizable ticket system including printing and network options. Based on the phenomenal and affordable Raspberry Pi. Available at >>> https://shop.sass-projects.info <<<
(July 5th, 2021)
I did a complete W-LAN installation on a campsite. But the Hotspot Manager that comes with the UniFi Controller was not very useful and a bit laborious to work with. I wanted a very simple all in one solution like, "Press one button and nothing else" to get a voucher printed and automatically insert the information to the UniFi Controller, that guests are able to join the network. I made a little video to introduce what this project does.
Youtube Video: https://www.youtube.com/watch?v=23y2rxoWPfo
- Based on the "RASPBIAN BUSTER LITE"
- Minimal image based on Debian Buster
- Version: September 2019
- Release date: 2019-09-26
Download image: https://downloads.raspberrypi.org/raspbian_lite_latest
- Brother_ql version: 0.9.4
- UniFi Controller version: 5.11.50
- UniFi API-client version: 1.1.42
- Raspberry Pi 3 B+ (B Plus) with 3A Power Supply with Heatsinks
- Raspberry Pi Supply Switch On/Off
- Raspberry Pi 7" Touchscreen Display and Case (Official)
- Brother QL-700 High-speed Professional Label Printer
- Brother DK-11209 Adress Label Small 62x29mm
- Two simple push buttons
sudo raspi-config
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install ntp ntpdate
sudo reboot
sudo apt-get install xinit
sudo apt-get install lxde-core lxterminal lxappearance
sudo apt-get install lightdm
sudo reboot
Optional: If you like to work over a VNC server like RealVNC.
sudo apt-get install realvnc-vnc-server realvnc-vnc-viewer
Remember to enable the VNC Server over sudo raspi-config
and reboot. (5 Interfacing Options - P3 VNC - Yes)
sudo apt-get install mariadb-server mariadb-client
sudo mysql_secure_installation
Secure installation:
- No current password: just hit return
- Set root password: Y
- Enter your MariaDB root password: yourpassword
- Remove anonymous user: Y
- Disallow root login remote: Y
- Remove test database: Y
- Reload privilege table: Y
sudo apt-get install apache2
sudo apt-get install php7.3 libapache2-mod-php7.3
sudo apt-get install php7.3-mysql php7.3-curl php7.3-gd php7.3-intl php-pear php-imagick php7.3-imap php-memcache php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl
sudo apt-get install imagemagick
sudo service apache2 restart
sudo apt-get install rpi-chromium-mods
sudo apt-get install python-sense-emu python3-sense-emu
sudo apt-get install python3-setuptools python3-pip libopenjp2-7-dev libtiff5 git fontconfig
sudo pip3 install --upgrade brother_ql
The brother_ql Python package provides the foundations for this project and enables driving QL series label printers without the usually required printer drivers. The upgrade flag makes sure, you get the latest version. So this is perfect!
sudo usermod -G lp -a pi
sudo reboot
cd /home/pi/Desktop
If you get No such file or directory
than you have to login once into your GUI to create the folders.
sudo wget https://raw.githubusercontent.com/PaintSplasher/unifi-voucher-service/master/codeimage/test-print.png
To identify your printer at your usb-port type
lsusb
You should see something like Bus 001 Device 004: ID 04f9:2042 Brother Industries, Ltd
, write down your ID.
sudo brother_ql -p usb://04f9:2042 -m QL-700 print -l 62x29 test-print.png
Your printer should now have a happy notice printed for you. Your printer ID depends on how many usb devices you have connected or which port you use, change the ID if necessary.
sudo apt-get install fontconfig
cd /usr/src
sudo git clone https://github.com/pklaus/brother_ql_web.git
cd brother_ql_web
sudo pip3 install -r requirements.txt
sudo cp config.example.json config.json
sudo nano config.json
As always it is up to you, if you want to change the port to :80 or :1337 or whatever. I go with standard :8013. Also if you don't have the QL-700 you should also change the model and remember your printer ID.
"PORT": 8013 , "HOST": "localhost" , "MODEL": "QL-700" , "PRINTER": "usb://04f9:2042"
sudo python3 brother_ql_web.py
Afterwards pointing a browser at the Raspberry Pi to http://localhost:8013 - You should get the user interface and be able to print any text you want. Hit STRG+C
to end the service and we can go on.
sudo nano /etc/rc.local
And add before "exit 0":
cd /usr/src/brother_ql_web; /usr/bin/python3 brother_ql_web.py&
sudo chmod +x /etc/rc.local
cd /var/www/html/
sudo git clone https://github.com/PaintSplasher/unifi-voucher-service.git
I made two touchscreen pages you can use - Pointing your browser to version 1 or version 2 to see the difference.
- Version 1: predefined vouchers
http://localhost/unifi-voucher-service/index.php
- Version 2: custom vouchers
http://localhost/unifi-voucher-service/index_custom.php
To change your personal voucher settings I did a uvs_config.php file and described everything.
sudo nano /var/www/html/unifi-voucher-service/uvs_config.php
cd /usr/src/
sudo git clone https://github.com/Art-of-WiFi/UniFi-API-client.git
sudo cp /usr/src/UniFi-API-client/examples/site_provisioning_example/config.template.php /var/www/html/unifi-voucher-service/config.php
sudo nano /var/www/html/unifi-voucher-service/config.php
Fill in your UniFi Controller "Username", Password", "URL" and "Version". Debug mode leave it on false.
It is important that we are able to execute "php to shell" so it is working between UniFi Controller and our landing page.
sudo chown pi -R /var/www/html && sudo chgrp pi -R /var/www/html
sudo chmod 777 -R /var/www/html/unifi-voucher-service/codeimage
sudo nano /etc/sudoers
And add after "User privilege specification"
www-data ALL=(ALL) NOPASSWD: ALL
After we push the "on" button on our Raspberry Pi we want to land directly on our unifi-voucher-service page without any input in fullscreen.
sudo apt-get install unclutter
sudo nano /home/pi/.config/lxsession/LXDE/autostart
And add
@xset -dpms
@unclutter
@chromium-browser --kiosk http://localhost/unifi-voucher-service
sudo raspi-config
Go to 3 Boot Option - B1 Desktop / CLI - B4 Desktop Autologin Desktop GUI, automatically logged in as "pi" user. Finish and reboot.
curl -sSL https://pisupp.ly/piswitchcode | sudo bash
Please use the github issue list or the Ubiquiti Community forums (https://community.ubnt.com/t5/UniFi-Stories/Unifi-Raspberry-Label-printer-with-touchscreen-Campsite/cns-p/2355393) to share your ideas/questions.
A big thank you and credits goes to:
- Art-of-WiFi: https://github.com/Art-of-WiFi/UniFi-API-client
- pklaus: https://github.com/pklaus/brother_ql_web
- aojeda: @Ubiquiti Community