Can you please help me to print anything on my thermal printer - I am failing so far.Thanks
I have bought a thermal printer on Aliexpress with RS232/TTL + USB ports.
I tried Adafruit library without success too.
I am struggling to print anything. The printer works well (Pushbutton to release paper electronicaly)
Wiring to Arduino UNO :
DTR : Empty
TX : to pin 10
RX to pin 11
GND to Main ground. (Arduino GND also plugged on main GND)
POWER Printer to external supply 12V.
POWER Arduino to computer USB
Code below:
#include <SoftwareSerial.h>
// Create an instance of the SoftwareSerial library
SoftwareSerial printerSerial(10, 11); // RX, TX
void setup() {
// Start the serial communication with a baud rate of 9600
Serial.begin(9600);
// Set the baud rate for the printer
printerSerial.begin(9600);
Serial.println("Initializing printer...");
// Initialize the printer
initializePrinter();
}
void loop() {
// Print a fixed text on the thermal printer
printText("Hello, thermal printer!");
delay(5000); // Wait for 5 seconds before printing again
}
void initializePrinter() {
// Reset the printer
printerSerial.write(27); // ESC command
printerSerial.write('@');
delay(100);
// Set the print mode to normal
printerSerial.write(27); // ESC command
printerSerial.write('!');
printerSerial.write((uint8_t)0); // 0 = normal print mode
delay(100);
// Set the character font (optional)
// The font number can be 0-7 depending on the printer model
printerSerial.write(27); // ESC command
printerSerial.write('M');
printerSerial.write((uint8_t)0); // 0 = font A
delay(100);
}
Is this sketch from the printer's examples (do they have any)? Does the printer document show where to download its thermal printer library? Did the printer document say to only use SoftwareSerial.h library?
This is the Adafruit page for their thermal printer:
It is a nice looking printer at a good price however it shows all the interfaces etc on you link, there is some information missing such as the baud rate. They do say you can contact them if you have problems, I would suggest doing that as quick as you can.
Great eyes, even looking I cannot read it. But I only looked at the first 20 seconds. I do not watch videos.
If it were me I would use a MEGA or something wit a know serial port, even a terminal program to get it operating. At that point I could determine which pin is the real Tx and Rx. When I have problems with serial it is generally that Tx is expecting to be connected to the other Tx. Some items from china are marked that way.
I have asked the documentation, thanks for taking the time to do some digging; Honestly too complex for me looking at the PDF. I will get back to you guys once I have the tech doc.
the printer DO works to print a setup page while long press when powering up. That's about it
Perhaps post the sketch you used to create that printout.
Can you reduce the amount printed out?
If you can, you can do 2 printouts and compare them. That may tell you that the printer is responding to the data in your sketch rather than just printing out some random characters.
The second image is a Google translation of whatever chinese caracters is returned
I created a .c file with the following content in UTF-8 format as per the tutorial (encoding GB2312) Outside of the IDE
The text repeats itself every 10 seconds (delay in the code)
The setup page shows GB18030
other caracters are coming out but nothing comparable with whatever is in the code.
So the communication works well, I reduced the delay and it works.
I think the issue is in the encoding but I am a newbie on thart part
Wow! That's a short set of commands. I somehow expected to see dozens of commands.
I would suggest that whilst playing around with the printer, that you have a simple sketch that takes ASCII hexadecimal numbers in from the IDE serial monitor an simply sends them out via a software serial port at the correct baud rate.
I wonder if this particular printer renders the page in internal memory before printing it out in one go. The pageprint command says Print the contents of the Page onto the label paper.
The 3 commands Pagestart, Pageend and Pageprinting suggest to me that you might issue a pagestart command followed by whatever print commands you need followed by a pageend command and then finally a pageprint command to actually commit the print to paper.
By studying the document you should hopefully be able to figure out what the example is doing. You could then try simply printing the exact same data to the printer to see what it does.
What isn't clear from the document is whether the data is sent in binary or ASCII hex - i.e. if you want to print the letter A, then do you send A or do you send 41 (which is the hexadecimal code for the letter A).
Hi, I also bought this printer and after several attempts I managed to get it to work, the problem was the JPL language which must be changed to ESC/POS with the PrinterSetting_en_US program