Skip to content
September 29, 2011 / Mr Megahertz

ESC/POS Thermal Printer and Mono (or .Net)

Recently, I found small thermal printers sold online, like the Sparkfun’s one. (You may find these en eBay too.)  To communicate with these printers you will need a serial link, working at TTL levels.

I saw an Arduino lib on Blidr blog, but I’ve got a standard FTDI board and I wanted my printer to work with it.

So, I made ThermalDotNet: a .Net class to use these thermal printers.

 

First, the FTDI board to thermal printer wiring diagram (hand drawn, yay! \o/):

Printing (in C#) takes a few lines of code :

...
using System.IO.Ports;
using ThermalDotNet; //Don't forget to add the dll reference
...
// Replace /dev/tty with the name of your serial port.
// Can be COM1, COM2... on Windows, /dev/ttyUSB0 on Linux.
SerialPort printerPort = new SerialPort("/dev/tty", 9600);

// Connection to the printer
ThermalPrinter printer = new ThermalPrinter(printerPort); 

printer.WakeUp();   // Let's wake up the printer
printer.WriteLine("Hello World");
printer.LineFeed(); // Feed paper
printer.Sleep();    // Save some energy
Console.WriteLine("Printer is now offline.");
printerPort.Close();

At the moment, theses features are supported :

  • Simple text and standard text styles supported. (Bold, double size, reverse printing…)
  • Barcodes support
  • Image printing support (must be 384px wide)
  • Printer configuration support (heating time, speed, etc.)

You must have a good power supply to make this printer work properly, mine is a cheap ‘5V – 2A’ supply but its voltage falls down to 4.5V when the printing line needs a lot of black.

The workaround is to heat less dots at a time: by default 64 dots are heated up. I reduced this number to 16 in the printer configuration.

ThermalPrinter printer = new ThermalPrinter(serialPort);
printer.SetPrintingParameters(2,220,1);

or

ThermalPrinter printer = new ThermalPrinter(serialPort,2,220,1);
// (2+1*8) dots   = 24 dots heated up at a time (instead of 64)
// 220*10 µs      = 2200 µs of heating time (instead of 800 µs)
// 1*10 µs        = 10 µs of heating interval (instead of 20 µs)

In compensation, the printer is slower. If you need a fast printing, get a good 9V – 2A power supply!

More to come…

About these ads

4 Comments

Leave a Comment
  1. Adam Meyer / Sep 29 2011 7:12 pm

    Awesome!

  2. enlinea777 / Oct 25 2012 5:10 am

    Hello dear,
    I have the printer and FTDI
    download the project, still does not understand how to compile or run the code in windows
    Mono developer but I have not found says “ThermalDotNet”
    I can do.
    I am new to mono, but I program in windows and linux with ubuntu.
    Could you help me?

    • Oryx / Oct 31 2012 8:05 pm

      Check that ThermalDotNet is in the list of references. :)

  3. Ciftci / Apr 6 2013 3:21 pm

    wooow just great man, but i could not find the paper cut function or the drawkicker

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 25 other followers

%d bloggers like this: