Arduino Uno and Mini Thermal Printer with C# windows application

Hi,

As you can see in attachment, I tried to making a mini thermal printer application using the adafruit github thermal printer (GitHub - adafruit/Adafruit-Thermal-Printer-Library: Arduino Library for Small Thermal Printers) example and my project a little bit as differently( my project working with windows application). These projects works as well but I wonder, how do I use "printer.printBarcode" (code128 or any other barcode types) value replacing to "printer.println" for alphabetical character( as string or char etc. ) in arduino side? As be clearly when I send a text message from windows application to arduino, it giving output as barcode format on thermal printer.

Thanks.

AdaFruit.zip (49.4 KB)

You will have to post your code here if you want me to look at it. I don't want to clutter my PC with unknown ZIP files.

If your question is about the internals of the Adafruit library you should probably be asking Adafruit for advice.

Is this a problem with an Arduino program?

Or can you do things OK with the Arduino but the problem is sending data from C#?

...R

Fristly, thanks for your reply :slight_smile:

C# side works well . I guess, my issue from arduino side. How do I taking barcode output from thermal printer like code128 or similar (which one is best) for character values.

printer Mini Thermal Receipt Printer : ID 597 : $49.95 : Adafruit Industries, Unique & fun DIY electronics and kits

//c# side
using System;
using System.Windows.Forms;
using System.IO.Ports;
namespace AdaFruit
{
    public partial class Form1 : Form
    {
        SerialPort port;
        public Form1()
        {
            InitializeComponent();

            port = new SerialPort();
            port.PortName = "COM4"; 
            port.BaudRate = 9600; 
            port.Open(); 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Replace(" ", "") != "")
            { 
                port.Write(textBox1.Text);
            }

        }


    }
}
arduino.ino

#include "Adafruit_Thermal.h"
#include "SoftwareSerial.h"
#define TX_PIN 6 
#define RX_PIN 5 

SoftwareSerial mySerial(RX_PIN, TX_PIN); 
Adafruit_Thermal printer(&mySerial); 
void setup() {

  Serial.begin(9600); 
  
  mySerial.begin(19200); 
 
  printer.begin();      
 
}

void loop() {
  String incomingText;
     while(Serial.available()) {
      incomingText = Serial.readString();
      printer.println(incomingText);
   
        }
}

recepkirman:
C# side works well . I guess, my issue from arduino side. How do I taking barcode output from thermal printer like code128 or similar (which one is best) for character values.

I don't understand this at all.

How is the printer sending barcode values? I thought you wanted to print the barcode?

I have no idea what code128 means

Is the printer connected to the Arduino or to the PC?

If it is connected to the Arduino have you tried a simple program to print stuff without taking input from the PC?

Have a look at Serial Input Basics

Using the String (capital S) class can cause problems in the small memory of an Arduino. Use C strings (small s) which are char[] arrays terminated by 0.

...R

Sorry for my english.

Yes, I want print barcode and code128 is just a simple example for giving a barcode type. Printer connected arduino uno. I tried only adafruit's github example. I'm reading your serial input basics topic :slight_smile:

thanks.

I have never tried printing barcodes.

I'm guessing you need a library that can take input characters and produce the output to print a barcode - or is that capability already included in the printer?

I suspect that producing raster data for a printer would be hard work for an Arduino.

What does the adafruit example program do?

...R