Ethernet data on 9100 port for Zebra printer (ZPL)

Hi everybody,

I would like to send data on my Zebra printer (192.168.1.80) by Ethernet (Arduino Uno + Ethernet Shield OR Arduino Yùn).

For testing, I want send this message (this message allows print a label with “HELLO”) :

^XA
^FO49,30^A0N,167,130^FDHELLO^FS
^XZ
^SP

When I send this command with the Zebra utilities on PC, the Ethernet trame is :

But my Arduino program not functionnaly…
I try with client.print, client.println and client.write with the trame in hexadecimal.
All prog ahs been executed : Serial.print → connecting, connected, end of data, disconnect.

Could you help me ?
Thank you !

My Arduino program

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(192, 168, 1, 80);  // numeric IP for Google (no DNS)
//char server[] = { 192, 168, 1, 80 };    // name address for Google (using DNS)
char data[] = {0x5e, 0x58, 0x41, 0x0d, 0x0a, 0x5e, 0x46, 0x4f, 0x34, 0x39, 0x2c, 0x33, 0x30, 0x5e, 0x41, 0x30, 0x4e, 0x2c, 0x31, 0x36, 0x37, 0x2c, 0x31, 0x33, 0x30, 0x5e, 0x46, 0x44, 0x48, 0x45, 0x4c, 0x4c, 0x4f, 0x5e, 0x46, 0x53, 0x0d, 0x0a, 0x5e, 0x58, 0x5a, 0x0d, 0x0a, 0x5e, 0x53, 0x50, 0x0d, 0x0a};

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start the Ethernet connection:
    Ethernet.begin(mac, ip);
 
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 9100)) {
    Serial.println("connected");
    // Make a HTTP request:
    //client.print(data);

    Serial.println("end of client print");
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}


void loop()
{
   if (client.connect(server, 9100)) {
    Serial.println("connected");
  }
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    //client.write(data, 48);
    client.println("^XA");
    client.println("^FO49,30^A0N,167,130^FDHELLO^FS");
    client.println("^XZ");
    client.println("^SP");
//    client.println("");
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {

    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    delay(5000);
  }
}

zebra.ino (2.67 KB)

    client.println("^XA");
    client.println("^FO49,30^A0N,167,130^FDHELLO^FS");
    client.println("^XZ");
    client.println("^SP");

This does not look like

I try with client.print, client.println and client.write with the trame in hexadecimal.

Thank you for this response.

Il try with

  • client.print("^XA");
  • client.println("^XA");
  • client.write(data, 48); assumed data is an array of char

Anybody can help me ? :smiley_cat:

In the image of the data sent from the PC you can see the CR/LF pair at the end of each line (0D/0A). The client.println() should also output these. Can you capture the output from the Arduino so that you can compare it with the output from the PC ?

Use putty and do the same command from the pc to the zebra printer and monitor it with wireshark and post the results.

Did you do a config print from the zebra printer to see if hex is enabled? I haven't used one in years but I thought they had two modes.

Hello , you cponseguiu if comonicar with the zebra ?