0

J Always Printing on Thermal Receipt Printer
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

J Always Printing on Thermal Receipt Printer

by ngramste on Wed Oct 21, 2020 12:02 am

I am not sure why but this J character is always printing as the first character the first time I send any command to the printer. Everything after it prints perfectly fine. I also saw the same issue when looking at the A_printertest example code provided by the thermal printer library. Any help would be appreciated! I am using an Arduino Uno connected to the Adafruit Mini Thermal Receipt Printer https://www.adafruit.com/product/597

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_Thermal.h>
 
#include "SoftwareSerial.h"
#define TX_PIN 6 // Arduino transmit  YELLOW WIRE  labeled RX on printer
#define RX_PIN 5 // Arduino receive   GREEN WIRE   labeled TX on printer
 
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial);     // Pass addr to printer constructor
 
void setup() {
  pinMode(7, OUTPUT); digitalWrite(7, LOW);
 
  mySerial.begin(19200);  // Initialize SoftwareSerial
  printer.begin();        // Init printer (same regardless of serial type)
 
  printer.justify('C');
  printer.println("<- Why this J?!");
  printer.feed(4);
}


Image

ngramste
 
Posts: 2
Joined: Tue Oct 20, 2020 11:56 pm

Re: J Always Printing on Thermal Receipt Printer

by ngramste on Wed Oct 21, 2020 12:17 am

I was able to add
Code: Select all | TOGGLE FULL SIZE
printer.reset();
right after initializing the printer and that seems to have solved my issue.

ngramste
 
Posts: 2
Joined: Tue Oct 20, 2020 11:56 pm

Re: J Always Printing on Thermal Receipt Printer

by nicochulo2001 on Tue Oct 27, 2020 11:52 am

If that doesn't work, there's also a fork of the Adafruit Thermal Printer Library called "Pos-Printer-Library" (https://github.com/AndersV209/Pos-Printer-Library) that solved a similar issue for me. It also offers a few added functionalities so that may prove useful to you

nicochulo2001
 
Posts: 5
Joined: Mon Oct 26, 2020 2:57 pm

Re: J Always Printing on Thermal Receipt Printer

by explora_exhibits on Tue Mar 09, 2021 4:02 pm

printer.reset();

This workaround only superimposed my first character over the "J" unfortunately. I also noticed it prints a "J" first on all the example code.

Does Adafruit have any solution?

My printer model is CSN-A2

explora_exhibits
 
Posts: 5
Joined: Tue Mar 09, 2021 2:37 pm

Re: J Always Printing on Thermal Receipt Printer

by adafruit_support_carter on Tue Mar 09, 2021 4:11 pm

Any difference if you leave out the justify call?
Code: Select all | TOGGLE FULL SIZE
  printer.justify('C');

adafruit_support_carter
 
Posts: 20609
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

by explora_exhibits on Tue Mar 09, 2021 5:21 pm

adafruit_support_carter wrote:Any difference if you leave out the justify call?
Code: Select all | TOGGLE FULL SIZE
  printer.justify('C');


No difference unfortunately. Here is bare-bones code that produced "JTEST".

#include "Adafruit_Thermal.h"

#include "SoftwareSerial.h"
#define TX_PIN 6
#define RX_PIN 5

SoftwareSerial mySerial(RX_PIN, TX_PIN);
Adafruit_Thermal printer(&mySerial);

void setup() {

mySerial.begin(19200);
printer.begin();
printer.print (F("TEST"));
printer.feed (3);
}

void loop() {
}

explora_exhibits
 
Posts: 5
Joined: Tue Mar 09, 2021 2:37 pm

Re: J Always Printing on Thermal Receipt Printer

by adafruit_support_carter on Tue Mar 09, 2021 5:36 pm

Weird. If you print a second line, do you get another J?

What are you using for power?

adafruit_support_carter
 
Posts: 20609
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

by explora_exhibits on Tue Mar 09, 2021 5:50 pm

adafruit_support_carter wrote:Weird. If you print a second line, do you get another J?

What are you using for power?


Everything is good after that initial "J". I'm using the 5V 2A wall wart supplied with the Adafruit Mini Thermal Receipt Printer Starter Pack.

explora_exhibits
 
Posts: 5
Joined: Tue Mar 09, 2021 2:37 pm

Re: J Always Printing on Thermal Receipt Printer

by adafruit_support_carter on Tue Mar 09, 2021 6:16 pm

What about the timing of the print? Does the J appear right away? Or when call one these specific lines?
Code: Select all | TOGGLE FULL SIZE
printer.begin();        // Init printer (same regardless of serial type)
     
printer.justify('C');
printer.println("<- Why this J?!");


You could additional prints and delays to help:
Code: Select all | TOGGLE FULL SIZE
Serial.println("Calling begin()");
printer.begin();
delay(1000);
Serial.println("Calling justify");
printer.justify('C');
delay(1000);
Serial.println("Calling println");
printer.println("<- Why this J?!");

And then you can open the Arduino Serial Monitor and watch the print statements there and compare to when the J shows up.

adafruit_support_carter
 
Posts: 20609
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

by explora_exhibits on Tue Mar 09, 2021 6:56 pm

I switched to printing directly from the serial pins, and it did not print a "J". I suspect there is junk data being transmitted from either the SoftwareSerial library or the Adafruit Thermal Printer Library.


adafruit_support_carter wrote:What about the timing of the print? Does the J appear right away? Or when call one these specific lines?
Code: Select all | TOGGLE FULL SIZE
printer.begin();        // Init printer (same regardless of serial type)
     
printer.justify('C');
printer.println("<- Why this J?!");


You could additional prints and delays to help:
Code: Select all | TOGGLE FULL SIZE
Serial.println("Calling begin()");
printer.begin();
delay(1000);
Serial.println("Calling justify");
printer.justify('C');
delay(1000);
Serial.println("Calling println");
printer.println("<- Why this J?!");

And then you can open the Arduino Serial Monitor and watch the print statements there and compare to when the J shows up.

explora_exhibits
 
Posts: 5
Joined: Tue Mar 09, 2021 2:37 pm

Re: J Always Printing on Thermal Receipt Printer

by explora_exhibits on Fri Mar 12, 2021 7:10 pm

For whatever it's worth, it only prints the "J" on the first print after uploading a new/updated program to the Arduino, or upon a power cycle.

In my application, the Arduino will generally be powered on once a day, so suffering through one "J" on the first print is not the end of the world.

EDIT: So weird the time indicated for my post is for Australia... what's that about? I thought Adafruit was in Boston?

explora_exhibits
 
Posts: 5
Joined: Tue Mar 09, 2021 2:37 pm

Re: J Always Printing on Thermal Receipt Printer

by adafruit_support_carter on Mon Mar 15, 2021 2:32 pm

Weird issue. It seems like you've found a work around. But since you can repeat the behavior, it might be worth opening an issue here:
https://github.com/adafruit/Adafruit-Th ... ary/issues

adafruit_support_carter
 
Posts: 20609
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

by rociorey on Wed Mar 31, 2021 6:18 am

Any updates on this? I seem to be having the exact same problem, every time I start the thermal printer it prints a "J" and I have no idea why

rociorey
 
Posts: 1
Joined: Wed Mar 31, 2021 6:17 am

Re: J Always Printing on Thermal Receipt Printer

by adafruit_support_carter on Wed Mar 31, 2021 11:43 am

Looks like there is an open issue for this:
https://github.com/adafruit/Adafruit-Th ... /issues/38

adafruit_support_carter
 
Posts: 20609
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.