Controlling Thermal Printer with Arduino UNO

Hi,

I am making an art project that requires me to control a thermal printer with an Arduino UNO. The printer I am using is a RONGTA RP820-US mini receipt printer. Please see below test page with printer information. BAUD rate 19200.

At first, I tried using a RS 232 to serial adapter to communicate. But I wasn't able to print anything. Please see below circuit diagram and code.

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

// Set up a new SoftwareSerial object
SoftwareSerial mySerial (rxPin, txPin);

void setup()  {  
    // Set the baud rate for the SoftwareSerial object
    mySerial.begin(19200);
    // Print data to the transmit pin    
}

void loop() {
  mySerial.println("SELFTEST");
  delay(100);
}

The TX LED on the adapter and the Arduino would be flashing (which indicates the transmission of data), but the thermal printer would not print. I tried switching the RX and TX wires, but nothing changed.

I looked up a diagram of the serial port (see below). I decided to plug my a wire directly from my Arduino TX pin into the TX pin of the printer (essentially bypassing the adapter).

205890c9f4e7d58fa8242ad716e6ba88c08533dd

This did get some result, as the printer began printing something -- however, this was gibberish text. I'm not sure if this is a viable solution and I just need to change some of my code, or whether persevering with the RS232 to serial adapter is the best bet.

I'd appreciate any advice or ideas.

Thank you!

Always connect an Rx to a Tx. If You put Your ear to another ear, You will not hear anything.... Random testing might put circuitry in danger.

A link to the datasheet, technical manual, of the printer might be helpful.

Please confirm that you have printed the manual PDF and you have set the DIP switches, SW-7 and SW-8 to the Baud rate matching the Arduino.

Then your program MUST watch the RTS line to see if the printer can accept data from your Arduino. Hi = busy and LO = ready. This is also at RS-232 voltages. Does your adapter support another RS-232 line for conversion to TTL?

USE EXTERNAL POWER. The printer needs a LOT of current. Share the ground pin with Printer, Power supply and Arduijno.

Use VCC, GND, TX, RX, RTS.
See this video, minute 1:25...

Hi everyone. Thank you for your help so far. To answer your questions:

I have tried switching the Tx and Rx pins in case I have them the wrong way. No change.

The Baud rate of the printer matches that of the Arduino (19200). I have tried changing it to 9600 using the switches, but still no action. Basically, Baud rate doesn't seem to be the issue.

Here is the link to the RS 232 to serial adapter: https://core-electronics.com.au/rs232-to-serial-converter.html?gad_source=1&gclid=CjwKCAjw17qvBhBrEiwA1rU9w8ciFtQk8rXsyqfvVgsBo9cnkBXgi8a02zc1NGLCoNFqJMjz2-e5pBoClGcQAvD_BwE

I don't think it has an RTS line so I can test if it's busy or not.

The printer and Arduino have power. The adapter has an usb input (maybe for power), but I haven't been using it as the lights come on when it is connected to GND and 5V of the Arduino.

On this adapter, the Tx and Rx lights flash depending on which way the cables are. But nothing seems to get through the printer.

Cheers

Use external power for the printer.

That printer uses a printing protocol from 50-60 years ago. Strange for something so new.

You have two possible ways to program your Arduino to send bytes to the printer.

  1. after each byte sent to the printer, you can see if there is a byte to be read from the printer. That byte will ONLY be a XON or an XOFF character. See your ASCII chart for the actual character or hex value. Those are the ONLY character you will see from that printer. They mean you can send more bytes or you must stop sending until you receive an XON character.
  2. You can not use the printer TX to adapter RX connection, but instead connect the printer's RTS line to the adapter RX pin in order to convert RS-232 to TTL. Connect the adapter RX to any digital pin on your Arduino. Then program the Arduino to check that pin for high or low after each byte is sent to the printer. If low is found, you must not send another byte until that pin goes high.
    The choice is which of the two are going to be best for your programming. They are equivalent logically.

Back in the day, printer documentation told how many characters the printer buffer could hold before an XOFF was sent. But the document for this printer does not tell us that, so we have to assume the buffer can only hos one byte.

The product linked does not appear to have a USB input, so is that the right product or what?

a7

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