Arduino and serial POS Printer

Hello,

I would like to connect my Arduino to an POS thermal printer with serial cable, I tried with only RX, TX and GND, It work but the printer print weird characters !! it's because I not used MAX323 converter ?

If so, it's not complicated to make it?

Thank you

it’s because I not used MAX323 converter

Quite possibly, but without data on the device who knows?

I am sorry, I don’t understand

kiman26:
I am sorry, I don't understand

You are the ONLY one who can see what kind of POS (piece of sh*t?) printer you want to connect to the Arduino. Is it too difficult to understand that you need to share that information?

You should post a link to the datasheet for the printer you want to use.

If it uses RS232 voltage levels you need to use a MAX232 converter to protect your Arduino from damage and to make sure that communication happens.

It may also be that the printer has a choice of character sets and you have not chosen the appropriate one.

...R

You can verify it in the commands manual of the printer, “attached in this post”

I used these code :

#include <SoftwareSerial.h>

SoftwareSerial myserial(10, 11); // RX, TX

void setup()
{
Serial.begin(115200);
}

void loop()
}
 myserial.print(27);
 myserial.print(75));
 myserial.print(1);
}

Thank you for your help

578-772000000011_1.50.pdf (1.14 MB)

That is a very long document (I hope you have read it carefully - seriously) but it is only part of the story. You also need to post a link to the document about the hardware connection.

...R

Using a SoftwareSerial instance without having called begin() is pointless.

oh sorry, here is my code:

#include <SoftwareSerial.h>

SoftwareSerial Thermal(10, 11); // RX, TX

//le bouton est connecté à la broche 2 de la carte Adruino
const 
int led = 7;
int bouton = 4;
int etatBouton;
int ESC = 27;
int CMD1 = 75;
int ON = 1;
void setup()
{
pinMode(led, OUTPUT);
pinMode(bouton, INPUT);
etatBouton = HIGH;
digitalWrite(led,LOW);
digitalWrite(bouton,HIGH);
initPrinter();
}

void initPrinter()
{

 Thermal.begin(115200); // to write to our new printer
 Thermal.print(ESC);
 Thermal.print("@");
 }
 
void loop() 
{
etatBouton = digitalRead(bouton);
if (etatBouton == HIGH) //test si le bouton est OFF
    {
    digitalWrite(led,LOW);
    }
    else  //test si le bouton est OFF (donc BAS)
    {
      //set speed
 Thermal.write(27);
 Thermal.write(120);
 Thermal.write(1);
//Print
 Thermal.write("TEST PRINT");
 Thermal.write(10);
 //Print
 Thermal.write(27);
 Thermal.write(100);
 Thermal.write(1);
 //cutting
 Thermal.print(27);
 Thermal.write(105);
    digitalWrite(led,HIGH);
    delay(1000);
    }
}
Thermal.begin(115200);

Start testing with a more realistic 9600 baud. SoftwareSerial is slow.

If you need 115200 baud then you need a Mega, Leonardo or Micro with a spare HardwareSerial port.

...R

The default speed of the printer is 115200, and Yes I make this test with mega.

kiman26:
The default speed of the printer is 115200, and Yes I make this test with mega.

Trying to program this printer without reading the technical hardware manual is also pointless.

You think I try to program the printer without read the technical hardware manual ?

kiman26:
You think I try to program the printer without read the technical hardware manual ?

There is not much evidence in this Thread that you have done so. For example, I have seen nothing like
"It says xxxx in the manual on page YYY and I don't understand if that means I should do A or B"

And we are still waiting for you to post a link to it.

...R

 Thermal.print(ESC);

 Thermal.write(27);
 Thermal.write(120);
 Thermal.write(1);

You really need to understand the difference between print() and write() and when to use each.

The default speed of the printer is 115200, and Yes I make this test with mega.

What are the 4 hardware serial ports doing, then?

It's not work with all 4 hardware serial in mega :(.
But after I used max232 chip it working now.

Thank you