Arduino Due thermal printer printing gibberish

My ardunio due is connected to the adafruit thermal printer and is printing gibberish when I run basic code, but the self test page and serial monitor entries print just fine so I think I have my connections mixed up. I am using the programming port connected to my MacBook and my RX is in 0 and my TX is in 1. Here is the code:

#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include "test5.h"

//#define TX_PIN 1 // Arduino transmit  YELLOW WIRE  labeled RX on printer
//#define RX_PIN 0 // 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
Adafruit_Thermal printer(&Serial1);
void setup() {
//  pinMode(7, OUTPUT); digitalWrite(7, LOW);

//  Serial.begin(19200);  // Initialize SoftwareSerial
  Serial1.begin(19200); // Use this instead if using hardware serial
  printer.begin();        // Init printer (same regardless of serial type)

  // Font options
  printer.setFont('A');

  printer.inverseOff();
  printer.doubleHeightOff();

  // Set text justification (right, center, left) -- accepts 'L', 'C', 'R'
  printer.justify('L');
  printer.boldOff();
  printer.setSize('S');

  printer.setLineHeight(); // Reset to default

  // Print the bitmap image:
//  printer.printBitmap(test5_width, test5_height, test5_data);
  printer.println("caption goes here");
  printer.feed(2);

  printer.sleep();      // Tell printer to sleep
  delay(3000L);         // Sleep for 3 seconds
  printer.wake();       // MUST wake() before printing again, even if reset
  printer.setDefault(); // Restore printer to defaults
}

void loop() {
}

I need all the help I can get. Working with Arduino is fun but I am a beginner and this is for my capstone project. I was able to get everything working when I used the UNO R# but it didn't have enough memory for my prints so I switched to the Due.

Hello ozioma

I´ve a question only:

How and where the baudrate for the printer is set?

I believe this line is setting the baudrate to 19200 which is the baudrate shown on the text print page.

  Serial1.begin(19200); // Use this instead if using hardware serial

Those aren't Serial1 pins.

I've tried the different serials and none of them worked either. The wires are still the same but I changed the code to just serial still prints gibberish when the code is run

I asked for help on reddit and someone mentioned that serial connections need to be crossed. I did this and changed my code and pin connections to serial1 instead of serial and all works well! I hope this can help someone who's working on a similar project and is a complete beginner like I am. It was hard for me to find relevant forums posts/understand the vocabulary of some of these tools.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.