Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 1, No. 2, 2022 67 Multi-Purpose Portable Wireless Thermal Printer Yan Zhang 1, *, Xianxian Wu 2 1 School of Information Science and Technology Taishan University, Taian Shandong 271000, China 2 School of Foreign Languages Taishan University, Taian Shandong 271000, China * Corresponding author: Yan Zhang (Email: xtzy@163.com) Abstract: Traditional thermal printers have low quality and slow speed in mixed printing of images and texts, so more intelligent processing programs are needed to improve printing quality and speed. This system has designed a thermal printer based on Wi-Fi MCU ESP8266. The printer uses this chip as the main controller, and combines thermal printing principle, stepping motor control technology, micro B/S architecture technology, wireless communication and other technologies to design. This printer adopts independent design, and is compatible with multiple control terminals. It is ready to use without complicated settings. It has a simple and friendly control interface and is worthy of promotion and application in more fields, more diversified and personalized scenes. Keywords: Esp8266; Thermal printer; Wi-Fi printer. 1. Introduction Since the beginning of the 21st century, the thermal printing market has consistently maintained a sustained growth, and has been widely used in retail, transportation, logistics, commerce and other industries [1]. Thermal printing requires no ink and is fast. However, due to the single color, it is mainly used for printing barcode, label, bill, etc. With the rise of artificial intelligence and the Internet of Things, thermal printing will usher in new market growth points in education and training, entertainment, healthcare and other fields, because these industries need more and more convenient, efficient, fast, low-cost image and text presentation and long-term preservation methods [2,3]. The traditional thermal printer is generally embedded into other equipment as an accessory part, which has problems such as closed design, single function, low print quality, high production cost and maintenance cost. The independent portable handheld printer generally uses wired or wireless Bluetooth to connect to the main device [4]. The connection preparation is complex and cumbersome, and professional drivers and application software need to be installed. The printing content is relatively fixed and single, mainly based on bills, rarely involving the printing and output of documents and graphics [5]. At the same time, the transmission speed of the Bluetooth method to obtain the print data is slow, the processing speed of the image and text output microcontroller has a low impact on the efficiency, and the print output quality is poor. There is a relative lack of independent, portable, fast and high-quality thermal printer products in the market. Therefore, this paper proposes and designs a wireless thermal printer system based on Wi-Fi, which is independent, portable and cost-effective. 2. Principle Scheme The system uses the 32-bit microprocessor chip ESP8266 [6] with Wi-Fi as the core control chip, embedded with efficient monochrome image processing algorithm, integrated with a micro WEB server, and compatible with the rapid connection of mobile phones, tablets, computers and other terminal devices through the B/S architecture [7]; Users do not need complicated hardware connection or software installation. They can use it out of the box and achieve high- quality image and text output anytime and anywhere [8]. The overall design scheme is shown in Figure 1. Figure 1. Overall scheme diagram of Wi-Fi thermal printer This project technically includes hardware circuit design and software design. The hardware circuit includes the power supply circuit of the MCU and motor, the interface circuit of the main control chip, the driving circuit of the stepping motor and the print head, the printing paper and the temperature monitoring circuit; The software design mainly focuses on the programming of the core controller, including Wi-Fi communication module, WEB service module, SPI communication module [9], artificial intelligence image processing module, printing control module, etc. The relevant software code is compiled and stored in the Flash memory. 3. Hardware System Design The core circuit of the wireless thermal printer is shown in Figure 2. The core chip required by the core circuit is Esp8266 as the MCU, and TB6612 as the main control chip of the stepping motor [10], respectively connected to the thermal print head JX-2R-05. Figure 2. Overall scheme diagram of Wi-Fi thermal printer 68 The chip Esp8266 is a 32-bit Wi-Fi MCU with the clock frequency of 80MHz. 20% of the chip's processing capacity is used to run Wi-Fi protocols and real-time operating systems. The remaining 80% of the chip's processing capacity can be used for programming and development. So it can be used as the master chip of thermal printers. The micro Web server code, stepping motor control code, print head control code, etc. can be realized by the chip. The TB6612 motor drive module has two channels of output. It can control two DC motors or a two phase four wire stepping motor. It can output 1.2A of motor drive current. The peak starting current can reach 2A, which can meet the needs of the print head motor. The thermal print head uses a stepper motor to control the paper feeding, and pins AIN2, AIN1, BIN1, BIN2 are the input terminals of the step pulse. AO1, AO2, BO1 and BO2 are the output terminals of the step pulse, which are respectively connected with MTRA+, MTRA -, MTRB+ and MTRB - of the thermal print head. The stepping motor section control code of this system adopts the 4-beat drive mode, that is, the pulse input terminal is continuously pulsed according to the 4-beat drive sequence of the drive sequence diagram. The phase beat of the motor is shown in Figure 3, and the beat interval is 1ms. Figure 3. Logic sequence diagram of stepping motor The print head model adopts the line type thermal print head Jingxin [11] JX-2R-05, and the point density is 384 points/line, that is, 48 bytes * 8bit should be input for each line of data. The schematic diagram is shown in Figure 4. The VH pin is the print head heater with a voltage range of 4.2V- 8.5V. PHK, VSEN and PHE are respectively the cathode, power supply and reflector of the reflective photoelectric on- off paper shortage detection sensor. DI pin is the serial input pin of the print head data, which is used to receive the print data of MCU. CLK pin is the serial input clock, which sends data at the rising edge. STB1~STB6 are the power supply control signals for the thermal head, and the heating time of the print head is controlled at 800us. TM pin is the print head temperature sensor pin, which is connected to the analog to digital conversion pin AD0 of ESP8266. Figure 4. Schematic diagram of JX-2R-05 thermal print head The working voltage of the print head is 4.2V~8.5V, so the system can be powered by direct USB or 18650 lithium battery. The esp8266 requires 3.3V voltage, which is provided by the voltage regulator chip AMS1117. The charge and discharge of 18650 are managed and controlled by chip 2KAX [12]. The schematic diagram of power supply is shown in Figure 5. Figure 5. Circuit schematic diagram of power supply part 4. Software System Design 4.1. Overall software structure The software mainly focuses on the design of built-in WEB server, print head control and the compilation of client interface program. Users do not need to install any third-party APP or driver, and can easily print documents, pictures or bills by opening a browser or WeChat [13] applet. The user is allowed to store a variety of print templates, and the program can automatically generate two-dimensional code, barcode and other data. The depth learning contour extraction algorithm and image binarization algorithm designed for MCU are used to generate data suitable for thermal printing, so that the printing effect is better. Mobile phones, computers or tablets with browsers can be used as upper computers. After the upper computer connects to the web server of Esp8266 through Wi-Fi, it downloads HTML and JavaScript web page code and runs it, further establishes the WebSocket connection, uploads the processed images and text, and controls the thermal printing progress in real time. The whole function is shown in Figure 6. Figure 6. Software functional modules diagram The software functions to be realized by MCU include: establishing Wi-Fi connection of AP or station, establishing web server, establishing HTML and JS file server, establishing WebSocket server, stepping motor control, data transmission with print head, print point heating control, paper shortage detection, print head temperature detection, etc. 4.2. Wireless Connection The Esp8266 supports Arudino [14] programming, which can be used to turn on the MCU’s Wi-Fi signal as a wireless access point for the host computer to connect directly. Or make it work by scanning Wi-Fi routers and connecting them. In short, the upper computer and the thermal printer are connected to the same local area network. This allows the printer to communicate with the host computer at a speed of 2Mbps, laying the foundation for subsequent services. MCU Wi-Fi AP or Station Build Web Server HTML and JS File Server WebSocket Server Stepper motor control, heating control GUI Web browser Phone/Ta blet/PC HTTP 69 4.3. Web and WebSocket Server The system builds a micro web server supporting HTTP protocol and WebSocket protocol [15] based on TCP protocol in MCU. Its purpose is to transmit HTML and JavaScript code and data files between the upper computer and the lower computer, and to communicate with each other in real time. These HTML, JavaScript and Arduino codes run in upper computer browser and MCU respectively to realize user interface, real-time transmission, picture editing, motion control, status monitoring and other functions. 4.4. Hardware Control Code The thermal print head is integrated with a stepping motor, which can be directly driven by the chip TB6612. The input pin of the TB6612 is connected to the GPIO5, GPIO2, GPIO0 and GPIO4 pins of the MCU Esp8266. The program needs to set these four pins as the output, and output the high level for 1 millisecond according to Figure 3. The motor will take a paper step of 0.0625 mm. It should be noted that the number of GPIOs of Esp8266 is limited, and some time-sharing multiplexing pins are required. For example, GPIO0 is used as an input pin during startup. If it is pulled down, it will set the ESP8266 to the boot loader mode, and switch to the output pin to control the motor operation during normal operation. The thermal printer core adopts a reflective photoelectric on-off detection sensor, which is mainly used to detect the paper shortage and locate the printing paper through the marks on the printing paper. Refer to Figure 2 for the connection circuit, which is connected to GPIO16 of Esp8266. Set GPIO16 as the input mode, and read the level value to reflect the paper status: when there is no reflected light, the photocell is cut off, which is called low level. When there is white paper, the light is reflected to the photocell, and the photocell is conductive, showing high level. 5. Verification The design prototype and software operation interface are shown in Figure 7. After the printer is connected to the power supply, connect it to the mobile phone or computer through wireless Wi-Fi. Enter the printer IP address through the browser to enter the built-in server and start the operation interface. In this interface, you can draw, input text, edit pictures, press the print button, and the data processed into binary images will be transferred to the thermal printer through WebSocket, and printed out quickly. Figure 7. Photos of experimental prototype and screenshot of software front-end interface The test shows that images or characters can be printed clearly, and the printing depth can be adjusted by modifying the printing heating time. Under 20% coverage, the printing speed can reach 80mm/s. The printing point spacing is 0.125mm. Temperature detection and paper shortage detection can work normally. The image editing function is convenient and easy to use. The multi terminal connection interfaces of mobile phones, tablets and computers are consistent, the operation is unified and the functions are normal. 6. Summary The advantage of this design is that the equipment can realize intelligent high-quality graphic and text rapid printing through Wi-Fi without complex program installation. The utility model fundamentally solves the problems of single function, poor universality and complex setting of the thermal printer. The problem of poor printing effect of thermal printing image is basically solved. Due to the limitation that thermal printing only supports monochrome output, it partly solves the needs of consumers for printing at any time and personalized printing. Acknowledgment This work is supported by the Tai'an Science and Technology Innovation Development Project (Grant No. 2021GX029). References [1] Thermal Printing Market Size | Global Forecast Report 2026 [Online]. Available: https://www.gminsights.com/industry - analysis/thermal-printing-market. [2] Xinglong Cui,Ting Sun,Shuixin Deng,Yusen Xie,Lei Deng,Baohua Chen, “Unsupervised Barcode Image Reconstruction Based on Knowledge Distillation,” in Proceedings of 2021 3rd International Conference on Advanced Information Science and System (AISS 2021). [3] Wen Min Yang and Run Zhou Ge and Peng Fei Meng, “Wireless Thermal Printer Based on Internet of Things,” Applied Mechanics and Materials. 2014, 3546(672-674) . [4] Audiowise Technology Inc., “Patent Issued for Fast Paging Method, Bluetooth System And Bluetooth Connection Method Using The Same (USPTO 10,805,967),” Journal of Engineering, 2020, : 8163-. [5] Wang, Ruoxu et al, “Demonstration of Programmable In- Band OSNR Monitoring Using LCFBG With Commercial Thermal Printer Head,” IEEE Photonics journal, 2015, 7(4) : 1- 1. [6] ESP8266 Wi-Fi MCU I Espressif Systems,[Online]. Available: https://www.espressif.com/ [7] Yao Shen, “Construction of a Wireless Sensing Network System for Leisure Agriculture for Cloud-Based Agricultural Internet of Things,” Sensors (Vol. 2021). [8] Yan Zhang, “ Design of CNC Engraving Machine Based on Wi-Fi MCU,” World Scientific Research Journal, Vol.5 (2019). [9] Wang Y K, “ Development and implementation of an all- electric injection molding machine control system based on ARM and DSP,” M.S. thesis, Dept. Electron. Eng., South China University of Technology., China, 2019. [10] Zhaoyang Fu, Zheng Liu, Xingbang Liu, “ A Dual-Redundancy Two-Phase Hybrid Stepping Motor for Satellite Antenna Drive System,” Journal of Energies( Vol. 15, no. 1612). [11] Jingxin Home [Online]. Available: http:// www.jingxinst.com [12] kkmicro Home [Online]. Available: http://kkmicro.com/ index.php/product/1334.html [13] WeChat - Free messaging and calling app[Online]. Available: https://www.wechat.com/en/ 70 [14] Arduino - Home[Online]. Available: https:// www.arduino.cc/ [15] Wojciech Lasocha, Marcin Badurowicz, “Comparison of WebSocket and HTTP protocol performance”, Journal of Computer Sciences Institute, Vol. 19 (2021).