How can I print Chinese by the Mini Thermal Printer ?

hello :slight_smile:
I need help !
In the specs for the Mini Thermal Printer it shows: "Character Set: GB18030(Chinese)"
but I don't know how to print the Chinese.
I can hardly find any teaching(Arduino UNO).

https://wiki.dfrobot.com/Embedded%20Thermal%20Printer%20-%20TTL%20Serial%20SKU%3A%20DFR0503-EN#target_4

I have tried the example of printing Chinese in it but it failed.

Grateful for any responses.

The link you added has a header "Print Character(Arduino)" which has an example of how to print Chinese. Start with that.

Print latin characters first. If this doesn't work, something is wrong with your circuit or printer.

Chinese text must be stored in UTF-8 format, I think that you already know what that means. Use your favorite editor to create such files, and never open one in IDE.

wvmarle:
The link you added has a header "Print Character(Arduino)" which has an example of how to print Chinese. Start with that.

I have tried that example of printing Chinese, but it failed.

Did it print anything, rattle, buzz, pass smoke ?
Do you know if the printer, power supply, comms are wired properly?
How do you know that?

lastchancename:
Did it print anything, rattle, buzz, pass smoke ?
Do you know if the printer, power supply, comms are wired properly?
How do you know that?

I created a C file with the example, the storage format tried ANSI and UTF-8, but they all printed garbled characters.

62214401_1025543730976478_5487927456402767872_n.jpg

62214401_1025543730976478_5487927456402767872_n.jpg
That’s not rubbish.
I see the words ‘Arduino, DFROBOT and DIY’
So you know the connectivity and printer are ok.
Now take a look at the character set, the code and see where the errors creep in.
Start by looking at correlations between the Chinese and ASCII character sets.
It may be as simple as a config pin, a stuck bit or other format specifier.

The output looks to me like the printer does not recognize the data as UTF-8.

Why trying to use UTF8?
The manual explicitly mentions the printer can understand GB2312 and GB18030, and even warns against accidentally converting to UTF8:

1.Create a hz.c file, the content should be a created character array. (How to create a .c file? Create a .txt file and revise the suffix to .c)

const char hz[32] is a statement of a character string array in fact. One string cannot exceed 32 bytes (16-bit Chinese character coded in GB2312). If you want to display a long Chinese character, you need to revise the number “32”; actually, in other words, it means to take out all Chinese characters and put them into a array. An international program version can be easily realized by this way since we can display different language by just switching the array;

Note : The creation of this file aims to solve the problem that GB2312 Chinese character internal code cannot be edited under IDE Programming Environment. So don’t open the file in IDE programming environment in case the file is rewritten into UTF8 internal code file.

wvmarle:
Why trying to use UTF8?
The manual explicitly mentions the printer can understand GB2312 and GB18030, and even warns against accidentally converting to UTF8:

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

This is the content of the C file I wrote according to the example.
The storage format is the same whether it is printed by ASNI or UTF-8.

#include"C:\Users\Administrator\Documents\Arduino\uart_dayinji\hz.c"     //Reference the hz.c file created before, the content of the quotation should be the index address of the hz.c file, and it need to be revised according to hz.c actual address. 
#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);
}

This is the arduino program I wrote according to the example.

It’s exactly the same as the example, but I don’t know why the printed content is garbled.

wvmarle:
The manual explicitly mentions the printer can understand GB2312 and GB18030

Wang_shinchih:
The storage format is the same whether it is printed by ASNI or UTF-8.

[...]

I don't know why the printed content is garbled.

Seriously. Did you even read the manual, or my previous post, regarding the character encodings to use?

wvmarle:
Seriously. Did you even read the manual, or my previous post, regarding the character encodings to use?

I read the instructions for the printer, but I am still confused how to use character encoding, I can't find related resources and teaching.

Set your text editor to save in the character encoding you want. You obviously know how to do this for UTF8 and ANSI, instead try the ones mentioned in the manual.

I know this post is a few months old, but hoping someone might be able to enlighten me on a few things, and I think this is the right thread for me.

I have a thermal printer which works great...… except I cannot print the '£' symbol. I get a Chinese character instead everytime. Is it possible to change this to print a '£'?

https://www.ebay.co.uk/itm/58mm-701-Portable-Bill-Embedded-Thermal-Printer-Receipt-RS232-TTL-Printer/292665135033?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

The printer has 5 wires, red and black, connected directly to a separate power supply, yellow tx, blue rx, green not connected. The fact that the printer is running ok (other than the '£'), is it really an issue that the green is loose?

and lastly, I can print text, and I can print a value over 2 lines:

printer.println(F("2 = "));
printer.println(i);

but I just cant get the right formula to print on the same line:

printer.println(F("2 = ")+(i));
printer.println(F("2 = "+i));
printer.println(F("2 = ")+F(i));
printer.println(F("2 = "))+printer.println(i)

and many other iterations. Would someone know the correct formula?

Many thanks for reading :slight_smile: