Nodered Nextion Display

Hello,
iam new and i would like to use Nodered + Nextion HMI.
I have a serial connection and can use buttons as well.
To get data ist not the problem.

I want to send a txt to a t0.txt part.
But till now i tried a lot, look in this forum and try to help myself.
It is useless. I need help.

I do not see any symstem working fine, by sending informations to the nextion.

Do anybody have any idea?
Found this:
(Syntax command control nextion display)
But i do not use MQTT.

Thanks
Alex

Have you tried a simple inject node to send a string like NEXTION,t0.txt="hello" to the serial node?

1 Like

Hi,
thanks for your help.

Yes, the debug:

But i cannot see anything on that HMI

Could it be, that the Nextion want to get a buffer for input?

Thanks alex

the serial node sorts that out automatically.

It could be you need to append a linefeed or carriage return (or both)

try adding them see what happens.

NOTE: to add a \r CR you can use the inject node but a function node is just as easy...

1 Like

hello,
i´d tried

this is the funtion

but nothing change in the HMI

Thanks

Alex

Did you made a t0 element on your Nextion display with the Nextion editor?

Looks like it

@holographic Perhaps post your flow and HMI file so anyone with a Nextion can test if need be.

Yes i do.

I cannat upload a tft file here. Look like that is blocked.
Upload from the nodes

EDIT:

