Hi,
is there a way to use the AdafruitThermalLibrary with the softwareSerial of the ESP8266? I'm using a nodeMCU 1.0 board, but I'm having no luck making the library working on the ESP. I have tested a nearly identical code with an Arduino UNO and the same electrical setup and it worked.
The only electrical question that I have is if it's fine to use RX and TX from 3.3V of the esp to 5V of the printer.
This is the code:
#include "Adafruit_Thermal.h"
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include "adalogo.h"
#include "adaqrcode.h"
#define TX_PIN 6 // Arduino transmit YELLOW WIRE labeled RX on printer
#define RX_PIN 5 // Arduino receive GREEN WIRE labeled TX on printer
SoftwareSerial mySerial; // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial); // Pass addr to printer constructor
void setup() {
pinMode(7, OUTPUT); digitalWrite(7, LOW);
// NOTE: SOME PRINTERS NEED 9600 BAUD instead of 19200, check test page.
mySerial.begin(9600, SWSERIAL_8N1, TX_PIN, RX_PIN, false, 256);
//Serial1.begin(19200); // Use this instead if using hardware serial
printer.begin(); // Init printer (same regardless of serial type)
// Test inverse on & off
printer.inverseOn();
printer.println(F("Inverse ON"));
printer.inverseOff();
// Test character double-height on & off
printer.doubleHeightOn();
printer.println(F("Double Height ON"));
printer.doubleHeightOff();
// Set text justification (right, center, left) -- accepts 'L', 'C', 'R'
printer.justify('R');
printer.println(F("Right justified"));
printer.justify('C');
printer.println(F("Center justified"));
printer.justify('L');
printer.println(F("Left justified"));
// Test more styles
printer.boldOn();
printer.println(F("Bold text"));
printer.boldOff();
printer.underlineOn();
printer.println(F("Underlined text"));
printer.underlineOff();
printer.setSize('L'); // Set type size, accepts 'S', 'M', 'L'
printer.println(F("Large"));
printer.setSize('M');
printer.println(F("Medium"));
printer.setSize('S');
printer.println(F("Small"));
printer.justify('C');
printer.println(F("normal\nline\nspacing"));
printer.setLineHeight(50);
printer.println(F("Taller\nline\nspacing"));
printer.setLineHeight(); // Reset to default
printer.justify('L');
// Barcode examples:
// CODE39 is the most common alphanumeric barcode:
printer.printBarcode("ADAFRUT", CODE39);
printer.setBarcodeHeight(100);
// Print UPC line on product barcodes:
printer.printBarcode("123456789123", UPC_A);
// Print the 75x75 pixel logo in adalogo.h:
printer.printBitmap(adalogo_width, adalogo_height, adalogo_data);
// Print the 135x135 pixel QR code in adaqrcode.h:
printer.printBitmap(adaqrcode_width, adaqrcode_height, adaqrcode_data);
printer.println(F("Adafruit!"));
printer.feed(2);
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
}
void loop() {
}
Many thanks!