Foreword:
With this guide we will see how to connect a thermal printer, generically called Thermal Printer, with the Raspberry Pi.Can be employed for many uses such as for example the realization of a cash register or even simply to print images, bar codes of various types thanks to the library that you will find in this article or even connect to the network and realize a thermal printer of the network, for your many uses.
LIST OF MATERIALS:
- Raspberry Pi
- Micro SD
- Ethernet cable
- Mini Thermal Printer
- Paper Printer
- Jumper Kit M / MM / FF / F
We will limit ourselves in this guide, however, to consolidate the basic concepts for the creation and printing of a small message with this wonderful printer.
Software:
We will need to install the operating system for the Raspberry Pi. For newbies novice here you find the guide on how to install the Distro before starting the project.
Once you downloaded and installed the distro the first thing you should do is usually the latest update:
sudo apt-get update
Later we will install shell libraries fondametali to create the project:
sudo apt-get install python-serial python-imaging python-Unidecode
NOTE: The next step that we are about to show will "liberate" the serial port to communicate with the Raspberry Pi thermal printer, causing However, the loss of functionality of the console cable raspberry, and so will be accessible exclusively via SSH or via Desktop functionality via a keyboard and a mouse.
sudo nano /boot/cmdline.txt
Open the file cmdline.txt what we have to do is find this line:
dwc_otg.lpm_enable console = 0 = = ttyAMA0,115200 kgdboc ttyAMA0,115200 console = tty1 root = / dev / mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait
and replace with:
dwc_otg.lpm_enable = 0 console = tty1 root = / dev / mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait
and then:
sudo nano / etc / inittab
and delete the following line to save the file and close this instruction will lead to loss of the use of TTL cable console.
T0: 23: respawn: / sbin / getty -L ttyAMA0 115200 vt100
Once this is done it has to download the github firmware that will install the necessary libraries to interpret the file sent to serial printer.
So before we install git:
sudo apt-get install git
and then we will download the firmware:
git clone https://github.com/adafruit/Python-Thermal-Printer
We installed all the necessary software now we just have to see connections and an example to print.
Hardware components:
The wiring is very simple. First let's start with seeing the power of the Thermal Printer. Its working voltage ranges from 5V to 9V then it can be fed directly with the tension of the raspberry pi, but with a negligible current that can be made available, the printer may run very slowly and especially not affect good print quality.
So our advice and to obtain a DC power supply from 5V to 9V 2A to power the printer.
We see the pattern for wiring:
As we can see the bottom of the printer you have two JST connectors to the left that allows you to connect the power and the right to manage the serial. In this guide we look at the use of the yellow pin serial that allows you to receive data from the raspberry pi and send them to the printer. In doing so we will have our ticket !!
Here you will find the pinout of raspberry and how to connect the yellow cable supplied in the kit of the Thermal Printer. Pinout cable Yellow: connect to the TX Raspberry in order starting with the first pin corresponds to Pin 8 .
Print Ticket Practical example:
Let's go into a shell and let's move to the folder:
cd Python-Thermal-Printer
Then we write:
sudo nano provastampante.py
and paste the code below:
Adafruit_Thermal from import * printer = Adafruit_Thermal ("/ dev / ttyAMA0", 19200, timeout = 5) printer.println ('Critics') printer.println ('Corporation') printer.println ('Learn')
Now we just, always under the Printer folder-Thermal-Printer to run the .py file you just created:
sudo python provastampante.py
Post a Comment