Monday, February 15, 2010

Arduino and the thermal printers

I've been browsing through the web and noticed that there isn't much support for thermal printer especially for Epson branded or the ESC POS printer types using Arduino boards. Therefore, I will provide some useful insights on how to get a thermal receipt printer working using ESC POS codes with the Arduino...


Here's what you need:
Step 1
Get hardware

-Arduino
-RS232 level converter (Maxim 232 chip or equivalent and assembled with preferrably an RS232 male connector)
-Epson printer or ESC POS compatible printer (Citizen, etc.)
- cable to connect your printer to the RS232 converter.


To make an RS232 converter all you need is:
- a Maxim232 or alternative equivalent,
- 4 .1uF Capacitors
- a breadboard or pcb board to solder with wire connectors.

Go find datasheets for the converter chip of you choice and follow the pin numbers for connecting the capacitors and for voltage input and ground and viola, you got one.

Step 2
Write some program. Fortunately I have developed a sample program for you.(below) :)

void setup ()
{
Serial.begin(19200) //Epson default printer settings for baud rate for parallel type printer
}

void loop() //looping sequence
{
Serial.print(0x1B,BYTE); //ESC POS command
Serial.print('@'); //ESC POS initialize followed after command
Serial.print("Hola Epson"); //Print "Hola Epson" to buffer
Serial.print(0xA,BYTE); //Print and Line Feed from Buffer

}
//*** Upload you program

Step 3
Put it all together.

Make or purchase an RS232 level converter. Connect the Arduino 5V and Ground to the RS232 level converter so that it can communicate with the printer. Then pray it all works.




Final Result (Pics)


The Printer here is a parallel printer and I am using a parallel to serial cable to communicate with Arduino directly.


8 comments:

  1. hey ive just gathered an old cash machine from a dumpster.
    it has a m-t102 printer inside and i thought the best thing was to only take that thing out.
    i forgot the driver board. (esc-pos controller) so now i only have a lot of red wires (about 12 from the thermal stuff) and like 6 wires from the motor and other stuff.
    is there any possibilities to use this directly connected to the arduino or is it best to gain the driver board.

    ReplyDelete
  2. thanks your tutorial!
    it's usefull.

    ReplyDelete
  3. If you would like to get more tutorials or tutorial ideas, please visit electrojoystick dot com.

    ReplyDelete
  4. Nice! This will really come in handy for a project i'm about to start. Any ideas on how to print an image, like a receipt header, to one of these printers via arduino?

    ReplyDelete
  5. I have a question:
    In the datasheet of some POS printer, when we use Serial interface, the handshake types usually are DTR/DSR. I wondered if we can use only 2 wires: RX and TX? are there any problem?

    Pls give me an advice!
    Thanks.

    ReplyDelete
  6. Hi,

    I'm trying to do something a bit similar but i need to listen to the data on all the pins. If you could give me any advice it'd be appreciated

    stefankoshiw306 'at' gmail.com

    ReplyDelete
  7. I have a question
    Is this command will work on every printer that supports esc/pos or it will be different for each printer?

    ReplyDelete
  8. thanks for your tutorial...
    it's usefull!!
    ----------------------

    ReplyDelete