[
    {
        "id": "9f2e75f318e0db1f",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": ""
    },
    {
        "id": "f439f64620f88998",
        "type": "serial in",
        "z": "9f2e75f318e0db1f",
        "name": "Nextion",
        "serial": "f527860f.a985e8",
        "x": 790,
        "y": 380,
        "wires": [
            [
                "f2259c6fbec866b1",
                "4deff35a28f1ce03"
            ]
        ]
    },
    {
        "id": "94a2dac7d9f23039",
        "type": "serial out",
        "z": "9f2e75f318e0db1f",
        "name": "NEXTION",
        "serial": "f527860f.a985e8",
        "x": 2500,
        "y": 100,
        "wires": []
    },
    {
        "id": "0c779c63ceee7d51",
        "type": "switch",
        "z": "9f2e75f318e0db1f",
        "name": "Which Button",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "2",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "5",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "6",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "9",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 4,
        "x": 1380,
        "y": 380,
        "wires": [
            [
                "45470bcfb022c93a"
            ],
            [
                "ee791fc6b48d9a70",
                "c7dae7fc1337a474"
            ],
            [
                "842caeb9f13ca686",
                "3c462d2a75019956"
            ],
            []
        ],
        "outputLabels": [
            "Licht Links",
            "Licht Rechts",
            "Drucker Links",
            ""
        ]
    },
    {
        "id": "842caeb9f13ca686",
        "type": "debug",
        "z": "9f2e75f318e0db1f",
        "name": "2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2330,
        "y": 360,
        "wires": []
    },
    {
        "id": "e142724742466dbd",
        "type": "rpi-gpio out",
        "z": "9f2e75f318e0db1f",
        "name": "PIN7",
        "pin": "7",
        "set": false,
        "level": "1",
        "freq": "",
        "out": "out",
        "x": 2330,
        "y": 200,
        "wires": []
    },
    {
        "id": "772b8447c8b8a17f",
        "type": "rpi-gpio out",
        "z": "9f2e75f318e0db1f",
        "name": "Gewindemodus",
        "pin": "11",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 2360,
        "y": 400,
        "wires": []
    },
    {
        "id": "e4489f852968afae",
        "type": "comment",
        "z": "9f2e75f318e0db1f",
        "name": "Lampe ein",
        "info": "",
        "x": 2500,
        "y": 200,
        "wires": []
    },
    {
        "id": "ee791fc6b48d9a70",
        "type": "debug",
        "z": "9f2e75f318e0db1f",
        "name": "8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2330,
        "y": 260,
        "wires": []
    },
    {
        "id": "778f5ff619e9f46b",
        "type": "rpi-gpio out",
        "z": "9f2e75f318e0db1f",
        "name": "Maschine an",
        "pin": "37",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 2350,
        "y": 300,
        "wires": []
    },
    {
        "id": "f7bd3ed22b4a5c0d",
        "type": "comment",
        "z": "9f2e75f318e0db1f",
        "name": "Maschine AN",
        "info": "nur ein Test",
        "x": 2530,
        "y": 300,
        "wires": []
    },
    {
        "id": "3afaec171c8666dd",
        "type": "inject",
        "z": "9f2e75f318e0db1f",
        "name": "shutdown!",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payloadType": "date",
        "x": 1120,
        "y": 760,
        "wires": [
            [
                "ee6f6a6a85ee79a9"
            ]
        ]
    },
    {
        "id": "ee6f6a6a85ee79a9",
        "type": "exec",
        "z": "9f2e75f318e0db1f",
        "command": "sudo shutdown -h 0 #",
        "addpay": "",
        "append": "",
        "useSpawn": "",
        "timer": "",
        "winHide": false,
        "name": "turn off Pi",
        "x": 1300,
        "y": 760,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "3c0bbdb2ddb1129f",
        "type": "inject",
        "z": "9f2e75f318e0db1f",
        "name": "neustart!",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payloadType": "date",
        "x": 1120,
        "y": 840,
        "wires": [
            [
                "311ec29c7d00d7ab"
            ]
        ]
    },
    {
        "id": "311ec29c7d00d7ab",
        "type": "exec",
        "z": "9f2e75f318e0db1f",
        "command": "sudo shutdown -r 0 #",
        "addpay": "",
        "append": "",
        "useSpawn": "",
        "timer": "",
        "winHide": false,
        "name": "turn off Pi",
        "x": 1300,
        "y": 840,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "45470bcfb022c93a",
        "type": "toggle",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "onOffTopic": "",
        "onValue": "1",
        "onType": "str",
        "offValue": "0",
        "offType": "str",
        "toggleTopic": "",
        "toggleValue": "2",
        "toggleType": "str",
        "passOnOff": "",
        "x": 2170,
        "y": 220,
        "wires": [
            [
                "e142724742466dbd"
            ]
        ]
    },
    {
        "id": "c7dae7fc1337a474",
        "type": "toggle",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "onOffTopic": "",
        "onValue": "1",
        "onType": "str",
        "offValue": "0",
        "offType": "str",
        "toggleTopic": "",
        "toggleValue": "5",
        "toggleType": "str",
        "passOnOff": "",
        "x": 2170,
        "y": 320,
        "wires": [
            [
                "778f5ff619e9f46b"
            ]
        ]
    },
    {
        "id": "3c462d2a75019956",
        "type": "toggle",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "onOffTopic": "",
        "onValue": "1",
        "onType": "str",
        "offValue": "0",
        "offType": "str",
        "toggleTopic": "",
        "toggleValue": "6",
        "toggleType": "str",
        "passOnOff": "",
        "x": 2170,
        "y": 400,
        "wires": [
            [
                "772b8447c8b8a17f"
            ]
        ]
    },
    {
        "id": "f2259c6fbec866b1",
        "type": "function",
        "z": "9f2e75f318e0db1f",
        "name": "Extract Button ID",
        "func": "msg.payload = String(msg.payload[2]);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1070,
        "y": 380,
        "wires": [
            [
                "0c779c63ceee7d51"
            ]
        ]
    },
    {
        "id": "4c1e56bac57b1c42",
        "type": "debug",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2510,
        "y": 20,
        "wires": []
    },
    {
        "id": "d56fe51869f9e45a",
        "type": "comment",
        "z": "9f2e75f318e0db1f",
        "name": "Gewindemodus",
        "info": "nur ein Test",
        "x": 2540,
        "y": 400,
        "wires": []
    },
    {
        "id": "4deff35a28f1ce03",
        "type": "debug",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 340,
        "wires": []
    },
    {
        "id": "ff1ce9ad05f1a132",
        "type": "inject",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 2140,
        "y": 80,
        "wires": [
            [
                "8850e0187eacc6d3"
            ]
        ]
    },
    {
        "id": "8850e0187eacc6d3",
        "type": "function",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "func": "msg.payload = 't0.txt=\"Hello\"';\nvar textBuf = Buffer.from(msg.payload, 'ascii');\nvar postFixBuf = new Buffer(\"FFFFFF\", \"hex\");\n\nmsg.payload = Buffer.concat([textBuf, postFixBuf]);\n\nreturn msg;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 2320,
        "y": 80,
        "wires": [
            [
                "4c1e56bac57b1c42",
                "94a2dac7d9f23039"
            ]
        ]
    },
    {
        "id": "ac0492e69b2f65f5",
        "type": "inject",
        "z": "9f2e75f318e0db1f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 2150,
        "y": 140,
        "wires": [
            [
                "8850e0187eacc6d3"
            ]
        ]
    },
    {
        "id": "f527860f.a985e8",
        "type": "serial-port",
        "serialport": "/dev/ttyS0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "newline": "5",
        "bin": "bin",
        "out": "interbyte",
        "addchar": "false",
        "responsetimeout": ""
    }
]

Thanks for your help

Alex

Hi,


as simple as possible

OK... after more hours then I should admit too :woozy_face: I remembered why I am not that fond of the Nextion. It can be a bit of a pain to use.

All I was getting was random buffers from buttons and nothing I sent was working either.

Anyhow, once I realized I was using the wrong BAUD rate :astonished: (mine is apparently set for 115200) everything started making sense and working.

Try this for sending text (and numbers if you add such a field on your HMI program)

