Go Down

Topic: Thermal printer isn't Printing Images (Read 5890 times) previous topic - next topic

I am using a 2 inch thermal printer with arduino uno r3. I used adafruit library for thermal printer i.e. "Adafruit_Thermal.h". With this library the text (Strings)
are printing fine, but when there comes a bitmap image, the printer just prints some garbage dots. Guide me how to fix it.


You're probably going to need to post your code.

Feb 07, 2013, 01:25 pm Last Edit: Feb 07, 2013, 01:46 pm by AWOL Reason: 1

You're probably going to need to post your code.

Code is as follows:
Code: [Select]

#include "SoftwareSerial.h"
// If you're using Arduino 23 or earlier, uncomment the next line:
//#include "NewSoftSerial.h"

#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include <avr/pgmspace.h>

int printer_RX_Pin = 5;  // This is the green wire
int printer_TX_Pin = 6;  // This is the yellow wire

Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);

void setup(){
 pinMode(7, OUTPUT); digitalWrite(7, LOW); // To also work w/IoTP printer

 // The following function calls are in setup(), but do not need to be.
 // Use them anywhere!  They're just here so they're run only one time
 // and not printed over and over.
 // Some functions will feed a line when called to 'solidify' setting.
 // This is normal.

 // Test inverse on & off
 printer.println("Inverse ON");

 // Test character double-height on & off
 printer.println("Double Height ON");

 // Set text justification (right, center, left) -- accepts 'L', 'C', 'R'
 printer.println("Right justified");
 printer.println("Center justified");
 printer.println("Left justified");

 // Test more styles
 printer.println("Bold text");

 printer.println("Underlined text ");

 printer.setSize('L');     // Set type size, accepts 'S', 'M', 'L'
 printer.println("Large"); // Print line

 printer.setLineHeight(); // Reset to default

 // Barcode examples
 // CODE39 is the most common alphanumeric barcode
 printer.printBarcode("ADAFRUT", CODE39);
 // Print UPC line on product barcodes
 printer.printBarcode("123456789123", UPC_A);

 // Print the 75x75 pixel logo in adalogo.h
 printer.printBitmap(adalogo_width, adalogo_height, adalogo_data);

 // Print the 135x135 pixel QR code in adaqrcode.h
 printer.printBitmap(adaqrcode_width, adaqrcode_height, adaqrcode_data);

 printer.sleep();      // Tell printer to sleep
 printer.wake();       // MUST call wake() before printing again, even if reset
 printer.setDefault(); // Restore printer to defaults

void loop() {

The output print iss attached...
Text is fine but image is returned as garbage dots... :(

Moderator edit "You're probably going to have to post your code with [font=Verdana][[/font]code][font=Verdana][[/font]/code] tags"


What thermal printer are you using?

What thermal printer are you using?

Its chinese made printer. Model number is PT-48b.


Do you have a link to the datasheet?

What I am looking for is whether this printer supports graphic characters. You may be getting garbage because it doesn't.

Do you have a link to the datasheet?



Thanks. The PDF icon doesn't work, but it did lead me to another question. Are you driving the signal levels on that flat cable directly with your arduino or using an interface board in between? Your code doesn't look like it is driving everything directly.

Are you driving the signal levels on that flat cable directly with your arduino or using an interface board in between?

A interface board is available which is actually the logic level translator between printer and arduino. 

The PDF icon doesn't work.

Here the manual is attached.


A thermal printer is readily capable of printing images,   but the software controlling it may not me.

In fact,  any printer can print images,  except the ones based on typewriter technology which have
actual metal printing elements representing the letters and numbers.


Here the manual is attached.

Thank you. I see that it has a bit image mode, now just need to look at the adafruit library to make sure it is compatible and putting this into the correct mode.


Looking at the datasheet and looking at the adafruit library, it doesn't look like the library is directly compatible with your board. To get into bitmap mode, you need to send a specific command. The reason it works with everything else is because the printer is set at defaults at power up and accepts your text.

Page 14 of the datasheet describes how to use the bitmap mode. You have to send ESC (27) then * (42) then a mode of 8 or 24 dots, and then your actual bitmap information. I don't see the library sending all those commands.

This was only a quick look, but I don't see it controlling the printer in the same way as the datasheet. However, some of the commands are the same, but those are for text stuff. The barcode and bitmap routines are not doing things the same way.

Can you tell me how to send the command???
I am sending the commands as:
printer.writeBytes(27,42,1);//ESC * m
printer.writeBytes(100,2);//n1 n2
for(int i==0;i<=200;i++)
printer.writeBytes(data);//d1 d2 .... dk
where the data is stored in program memory in the same format as in adafruit library example.
The code is successfully compiled and uploaded on arduino but the output is same as I have shown you above.(The data is also same)
I am stuck here... :(

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131