Interfacing a thermal printer (Printer use TSPL code)

Hello community,

My project consists on controlling a BEEPRT LTK-230 Thermal printer
you can see the information on Beeprt LTK-230 POS Printer - 80mm Thermal Receipt Printer, with arduino uno, and RS232 to TTL Serial Port Converter Module Connector MAX3232 Serial Module
This printer use the TSPL command, I have tried to do a test with the code that I leave below, but unfortunately I don't get any results.

String str = "SIZE 72 mm,50mm\r\n DIRECTION 0,0\r\n SET CUTTER 1\r\n SET GAP ON\r\n SPEED 6\r\n DENSITY 5\r\n CLS\r\n TEXT 80,85,\"3.EFT\",0,4,4,\"BEEPRT\"\r\n LINE 0,100,576,100,5\r\n TEXTBOX 0,280,\"3.EFT\",0,1,1,510, L32,\"Nanjing Beeprt Information Technology Co., LTD -- Website:www.beeprt.com\" BARCODE 10,140,\"128\",80,0,0,3,3,\"9878787689653565567876\"\r\n PRINT 1,1\r\n";

void setup() {
    Serial.begin(115200);
}

void loop() {
   delay(2000);
   Serial.println(str);
   delay(500);
   Serial.println("Test End");
    
}

any help, information or hint will be welcome, thank you very much.

Why are you making a string, just to send commands? Can't you just send the strings directly to Serial?
e.g.

Serial.println("SIZE 72 mm,50mm");
Serial.println("DIRECTION 0,0");
...

or

char str[] = "SIZE 72 mm,50mm\r\n DIRECTION 0,0\r\n SET CUTTER 1\r\n SET GAP ON\r\n SPEED 6\r\n DENSITY 5\r\n CLS\r\n TEXT 80,85,\"3.EFT\",0,4,4,\"BEEPRT\"\r\n LINE 0,100,576,100,5\r\n TEXTBOX 0,280,\"3.EFT\",0,1,1,510, L32,\"Nanjing Beeprt Information Technology Co., LTD -- Website:www.beeprt.com\" BARCODE 10,140,\"128\",80,0,0,3,3,\"9878787689653565567876\"\r\n PRINT 1,1\r\n";
...
loop() {
...
Serial.println(str);

Are you sure you want to print that in loop()? Are you mass producing units? :slight_smile:

Have you verified that the serial cable is wired correctly? There is not a consistent standard on which pin is Rx and which is Tx, and some cables swap pins 2&3, while others do not.

Is the printer set to the correct baud rate?

Hello aarg, thank you for your support,

I have tried both codes:

void setup() {
    Serial.begin(115200);
}

void loop() {
   delay(2000);
   Serial.println("SIZE 72 mm,50mm");
   Serial.println("DIRECTION 0,0");
   Serial.println("SET CUTTER 1");
   Serial.println("SET GAP ON");
   Serial.println("SPEED 6");
   Serial.println("DENSITY 5");
   Serial.println("CLS");
   Serial.println("TEXT 80,85,\"3.EFT\",0,4,4,\"BEEPRT\"");
   Serial.println("PRINT 1,1");
   
   delay(500);
   Serial.println("Test End");
   
}

and

char str[] = "SIZE 72 mm,50mm\r\n DIRECTION 0,0\r\n SET CUTTER 1\r\n SET GAP ON\r\n SPEED 6\r\n DENSITY 5\r\n CLS\r\n TEXT 80,85,\"3.EFT\",0,4,4,\"BEEPRT\"\r\n LINE 0,100,576,100,5\r\n TEXTBOX 0,280,\"3.EFT\",0,1,1,510, L32,\"Nanjing Beeprt Information Technology Co., LTD -- Website:www.beeprt.com\" BARCODE 10,140,\"128\",80,0,0,3,3,\"9878787689653565567876\"\r\n PRINT 1,1\r\n";


void setup() {
    Serial.begin(115200);
}

void loop() {
   delay(2000);
   Serial.println(str);
   delay(500);
   Serial.println("Test End");
   
}

and no results.

Hello david_2018, thank you for your response, the baud rate for the printer is 115200, and the arduino conection with MAX3232 is RX To Pin 0, TX to Pin 1, VCC to 5V, and GND to GND.

What about my comment about loop()? Do you really want to send this command to the printer repeatedly? Maybe it is not happy with that.

Sorry for my ignorance, but I am still a novice in arduino programming, and I thought that the code that I have attached to you was what you had recommended.
I honestly don't know how to do it.

void setup() {
    Serial.begin(115200);
}

void loop() {
   delay(2000);
   Serial.println("SIZE 72 mm,50mm");
   Serial.println("DIRECTION 0,0");
   Serial.println("SET CUTTER 1");
   Serial.println("SET GAP ON");
   Serial.println("SPEED 6");
   Serial.println("DENSITY 5");
   Serial.println("CLS");
   Serial.println("TEXT 80,85,\"3.EFT\",0,4,4,\"BEEPRT\"");
   Serial.println("PRINT 1,1");
   
   delay(500);
   Serial.println("Test End");
   
}

airmounir:
Hello david_2018, thank you for your response, the baud rate for the printer is 115200, and the arduino conection with MAX3232 is RX To Pin 0, TX to Pin 1, VCC to 5V, and GND to GND.

I was asking about the connection between the MAX3232 and the printer.

Yes sorry, from MAX3232 to printer is via DB9 serial cable

airmounir:
Yes sorry, from MAX3232 to printer is via DB9 serial cable

Have yoy verified that the Rx and Tx lines are connected correctly between the MAX3232 and the printer? Some cables are wired straight (pin 2 to pin 2, pin3 to pin3), others swap pins 2 and 3. It is also possible the printer expects some of the other handshake lines to be active.

I use this module, it’s connected well, i think the proble is on my code, because the printer use TSPL commands.

51mYgRtXswL.AC_SL1000.jpg