A web-based ticket submission system that automatically prints tickets on ESC/POS thermal printers connected to a Raspberry Pi. Users can submit tickets through a simple web interface, which are then automatically printed with timestamps and formatted output.
Perfect for:
- Q&A sessions and feedback collection at events
- Anonymous comment boards
- Interactive installations
- Physical message boards
-Printer: (https://amzn.to/43Vx9DT)
-Raspberry Pi Kit: (https://amzn.to/3XoAZli)
-Receipt Paper: (https://amzn.to/4ag6q8Y)
-You’ll also need a monitor that supports HDMI input. Most do, but here’s a cheap one if you need it: (https://amzn.to/4rsK620)
-Plus a keyboard and mouse, I use this Bluetooth set: (https://amzn.to/4akjutW)
This application provides a complete solution for collecting and printing tickets in physical form. It consists of:
- Web Interface: A clean, responsive frontend that can be hosted on Netlify or run locally
- Backend API: A Flask-based API running on Raspberry Pi that handles printer communication
- Multiple Printer Support: Works with USB, Serial, Network, and Bluetooth-connected printers
- Optional Database Logging: Integrate with Convex to log all submitted tickets
- Spam Protection: Built-in reCAPTCHA integration
The system is designed to be flexible and easy to deploy. You can run everything on a single Raspberry Pi, or separate the frontend (hosted on Netlify) from the backend (on your Pi) for remote access.
- 📝 Simple web interface for ticket submission
- 🖨️ Automatic printing on Netum 58mm thermal printer
- ⏰ Timestamp and date stamping
- 💾 Logged submissions (optional Convex database integration)
- 🌐 Accessible from any device on your network
- 🔒 Built-in reCAPTCHA spam protection
Want to get started quickly? See QUICK_START.md for a step-by-step guide to deploy the application.
For detailed setup instructions, continue reading below.
Before starting, you'll need to configure the following:
-
reCAPTCHA Site Key - Replace
YOUR_RECAPTCHA_SITE_KEYinfrontend/index.html(line 183)- Get your key from Google reCAPTCHA Admin
- Or set via Netlify environment variable
RECAPTCHA_SITE_KEY
-
API URL - Replace
YOUR_API_URL_HEREinfrontend/index.html(line 217)- Set this to your ngrok, Cloudflare tunnel, or direct Raspberry Pi URL
- Example:
https://abc123.ngrok.ioorhttps://your-tunnel.trycloudflare.com
- Convex Database (Optional) - Set
CONVEX_DEPLOYMENTin Netlify environment variables- Only needed if you want to log tickets to a database
- If not configured, tickets will still print but won't be logged
See env.example for all available environment variables.
On your Raspberry Pi 4B, install the required Python packages:
# Install Python packages
pip3 install -r requirements.txt
# Install system dependencies for USB printer
sudo apt-get update
sudo apt-get install -y python3-pip python3-dev libusb-1.0-0-dev
# For USB printer access (important!)
sudo usermod -a -G lp dialout pi
sudo apt-get install -y printer-driver-all- Plug in your Netum thermal printer via USB
- Find the USB vendor and product IDs:
You should see something like:
lsusb
Bus 001 Device 003: ID 0416:5011 - The first 4 digits (0416) are the vendor ID
- The last 4 digits (5011) are the product ID
- Update the values in
app.pyif needed
If your printer is connected via GPIO serial pins:
sudo raspi-config
# Navigate to Interface Options > Serial Port > EnableEdit the configuration in app.py or set environment variables:
# For USB printer (default)
export PRINTER_TYPE=usb
export USB_VENDOR=0x0416
export USB_PRODUCT=0x5011
# For serial printer
export PRINTER_TYPE=serial
export SERIAL_PORT=/dev/ttyAMA0
# For network printer
export PRINTER_TYPE=network
export NETWORK_HOST=192.168.1.100python3 app.pyThe application will start on http://0.0.0.0:5000
Find your Raspberry Pi's IP address:
hostname -IThen access the web interface from any device on your network:
http://[RASPBERRY_PI_IP]:5000
To run the application automatically on boot:
# Create a systemd service file
sudo nano /etc/systemd/system/ticket-printer.serviceAdd the following content:
[Unit]
Description=Ticket Printer Application
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/ticket-printer-app
ExecStart=/usr/bin/python3 /home/pi/ticket-printer-app/app.py
Restart=always
[Install]
WantedBy=multi-user.targetThen enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable ticket-printer
sudo systemctl start ticket-printer
sudo systemctl status ticket-printer- Open a web browser and navigate to
http://[YOUR_PI_IP]:5000 - Enter your name (optional)
- Enter your question or comment
- Click "Print Ticket"
- The ticket will automatically print with the specified format
The tickets are printed in this format:
================================
TICKET
--------------------------------
From: [Name]
Time: [Current Time]
Date: [Current Date]
--------------------------------
Question/Comment
[Your message]
--------------------------------
================================
If the printer is not detected:
- Check USB connection
- Verify printer is powered on
- Run
lsusbto see if the device is recognized - Try different USB ports
- Check permissions:
sudo chmod 666 /dev/bus/usb/00X/00Y
If you get permission errors:
sudo usermod -a -G lp,dialout pi
sudo chmod 666 /dev/ttyUSB0 # or /dev/ttyAMA0 for GPIO
# Then log out and log back inYou can test the printer connection:
python3 << EOF
from escpos.printer import Usb
p = Usb(0x0416, 0x5011)
p.text("Test print\n")
p.cut()
EOFIf running as a service:
sudo journalctl -u ticket-printer -fGET /- Web interfacePOST /submit_ticket- Submit a ticket to print- Body:
{"from_name": "John Doe", "question": "Your question here"}
- Body:
GET /health- Health check endpoint
- Python 3.7+
- Netum 58mm ESC/POS thermal printer (https://amzn.to/43Vx9DT)
- Raspberry Pi 4B (https://amzn.to/4ooA5jS)
- 58mm Receipt Paper (https://amzn.to/4ag6q8Y)
- Flask web framework
- python-escpos library
This application supports multiple deployment configurations:
- Run
app.pydirectly on the Raspberry Pi - Access via local network:
http://[PI_IP]:5000
- Frontend: Deploy
frontend/folder to Netlify - Backend: Run
backend/api.pyon Raspberry Pi - Expose backend via ngrok or Cloudflare Tunnel
- See
README_NETLIFY.mdfor detailed instructions
Copy env.example to .env and configure:
cp env.example .env
# Edit .env with your settingsKey variables:
PRINTER_TYPE- Type of printer connection (usb, serial, network, bluetooth)USB_VENDOR/USB_PRODUCT- USB printer IDs (find withlsusb)RECAPTCHA_SITE_KEY- Your Google reCAPTCHA site keyCONVEX_DEPLOYMENT- Convex database URL (optional)
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.
This project adheres to a Code of Conduct that all contributors are expected to follow. Please read CODE_OF_CONDUCT.md before participating.
See CHANGELOG.md for a detailed history of changes and versions.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to modify and use as needed!