Hello,
I am using a EB5820 Thermal Printer with the Adafruit_Thermal library. When running the example from Adafruit on an Arduino board, everything works fine. When I'm running it on doit esp32 devkit v1 board, the function call 'printer.begin()' causes the printer to print garbage characters. It prints '8' and then on a new line it prints 'x('. I have tried using HardwareSerial instead of SoftwareSerial, but it makes no difference. Has anyone dealt with this before? Thanks
Edit: The printer works correctly. It's just that it prints the '8' and then 'x(' on a new line when 'printer.begin()' is executed. If I comment out that call, I don't see the garbage characters but I'm unable to use all printer functionalities such as inverse printing, temp setup etc.
/*------------------------------------------------------------------------
Example sketch for Adafruit Thermal Printer library for Arduino.
Demonstrates a few text styles & layouts, bitmap printing, etc.
IMPORTANT: DECLARATIONS DIFFER FROM PRIOR VERSIONS OF THIS LIBRARY.
This is to support newer & more board types, especially ones that don't
support SoftwareSerial (e.g. Arduino Due). You can pass any Stream
(e.g. Serial1) to the printer constructor. See notes below.
------------------------------------------------------------------------*/
#include "EEPROMHandler.h"
#include "Adafruit_Thermal.h"
// Here's the new syntax when using SoftwareSerial (e.g. Arduino Uno) ----
// If using hardware serial instead, comment out or remove these lines:
#include <SoftwareSerial.h>
#define TX_PIN 16 // Arduino transmit YELLOW WIRE labeled RX on printer
#define RX_PIN 17 // Arduino receive GREEN WIRE labeled TX on printer
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial); // Pass addr to printer constructor
// Then see setup() function regarding serial & printer begin() calls.
// Here's the syntax for hardware serial (e.g. Arduino Due) --------------
// Un-comment the following line if using hardware serial:
//Adafruit_Thermal printer(&Serial1); // Or Serial2, Serial3, etc.
// -----------------------------------------------------------------------
void printSomething(String webSender, String webMessage) {
// This line is for compatibility with the Adafruit IotP project pack,
// which uses pin 7 as a spare grounding point. You only need this if
// wired up the same way (w/3-pin header into pins 5/6/7):
//pinMode(7, OUTPUT); digitalWrite(7, LOW);
// NOTE: SOME PRINTERS NEED 9600 BAUD instead of 19200, check test page.
mySerial.begin(9600); // Initialize SoftwareSerial
//Serial1.begin(19200); // Use this instead if using hardware serial
printer.begin(); // Init printer (same regardless of serial type)
delay(1L); // Sleep for 1 seconds
printer.wake(); // MUST wake() before printing again, even if reset
printer.setDefault(); // Restore printer to defaults
//printer.println("");
// The following calls are in setup(), but don't *need* to be. Use them
// anywhere! They're just here so they run one time and are not printed
// over and over (which would happen if they were in loop() instead).
// Some functions will feed a line when called, this is normal.
// Font options
printer.setFont('A');
printer.boldOn();
//printer.setHeatConfig(11, 200, 40);
printer.flush();
//printer.setSize('M');
// Test inverse on & off
//printer.println ("");
printer.println("New Message From: " + webSender);
printer.println("--------------------------------");
printer.println(webMessage);
printer.println("--------------------------------");
printer.feed(4);
printer.sleep(); // Tell printer to sleep
delay(3000L); // Sleep for 3 seconds
printer.wake(); // MUST wake() before printing again, even if reset
printer.setDefault(); // Restore printer to defaults
}