Impossible to print with thermal printer

Hello Guys !

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.

https://www.aliexpress.com/item/4001223132916.html?spm=a2g0o.order_list.order_list_main.22.21ef5e5bXDSDDh&gatewayAdapt=glo2fra

  • the following nfo received with the box

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);
}

Swap TX/RX ?(they seem correct, but worth a try).

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:

This page also shows a thermal printer library:

This guy has a nice video...

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.

The baud rate is shown near the bottom of the printout in the OP's picture, 9600, N, 8, 1.

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.

There's another one of these currently for sale on AliExpress. This one is in white, but it says it's the T8L-US model - like yours.

Part way down the description for that printer it says:

instruction set: TSC/ESC/CPCL instructions, download bitmaps, NV bitmap, a variety of one-dimensional bar code, QRCODE qr code

That should lead you to the commands that your particular printer supports.

There's a possible PDF for the TSC commands that I found here.

Here's one for the CPCL commands too.

1 Like

Thanks for the reply, contact them for the documenation as I believe the library don't work on this one

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

Ok so I follow the steps of the below thread :

I am able to print a bunch of stuff that don't have anything to do with the c file created and the command sent... If anyone speaks chinese maybe :slight_smile:


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.

What is your second photo showing?

The second image is a Google translation of whatever chinese caracters is returned :slight_smile:

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

 const char hz[][32]={
"DFROBOT",             //0
"极趣科技",             //1
"嵌入式热敏打印机",     //2
"arduino开发控制",     //3
"DIY趣味",             //4
"让我们一起共创未来",     //5
"打造我们的DIY世界",     //6
};

Code


#include"C:\Users\fabienne\Documents\Arduino\sketch_may30f\hz.c" 
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
  mySerial.begin(9600);

}
void loop() 
{
  mySerial.println();
  mySerial.println();
  mySerial.println("DFROBOT");
  mySerial.println();
  mySerial.println(hz[0]);                                       
  mySerial.println(hz[1]);                                       
  mySerial.println(hz[2]);
  mySerial.println(hz[3]);
  mySerial.println(hz[4]);
  mySerial.println(hz[5]);
  mySerial.println(hz[6]);
  mySerial.println();
  mySerial.println();
  mySerial.println();
  delay(10000);
}

Maybe simplify the loop to something like

  mySerial.println();
  mySerial.println("DFROBOT");
  mySerial.println(hz[0])
  mySerial.println();
  delay(10000);

Edit: Try with hz[1] to see if the same chinese characters are printed.

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

So I have the documentation but nothing refering to ARduino libraries or encoding? Any thoughts?
Tech Documentation

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.

There is this example on page 10:

A
1B 40 1a 5B 01 00 00 00 00 80 01 40 01 00
1A 54 00 00 00 00 00
B0 AE CE D2 D6 D0 BB AA 00
1a 5d 00
1a 4f 00
B:
1a 5B 01 00 00 00 00 80 01 00 01 00
1A 54 01
00 00
00 00
60 00 00 00
C4E3BAC3 00
1A 54 01
18 00
00 00
60 00 00 00
C4E3BAC3 00
1A 54 01
a0 00
00 00
60 00 10 33
C4E3BAC3 00
1a 5d 00
1a 4f 00

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

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.