{"id":15132808,"url":"https://github.com/alifeee/thermal-printer-pi","last_synced_at":"2026-02-14T01:38:22.590Z","repository":{"id":256643614,"uuid":"851908161","full_name":"alifeee/thermal-printer-pi","owner":"alifeee","description":"Thermal Printer scripts for Raspberry Pi","archived":false,"fork":false,"pushed_at":"2025-03-16T14:31:04.000Z","size":21,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T16:49:57.171Z","etag":null,"topics":["escpos","python","raspberry-pi","thermal-printer","zj-58"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alifeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-03T22:29:15.000Z","updated_at":"2025-03-17T15:47:13.000Z","dependencies_parsed_at":"2025-03-09T18:36:52.170Z","dependency_job_id":null,"html_url":"https://github.com/alifeee/thermal-printer-pi","commit_stats":null,"previous_names":["alifeee/thermal-printer-pi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alifeee%2Fthermal-printer-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alifeee%2Fthermal-printer-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alifeee%2Fthermal-printer-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alifeee%2Fthermal-printer-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alifeee","download_url":"https://codeload.github.com/alifeee/thermal-printer-pi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406068,"owners_count":20933802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["escpos","python","raspberry-pi","thermal-printer","zj-58"],"created_at":"2024-09-26T04:40:29.113Z","updated_at":"2026-02-14T01:38:17.571Z","avatar_url":"https://github.com/alifeee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thermal Printing\n\nFor more context on the printer, see:\n\n- \u003chttps://github.com/alifeee/openbenches-thermal-printer?tab=readme-ov-file#escpos\u003e\n\n## python-escpos\n\nThe main Python library used is python-escpos: \u003chttps://github.com/python-escpos/python-escpos/\u003e\n\nHere is an example file:\n\n```python\nfrom escpos.printer import Usb\n\np = Usb(0x0416, 0x5011, profile=\"ZJ-5870\")\np.text(\"Hello World\\n\")\np.barcode('4006381333931', 'EAN13', 64, 2, '', '')\np.qr(\"https://alifeee.co.uk\")\n\np.close()\n```\n\n## Installation\n\n```bash\n# download files\nmkdir -p /usr/alifeee\ngit clone git@github.com:alifeee/thermal-printer-pi.git /usr/alifeee/thermalprinter\n# install python\npython3 -m venv env\n. env/bin/activate\npip install python-escpos[usb]\n# add usb rules\necho 'SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"0416\", ATTRS{idProduct}==\"5011\", MODE=\"0666\", GROUP=\"dialout\"' \u003e /etc/udev/rules.d/99-escpos.rules\nsudo systemctl restart udev\nsudo udevadm control --reload-rules \u0026\u0026 sudo udevadm trigger\n# add cgi scripts\nmkdir -p /var/www/cgi/do/\nsudo ln -s /usr/alifeee/thermalprinter/cgi/qr /var/www/cgi/do/qr\nsudo ln -s /usr/alifeee/thermalprinter/cgi/qr.cgi /var/www/cgi/do/qr.cgi\n```\n\n## Use\n\n### Test printer\n\n```bash\n./env/bin/python test.py\n```\n\n### Print QR code\n\n```bash\n./env/bin/python qr.py -t title -url \"http://raspberrypi.local/do/qr\"\n```\n\n## Using Flask server\n\n### nginx configuration\n\n```nginx\nserver {\n                listen 80 default_server;\n                listen [::]:80 default_server;\n\n                index index.html;\n\n                server_name _;\n\n                # return homepage even if Flask server is off\n                location = / {\n                        alias /usr/alifeee/thermalprinter/templates/;\n                        try_files index.html =404;\n                }\n\n                # otherwise use Flask server\n                location / {\n#                       root /var/www/html;\n#                       try_files $uri $uri/ =404;\n\n                        proxy_pass http://localhost:5000;\n                        proxy_redirect off;\n                        proxy_set_header Host $http_host;\n                        proxy_set_header X-Real-IP $remote_addr;\n                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n                        proxy_read_timeout 900;\n                        client_max_body_size 20M;\n                }\n\n                location /do/ {\n                        root /var/www/cgi;\n                        index index.cgi;\n                        fastcgi_intercept_errors on;\n                        include fastcgi_params;\n                        fastcgi_param SCRIPT_FILENAME /var/www/cgi$fastcgi_script_name;\n                        fastcgi_pass unix:/var/run/fcgiwrap.socket;\n                }\n        }\n```\n\n### test for debugging\n\n./env/bin/flask --app server run --host 0.0.0.0\n\n### enable service\n\n```bash\n# install modules\npython3 -m venv env\n./env/bin/pip install -r requirements.txt\n\n# enable systemd\nsudo cp thermalprinter.service /etc/systemd/system/thermalprinter.service\nsudo systemctl enable thermalprinter.service\nsudo systemctl start thermalprinter.service\nsudo systemctl status thermalprinter.service\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falifeee%2Fthermal-printer-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falifeee%2Fthermal-printer-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falifeee%2Fthermal-printer-pi/lists"}