Hello,
I Would like to use a thermal printer with my Arduino mega using a MAX232 IC, attached my schematic circuit.
I can print normally, Here is my sketch :
#include <SoftwareSerial.h>
#include <Console.h>
// ASCII codes used by some of the printer config commands:
#define ASCII_TAB '\t' // Horizontal tab
#define ASCII_LF '\n' // Line feed
#define ASCII_FF '\f' // Form feed
#define ASCII_CR '\r' // Carriage return
#define ASCII_DLE 16 // Data Link Escape
#define ASCII_EOT 4 // End Of Transmission
#define ASCII_DC2 18 // Device Control 2
#define ASCII_ESC 27 // Escape
#define ASCII_FS 28 // Field separator
#define ASCII_GS 29 // Group separator
#define rxPin 8
#define txPin 9
SoftwareSerial Thermal(rxPin, txPin);
void setup()
{
pinMode(txPin, OUTPUT);
pinMode(rxPin, INPUT);
Thermal.begin(115200);
// initialize serial communication:
Bridge.begin();
Console.begin();
}
void loop() // run over and over again
{
//Thermal.getPaperStatus(); // get the current status of the Thermal printer
Thermal.write(ASCII_DLE);
Thermal.write(ASCII_EOT);
Thermal.write(21);
while (Thermal.available())
{
Console.println(Thermal.read(), HEX);
}
delay(1000); // waits for a second
if (Console.available() > 0) {
char c = Console.read();
Console.println(c);
if (c == '\n') {
Thermal.println("Hello World!");
Thermal.write(ASCII_FS);
Thermal.write(0xC0);
Thermal.write(0x34); //cut&feed
}
}
}
here is the user manual:
TG2460H
and the commands manual:
TG2460H commands manual
The problem is I can't read data from the printer although the RX Led blinks.
I tested the printer with a windows application and I could read data normally.
I do not know where is the problem, thank you for your help.
