RasPiCommPlus Logo:Using the RS232 module control a thermal printer

In this tutorial we will take a look at how to control a thermal printer with the RasPiComm+ RS-232 module. The RasPiComm+ has been designed for the Raspberry Pi and is available for preorder on Indiegogo!

I'm using an Epson M-T102 printer with an Able Systems ATB 102 controller board since I had them handy. Other printers/controller boards might need different voltages or wirings, so please check the manuals and data sheets.

Required Parts

Raspberry Pi B+RS 8111284
RasPiComm+ MainboardTBA
RasPiComm+ RS-232 ModuleTBA
Thermal Printer Epson M-T102
Printer Controller Board Able Systems ATB 102
a few wires  

  1. Hardware Setup
  2. Let's get our gear in place! On the left: RS-232 module, RasPiComm+, Raspberry Pi B+. Then some cables I soldered to a Dsub9 according to the cabling requirements of the ATB102 (more about that in a minute), and on the right the thermal printer, controller board and some thermal printer paper.

    RS232 Thermal Printer Equipment
    To find out how to set up the wiring from the RS-232 module to the controller board, let's take a look at the pin-out according to the Able Systems ATB102 manual.
    RS232 pinout
    I soldered the wires to a DSub9 according to the schematics and connected them to the controller board (J2 pin, don't forget to cross the cables to make the receiving end (Rx) of the RS-232 module meet the transmitting end (Tx) of the controller board and vice versa).
    Thermal Printer Dsub9 connections
    Let's prepare the Raspberry Pi and RasPiComm+. Connect your DSub9 to the RS232 module...
    RS232 Dsub9 connector to module
    and slide the RS232 module into the RasPiComm+ module slot or your choice. I'll use module slot 1.
    RS232 to RasPiComm+
    Next up we'll power up the controller board, feed the printer some paper and test it. The manual of the ATB102 controller board specifies 5-8V to be connected on J1, pins 1 (+) and 2 (GND) (right side of picture).
    The lone cable on the bottom left part of the ATB102 is connected to the GND (pin 4) of J3. According to the ATB102 manual we can short it to pin 5 to activate paper feed..
    paper feed
    and double-tap it to print a self-test message.
    printer diagnose
    So far so good, the hardware seems to be functional! Let's boot up the Pi and set up our RasPiComm+ firmware and drivers!

  3. Software Setup
  4. If you have read my tutorials so far, you already know the drill! If you haven't already, download the Setup-Script:

    wget downloads.amescon.com/rpc+setup.sh
    and make it executable:
    chmod +x rpc+setup.sh
    Then execute the automated setup
    sudo ./rpc+setup.sh
    Starting the Setup
    The setup recognizes the connected modules (in this case RS232 in module slot #1). Prompt it to start firmware configuration
    Server building Firmware
    If not present in the local cache the firmware is requested from our server and transferred to your Raspberry Pi. Confirm firmware update
    Setup complete!
    Setup complete

  5. Using the RS232 module to print a line
  6. Let's check the installed firmware for module slot 1. Nope, it's not necessary for this tutorial, but hey, this is supposed to be educational, right?

    cat /proc/rpc+/module1/firmware_type
    Firmware type
    RS232, right. Let's find out how to adress it.
    cat /proc/rpc+/module1/type
    The RS-232 module offers 2 TTY-devices, nice! Those will be available under /dev/ttyRPC+X, whereas X depends on the module slot and on how many serial ports are connected.
    Module Slottty
    Slot 1/dev/ttyRPC+0
    Slot 2/dev/ttyRPC+2
    Slot 3/dev/ttyRPC+4
    Slot 4/dev/ttyRPC+6

    In our example the RS232-module is located in slot 1, which means we can adress it with /dev/ttyRPC+0.
    Pro Tip: The RS232 module can not only be used as 1xRS-232+Hardware-Handshake, but also as 2xRS-232 in which case we would use both ttyRPC+0 and ttyRPC+1 for communications!
    So now that we have found which tty-device we need to use for our printer, let's print something! I will send some text to the printer using the echo command, but you could also use screen (check out the GSM tutorial for reference, we use the screen command there!)
    Normally the echo-command would send the string that I type to the screen. Since I do not want it to be displayed on the screen, I will simply pipe (">") the echo-command to my ttyRPC+0 device that is connected to the printer.
    echo "RasPiComm+ printer test" > /dev/ttyRPC+0
    We'll need to activate the line feed a bit to see the printed text. We can either connect the pins 4&5 on our controller board, or simply enter
    echo "" > /dev/ttyRPC+0
    a few times, thus sending an empty string to the printer.
    And the whole picture:
    printout whole view

  7. Using the RS232 module to print a file
  8. I've got some lyrics in a file named "rhcp.txt" in my home folder (~) on the Raspberry Pi. Let's try printing those! To show the content of a file on screen we can use the cat-command.

    cat ~/rhcp.txt
    rhcp screen
    Since we don't want the lyrics to show up on the screen but rather want our printer connected to the RS232 module to handle it, let's pipe it to the RasPiComm+ TTY-device again.
    cat ~/rhcp.txt > /dev/ttyRPC+0
    rhcp printout
    You are not restricted to files when using the ">" pipe to the TTY device. Try
    date > /dev/ttyRPC+0
    date printout
    uname -a > /dev/ttyRPC+0
    uname printout

Additional Resources

If you have questions or feedback, please check out the following Resources:

RasPiComm+ CampaignIndieGoGo
RasPiComm+ Support ForumOfficial RasPiComm+ Support Forum
Twitter Github Tumblr PInterest Youtube