garbled output with JP QR204 Mini Thermal Printer

Hi,

I cannot make JP QR204 Thermal Printer RS232 / TTL + USB to print correct chars - the output looks garbled.

Any idea how to find out what is wrong?

Baud rate is set based on printers test page specs.

/*
 Example 38.1 - Sparkfun Thermal Printer Test (COM-10438)
 http://tronixstuff.com/tutorials > chapter 38
 Based on code by Nathan Seidle of Spark Fun Electronics 2011
*/
#include <SoftwareSerial.h>
SoftwareSerial Thermal(5, 6);
int heatTime = 80;
int heatInterval = 255;
char printDensity = 15; 
char printBreakTime = 15;
void setup() 
{
 Serial.begin(9600); // for debug info to serial monitor
 Thermal.begin(9600); // to write to our new printer
 initPrinter();
}
void initPrinter()
{
 //Modify the print speed and heat
 Thermal.write(27);
 Thermal.write(55);
 Thermal.write(7); //Default 64 dots = 8*('7'+1)
 Thermal.write(heatTime); //Default 80 or 800us
 Thermal.write(heatInterval); //Default 2 or 20us
 //Modify the print density and timeout
 Thermal.write(18);
 Thermal.write(35);
 int printSetting = (printDensity<<4) | printBreakTime;
 Thermal.write(printSetting); //Combination of printDensity and printBreakTime
 Serial.println();
 Serial.println("Printer ready"); 
}
void loop()
{
 Thermal.println(" Visit http://tronixstuff.com ");
 Thermal.write(10); //Sends the LF to the printer, advances the paper
 Thermal.print(" Millis = ");
 Thermal.println(millis()); 
 Thermal.write(10);
 Thermal.write(10); 
 do { } while (1>0);
}

I have attached the printed result (twice).
Also I have attached “demo” which is printed when you hold printer button when turning on - it shows baud rate as 9600.

print_res.png

Any ideas? I've tried printer is working fine when connected via USB to PC. With a com port serial simulator I could print easily.
I also got the manual for QR204 and default setup commands are the same (setting up the printer parms e.g. ESC 7 n1 n2 n3 or in decimal 27 55 n1 n2 n3).

My last bet is that the issue is with serial port communication, any idea what could it be?

Post a link to the manual.

ESC 7 n1 n2 n3

are you sure that the 7 is the ASCII character 7 (= 55 decimal) and not integer 7?

Pete

Based on manual we need to send decimal 55 - it is written explicitly there. This is from tutorial:

Set print parameters
ASCII        ESC   7   n1   n2  n3
HEX          1B    37  n1   n2  n3
DEC          27   55  n1   n2  n3

Based on all tutorials I've checked Thermal.write(int) does not do any casting/type conversion and writes bytes.

Also I have tried printing without setting these parameters which should mean working with defaults - no luck.

All I can suggest is that the printer doesn't like the output from SoftwareSerial.

Which Arduino are you using?

Pete

Arduino UNO from arduino starter kit.

How is the printer powered when connected to the UNO?

Pete

Pete, thanks for your time.

I've powered it with separate power supply via external USB charger (~2A)
Then serial 5 serial pins:
1 - NC
2 - TX, printer output
3 - RX, input
4 - DTR - printer output
5 - GND

I am only using TR, RX and GND.

This link uses a similar printer. It also uses similar code with SoftwareSerial but it is using 19200. Try 19200.

Pete

I’e tried 19200 baud rate since it’s default in all tutorials I found and also in adafrut tutorial. Though no luck and also printer test page (the one when you print when holding printer button and turning printer on) shows baud rate 9600. See attached screenshot.

  • printer TX is connected to pin 6 and RX is connected to 5, where GND is to GND port next to pin 13.

I’ve also tried to connect to pin 1 and 0, though there was some sync issues uploading app and I gave up.

Pins 0 and 1 are also Serial Rx/Tx on the USB Serial port. It is awkward to use pins 0 and 1 on the UNO (and NANO) as a Serial port (i.e. try to use Serial.print to write to the printer) because, as you've discovered it interferes with uploading a sketch.
I'm afraid I can't think of anything else to try.

Pete

Hi,
I had the same issue. It seems that I had bought a RS232 serial (12v data) instead of a TTL serial (5v data) printer.

After visiting:
https://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232

I added a max232 for level shifting and everything is working!!