image

[{"id":"4fbb5e130de7fcfc","type":"serial out","z":"e3ddcb330c2f0550","name":"NEXTION","serial":"f527860f.a985e8","x":1220,"y":180,"wires":[]},{"id":"28ecfd2672cce327","type":"debug","z":"e3ddcb330c2f0550","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1230,"y":100,"wires":[]},{"id":"6d14d3d60fea3839","type":"inject","z":"e3ddcb330c2f0550","name":"Hello World","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":830,"y":60,"wires":[["b647a6646b395311"]]},{"id":"b647a6646b395311","type":"function","z":"e3ddcb330c2f0550","name":"","func":"msg.payload = 't0.txt=\"Hello World\"';\nvar textBuf = Buffer.from(msg.payload, 'ascii');\nvar postFixBuf = new Buffer(\"FFFFFF\", \"hex\");\n\nmsg.payload = Buffer.concat([textBuf, postFixBuf]);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":60,"wires":[["28ecfd2672cce327","4fbb5e130de7fcfc"]]},{"id":"fc00376ed85755ca","type":"inject","z":"e3ddcb330c2f0550","name":"How are you doing?","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":850,"y":100,"wires":[["a8858050d5125c05"]]},{"id":"a8858050d5125c05","type":"function","z":"e3ddcb330c2f0550","name":"","func":"msg.payload = 't0.txt=\"How are you doing?\"';\nvar textBuf = Buffer.from(msg.payload, 'ascii');\nvar postFixBuf = new Buffer(\"FFFFFF\", \"hex\");\n\nmsg.payload = Buffer.concat([textBuf, postFixBuf]);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":100,"wires":[["28ecfd2672cce327","4fbb5e130de7fcfc"]]},{"id":"41612ead756b93af","type":"inject","z":"e3ddcb330c2f0550","name":"123456789","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":820,"y":200,"wires":[["d2632cd42c107210"]]},{"id":"d2632cd42c107210","type":"function","z":"e3ddcb330c2f0550","name":"","func":"msg.payload = 'n0.val=123456789';\nvar textBuf = Buffer.from(msg.payload, 'ascii');\nvar postFixBuf = new Buffer(\"FFFFFF\", \"hex\");\n\nmsg.payload = Buffer.concat([textBuf, postFixBuf]);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":200,"wires":[["4fbb5e130de7fcfc","28ecfd2672cce327"]]},{"id":"b1bded91d84376a3","type":"inject","z":"e3ddcb330c2f0550","name":"Clear Number","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":830,"y":240,"wires":[["c90183b377cba632"]]},{"id":"c90183b377cba632","type":"function","z":"e3ddcb330c2f0550","name":"","func":"msg.payload = 'n0.val=0';\nvar textBuf = Buffer.from(msg.payload, 'ascii');\nvar postFixBuf = new Buffer(\"FFFFFF\", \"hex\");\n\nmsg.payload = Buffer.concat([textBuf, postFixBuf]);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":240,"wires":[["4fbb5e130de7fcfc","28ecfd2672cce327"]]},{"id":"055d72891965fc59","type":"inject","z":"e3ddcb330c2f0550","name":"Clear Text","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":820,"y":140,"wires":[["b7e74b9c82ee3f30"]]},{"id":"b7e74b9c82ee3f30","type":"function","z":"e3ddcb330c2f0550","name":"","func":"msg.payload = 't0.txt=\"\"';\nvar textBuf = Buffer.from(msg.payload, 'ascii');\nvar postFixBuf = new Buffer(\"FFFFFF\", \"hex\");\n\nmsg.payload = Buffer.concat([textBuf, postFixBuf]);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":140,"wires":[["28ecfd2672cce327","4fbb5e130de7fcfc"]]},{"id":"f527860f.a985e8","type":"serial-port","serialport":"/dev/ttyS0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"5","bin":"bin","out":"interbyte","addchar":"","responsetimeout":""}]

Hi,
thanks for your help, so nice to get.

I´ve tried to change to 115200 but if i the RPI recieve an event, the string is empty.
So i can recieve in 9600, everything is right. but to send the comes even with your json part:

What dows the Type error mean?

Thank you really much much for your help :slight_smile:

Alex

Dear my friend.
Got it
Dam it
Thats It.

I change in the ```
cmdline.txt

 115200 baut

restart and go in nodered to Nextion (serial)
![image|377x500](upload://wgIFX1FRO9KZO76GyA4t9tDd8PK.png)
 clear the output 

The idea i do have it from this :slight_smile:

https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494

Working fine, everything

Thanks folks, you are the one :slight_smile: 
Alex

After the triple backticks here, your post wasn't processed properly, so unsure of you intended to post a similar image...

But good you figured it out. I forgot to add that part into my post, about Nextion needing that one field clear instead of the default false

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