How to connect from the Arduino board to transfer print data to the X Printer thermal printer via the RS232 module circuit

Hello,

I'm working on a project that needs to use an Arduino Uno circuit to transfer print data to an X Printe thermal printer via the RS232 module circuit.

Right now I can't get it to work, I'm connecting as shown can anyone help me find the solution?

Pins 0 and 1 are used by the serial monitor and to program the uno.

Move your connections to different pins and use SoftwareSerial().

Make sure the RS232 Tx and Rx pins are connected correctly. Those are generally pins 2 and 3 on the DB9 connectors, but which goes to which pin is not completely standardized.

void setup() 
{
Serial.begin(9600);

delay(1000);
int delTime=0; // delay between each instruction
begin(); //reset all settings
justification(0); //left side
Serial.println("Arduino");
delay(delTime);
justification(1); //middle
size(2); //big text
Serial.println("TEST V 0.2");
delay(delTime);
size(0); //small text
justification(0); //left side
color(1); //white text
Serial.println(" White text ");
delay(delTime);
color(0); //black text
Serial.println("Hello world!!!!!");
delay(delTime);
feed(1); //print 1 line below
Serial.println("Good Electronics Thermal Printer TEST");
delay(delTime);
feed(1); //print 1 line below
justification(1);
Serial.println("SIMPLE THERMAL PRINTER");
delay(delTime);
feed(1); //print 1 line below
Serial.println("CONNECTED TO ARDUINO");
delay(delTime);
feed(1); //print 1 line below
Serial.println("very very very long text in this line......");
delay(delTime);
feed(1); //print 1 line below
Serial.println("very very very long text in this line again");
delay(delTime);
feed(1); //print 1 line below
Serial.println("Printing complete!");
cut(); //cut the paper
}

void loop() 
{


}

void begin()
{
Serial.write(27);
Serial.write(64);
Serial.write(10);
}

void justification(int just)
{
Serial.write(27);
Serial.write(97);
Serial.write(just);
Serial.write(10);
}

void feed(int lines)
{
Serial.write(27);
Serial.write(100);
Serial.write(lines);
Serial.write(10);
}

void cut()
{
feed(3);
Serial.write(27);
Serial.write(105);
Serial.write(10);
}

void color(bool col)
{
Serial.write(29);
Serial.write(66);
Serial.write(col);
Serial.write(10);
}

void size(int siz)
{
Serial.write(29);
Serial.write(33);
Serial.write(siz);
Serial.write(10);
}

This code runs without error, but my Xprinter XP-350B printer can't print, why is that? help me

It could be due to the way that the lead that you are using to connect the printer is wired.

The transmit pin of the Arduino has to go to the receive pin on the printer, and
the receive pin on the Arduino to the transmit pin on the printer.

The pins in question are 2 and 3, as mentioned by david_2018 in post #4.

Sometimes you need a 'crossover' cable where pin 2 at one end connects to pin 3 at the other end (and vice versa). Sometimes you need 'straight through' connections, pin 2 to pin 2 and pin 3 to pin 3.

It depends on the way the printer is wired - Unfortunately I can't see any information on that in the printer manual.

Hello. I'm also working on a similar project. If you've made progress, could you share it with me?

Same here, any progress? Or someone know how to activate the autocut?

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