Printing label Brother QL-820NWB node-red

Hi there,
I'am Marnick Bijlsma and i'am trying to connect my Brother QL-820NWB printer with node-red.
I tried to do this with Esc/P commands via port 9100. I can see that its connected with the 9100 port and its own IP adress. Also i could make a connection with commandline (telnet). But it won't print anything with my flow. In my oppinion the Esc/P commands are right. I dont see whats wrong with it. Can anyone give me tips?

Kind regards!
Marnick Bijlsma

[
    {
        "id": "b87b6183948ec679",
        "type": "inject",
        "z": "f62543fa36a37222",
        "name": "",
        "props": [
            {
                "p": "address",
                "v": "00:13:A2:00:01:02:03:04",
                "vt": "str"
            },
            {
                "p": "engineer",
                "v": "Morgan",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 550,
        "y": 400,
        "wires": [
            [
                "e5dea416fe28b673"
            ]
        ]
    },
    {
        "id": "e5dea416fe28b673",
        "type": "function",
        "z": "f62543fa36a37222",
        "name": "",
        "func": "var PTOUCH_ESC_P_MODE = Buffer.from([0x1b, 0x69, 0x61, 0x00]);\nvar INITIALIZE = Buffer.from([0x1b,0x40]);\nvar LARGE_QR = Buffer.from([0x1b,0x69,0x51,0x0C,0x02,0x00,0x00,0x00,0x00,0x02,0x00]);\nvar AUTO_LENGTH = Buffer.from([0x1b,0x69,0x6c,0x00,0x00]);\nvar LEFT_MARGIN = Buffer.from([0x1b, 0x24, 0x3C, 0x00]);\nvar FONT = Buffer.from([0x1B, 0x6B, 0x00]);\nvar FONT_SIZE = Buffer.from([0x1B, 0x58, 0x34]);\n\nvar payload = [];\npayload.push(PTOUCH_ESC_P_MODE); //Command to put printer in ESC P command mode\npayload.push(INITIALIZE); //Command to initialize printer for commands\n\n//QR Code Bytes\npayload.push(LARGE_QR); //QR code config bytes 12 dots per per cell, Model 2, auto input\npayload.push(Buffer.from(msg.address+\"\\\\\\\\\\\\\", \"utf-8\")); //Payload to embed in QR Code.  Note requires three \\ to end QR payload\n\n//Text bytes\npayload.push(AUTO_LENGTH); //Auto set length of label\npayload.push(LEFT_MARGIN); //1\" left margin to allow for QR code on left side of label\npayload.push(FONT); //Helsinki font\npayload.push(FONT_SIZE); //12pt font size\npayload.push(Buffer.from(msg.address.substring(0,11)+\"\\n\", \"utf-8\"));  //print first half of address on top line\npayload.push(LEFT_MARGIN); //1\" left margin to allow for QR code on left side of label\npayload.push(Buffer.from(msg.address.substring(12,23)+\"\\n\", \"utf-8\"));  //print second half of address on second line\npayload.push(LEFT_MARGIN); //1\" left margin to allow for QR code on left side of label\npayload.push(Buffer.from(\"QC: \"+msg.engineer, \"utf-8\")); //print quality control engineer on third line\npayload.push(Buffer.from([0x0c])); //execute print command\n\nmsg.payload = Buffer.concat(payload);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 720,
        "y": 400,
        "wires": [
            [
                "7f0aa37e96206837",
                "ef48ddbd41bc0fe0"
            ]
        ]
    },
    {
        "id": "7f0aa37e96206837",
        "type": "tcp out",
        "z": "f62543fa36a37222",
        "name": "",
        "host": "192.168.2.15",
        "port": "9100",
        "beserver": "client",
        "base64": false,
        "end": true,
        "tls": "",
        "x": 940,
        "y": 400,
        "wires": []
    },
    {
        "id": "ef48ddbd41bc0fe0",
        "type": "debug",
        "z": "f62543fa36a37222",
        "name": "debug 32",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 940,
        "y": 300,
        "wires": []
    }
]

Hello Marnick, welcome to the forum.
I would suggest that you send something simpler to the print for testing purposes. The best choice would be the "Status information request", so you can see in a debug node the printer´s response.

ESC i S Status information request
ASCII: ESC i S
Decimal: 27 105 83
Hexadecimal: 1B 69 53

Hello Andrei! Thank you for the respons!

I tried what you said but i dont get any response from the printer.
Is there a possibility that its the wrong port? Or do you have other suggestions?

below you can see what i sended to the printer. Its connected with port 9100.

image

Kinds regards,
Marnick

Try setting the buffer directly into msg.payload (I would copy and paste a demo for you but you posted a picture instead of code)

Hello Steve!

I tried to put the buffer directly into the payload but nothing happens. The only thing
i could see that the printer was 'busy' after resending it 3 times. But i dont get the response of the status.

Here below is my example.

[
    {
        "id": "e5dea416fe28b673",
        "type": "function",
        "z": "f62543fa36a37222",
        "name": "",
        "func": "//var ESC_i_S = Buffer.from([0x1b, 0x69, 0x53]);\n\n\n\n//var payload = [];\n//payload.push(ESC_i_S); //Command to put printer in ESC P command mode\n\nmsg.payload = [0x1b,0x69,0x53];\n\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 980,
        "y": 520,
        "wires": [
            [
                "7f0aa37e96206837",
                "ef48ddbd41bc0fe0"
            ]
        ]
    }
]

You have set payload to an integer array not a byte buffer.

Change

msg.payload = [0x1b,0x69,0x53];
return msg

to

msg.payload = Buffer.from([0x1b,0x69,0x53]);
return msg

You may need to power the printer off/on to clear its comm buffer.

NOTE: i have no idea if 0x1b,0x69,0x53 is the correct sequence of bytes - you will need to verify this

Thank you very much! now i was able to make a QR code and printed it! Very nice!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.