J Always Printing on Thermal Receipt Printer

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ngramste
 
Posts: 2
Joined: Tue Oct 20, 2020 11:56 pm

J Always Printing on Thermal Receipt Printer

Post by ngramste »

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

#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

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

Re: J Always Printing on Thermal Receipt Printer

Post by ngramste »

I was able to add

Code: Select all

printer.reset(); 
right after initializing the printer and that seems to have solved my issue.

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

Re: J Always Printing on Thermal Receipt Printer

Post by nicochulo2001 »

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

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

Re: J Always Printing on Thermal Receipt Printer

Post by explora_exhibits »

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

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

Post by adafruit_support_carter »

Any difference if you leave out the justify call?

Code: Select all

  printer.justify('C');

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

Re: J Always Printing on Thermal Receipt Printer

Post by explora_exhibits »

adafruit_support_carter wrote:Any difference if you leave out the justify call?

Code: Select all

  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() {
}

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

Post by adafruit_support_carter »

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

What are you using for power?

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

Re: J Always Printing on Thermal Receipt Printer

Post by explora_exhibits »

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.

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

Post by adafruit_support_carter »

What about the timing of the print? Does the J appear right away? Or when call one these specific lines?

Code: Select all

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

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.

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

Re: J Always Printing on Thermal Receipt Printer

Post by explora_exhibits »

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

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

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.

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

Re: J Always Printing on Thermal Receipt Printer

Post by explora_exhibits »

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?

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

Post by adafruit_support_carter »

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

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

Re: J Always Printing on Thermal Receipt Printer

Post by rociorey »

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

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: J Always Printing on Thermal Receipt Printer

Post by adafruit_support_carter »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”