I try to print some text with python and a thermal receipt printer by a Raspberry Pi 2 model B.
I use the library developped by Adafruit and the printer sold by Adafruit too.
But it fails. The only thing working is the println function, and at least not well.
I have to print some characters like .--``[#]..--``--. but I have some random results.
Sometimes the line is correctly printed, sometimes the line is vertically mid printed (like a negative interline), sometimes not all the characters.
I use an AC power adaptor from an old Sony electronic equipment to power the printer. Output: DC5V 800mA. The printer is connected to the PI by GPIO and powered by the Sony power supply.
#!/usr/bin/python
from Adafruit_Thermal import *
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.setSize('S')
def printfile():
with open('output') as f:a=f.read()
a=a.splitlines()
for i in range(int(len(a))):
printer.println(a[i])
printfile()
an output file example:
[#]
[#]]
[#]
.--``||.
.--` | .--``--.
| .--` `--.
`--. | |
`--. .--``--. |
x x`--..--[#] `--. .--`
.--``-[#]][#] |.--`
.--` [#]-[#] .--`
| {`} ||--|`--.
`--. .--| |x `--.
`--.| |
`--. .--`
`--..--`
I saw that when it is bad printed, a red led blinks under the printer, that means there are some errors...
Any Idea ?
Links:
- Thermal receipt printer: https://www.adafruit.com/products/597
- Python library: https://github.com/adafruit/Python-Thermal-Printer