Modbus RTU using ch340 ttl to usb on pi 4

I NEED SOME help on my raspberry pi 4 i use ch340 ttl to usb to get string from a flowmeter via rs485 . wenne i l put the ch340 to my windows10 node red i get the data but when i put it in pi 4 with the same flow i get northing . note : in my windows flow on node modbus-read i use config Serial port COM47 . Serial type :RTU-BUFFERD
Baud rate : 9600

at do the same in my pi 4 but i change the serial port to /dev/ttyUSB0 . it the anythink
should i active or any advise

I've had issues with drivers on raspberry pi's before. Works on windows, mac, linux(64), but raspberry NO-GO.

Check out this post on pi drivers for the ch240
https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/linux

i installed drivers and the modbus-read node show connect but when i inject it . it reconnecting without any out put

What does this command show?
ls -l /dev/serial/by-id

leopard@raspberrypi:~ $ ls -l /dev/serial/by-id
ls: cannot access '/dev/serial/by-id': No such file or directory

leopard@raspberrypi:~ $ ls -l /dev/serial*
lrwxrwxrwx 1 root root 5 Jul 10 02:17 /dev/serial0 -> ttyS0
lrwxrwxrwx 1 root root 7 Jul 10 02:17 /dev/serial1 -> ttyAMA0

/dev/serial:
total 0
drwxr-xr-x 2 root root 60 Jul 31 15:40 by-path

leopard@raspberrypi:~ $ ls /dev/ttyUSB*
/dev/ttyUSB0

leopard@raspberrypi:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 1a86:7523 QinHeng Electronics CH340 serial converter
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

node i m using modbus-read * ;

node-red-contrib-modbus
v5.25.0

the config is totally correct in this nodes . the problem i think is in the server i use maybe /dev/ttyUSB0 ?

[
    {
        "id": "384f10890cc6f831",
        "type": "modbus-read",
        "z": "4c0d8eb2f4e52850",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": false,
        "unitid": "1",
        "dataType": "HoldingRegister",
        "adr": "4112",
        "quantity": "4",
        "rate": "10",
        "rateUnit": "s",
        "delayOnStart": false,
        "startDelayTime": "0",
        "server": "4412ae43.cdf648",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 230,
        "y": 140,
        "wires": [
            [
                "6cf7a26b9fbe62ab",
                "dcbeb403db420b52"
            ],
            []
        ]
    },
    {
        "id": "6cf7a26b9fbe62ab",
        "type": "modbus-response",
        "z": "4c0d8eb2f4e52850",
        "name": "modbus 1 Débit",
        "registerShowMax": "20",
        "x": 520,
        "y": 120,
        "wires": []
    },
    {
        "id": "dcbeb403db420b52",
        "type": "debug",
        "z": "4c0d8eb2f4e52850",
        "name": "debug 2355",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 180,
        "wires": []
    },
    {
        "id": "4412ae43.cdf648",
        "type": "modbus-client",
        "name": "",
        "clienttype": "simpleser",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": false,
        "tcpHost": "127.0.0.1",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB0",
        "serialType": "RTU",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "even",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "",
        "unit_id": 1,
        "commandDelay": 1,
        "clientTimeout": 1000,
        "reconnectOnTimeout": true,
        "reconnectTimeout": 2000,
        "parallelUnitIdsAllowed": false
    }
]

Well that is odd. Are you running the standard pi OS?

Unplug the adaptor, reboot, and run
tail -f /var/log/syslog
if necessary wait for a gap then hit return a couple of times to give a couple of blank lines, then plug in the adaptor. Post what you see in the log.

raspberry pi os full ( 32bit )


leopard@raspberrypi:~ $ tail -f /var/log/syslog
Jul 31 16:04:45 raspberrypi Node-RED[386]: Your flow credentials file is encrypted using a system-generated key.
Jul 31 16:04:45 raspberrypi Node-RED[386]: If the system-generated key is lost for any reason, your credentials
Jul 31 16:04:45 raspberrypi Node-RED[386]: file will not be recoverable, you will have to delete it and re-enter
Jul 31 16:04:45 raspberrypi Node-RED[386]: your credentials.
Jul 31 16:04:45 raspberrypi Node-RED[386]: You should set your own key using the 'credentialSecret' option in
Jul 31 16:04:45 raspberrypi Node-RED[386]: your settings file. Node-RED will then re-encrypt your credentials
Jul 31 16:04:45 raspberrypi Node-RED[386]: file using your chosen key the next time you deploy a change.
Jul 31 16:04:45 raspberrypi Node-RED[386]: ---------------------------------------------------------------------
Jul 31 16:04:45 raspberrypi Node-RED[386]: 31 Jul 16:04:45 - [info] Starting flows
Jul 31 16:04:45 raspberrypi Node-RED[386]: 31 Jul 16:04:45 - [info] Started flows


Unplug the adaptor in this last

I don't understand, what I want you to do is to unplug the adaptor, reboot, run tail and then plug the adaptor in to the USB port on the pi. You should see the OS registering it as a serial device. If it doesn't log anything when you plug it in then it is not working.

leopard@raspberrypi:~ $ tail -f /var/log/syslog
Jul 31 16:20:06 raspberrypi kernel: [ 974.513653] usbcore: registered new interface driver usbserial_generic
Jul 31 16:20:06 raspberrypi kernel: [ 974.513723] usbserial: USB Serial support registered for generic
Jul 31 16:20:06 raspberrypi kernel: [ 974.517645] usbcore: registered new interface driver ch341
Jul 31 16:20:06 raspberrypi kernel: [ 974.517722] usbserial: USB Serial support registered for ch341-uart
Jul 31 16:20:06 raspberrypi kernel: [ 974.517815] ch341 1-1.2:1.0: ch341-uart converter detected
Jul 31 16:20:06 raspberrypi kernel: [ 974.523355] ch341-uart ttyUSB0: break control not supported, using simulated break
Jul 31 16:20:06 raspberrypi kernel: [ 974.524649] usb 1-1.2: ch341-uart converter now attached to ttyUSB0
Jul 31 16:20:06 raspberrypi mtp-probe: checking bus 1, device 3: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2"
Jul 31 16:20:06 raspberrypi mtp-probe: bus: 1, device: 3 was not an MTP device
Jul 31 16:20:09 raspberrypi ModemManager[614]: [base-manager] couldn't check support for device '/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2': not supported by any plugin

That looks ok. Does ls -l /dev/serial/by-id still show nothing?

I understood from the previous post that you had unplugged the adaptor and saw nothing in the log. If you now unplug it do you see a disconnected message?

leopard@raspberrypi:~ $ ls -l /dev/serial/by-id
ls: cannot access '/dev/serial/by-id': No such file or directory

i can see if the ch340 are plugin and unplug in the node-red at node modbus-red and also in msg lsusb !

my problem is when i inject the node are give me northing in the output . but in my laptop it give me the buffer at com47 or com28 .

Sorry, I don't know what else to suggest.

no problem . is the any Permissions can i give to set ch340 on the /dev/ttyUSB0

any ideas

You said it is initially showing connected in node-red, which means that there should not be a permissions issue.
Do you see anything relevant in syslog if you reboot, tail syslog, and then try to use the port in node-red?

I presume the system is up to date, if not then run
sudo apt update && sudo apt full-upgrade
watch for any errors.

If that does not help then stop node red and start it again using

node-red-stop
node-red-start

Then try to make the comms work, and post the full startup log here.

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
31 Jul 17:00:10 - [info]
Welcome to Node-RED

31 Jul 17:00:10 - [info] Node-RED version: v3.0.2
31 Jul 17:00:10 - [info] Node.js version: v18.17.0
31 Jul 17:00:10 - [info] Linux 6.1.21-v8+ arm LE
31 Jul 17:00:11 - [info] Loading palette nodes
rpi_ads1115_s32.node driver V2.0.2 (c) Ocean iiot2k@gmail.com
31 Jul 17:00:15 - [info] Dashboard version 3.5.0 started at /ui
31 Jul 17:00:15 - [info] Settings file : /home/leopard/.node-red/settings.js
31 Jul 17:00:15 - [info] Context store : 'default' [module=memory]
31 Jul 17:00:15 - [info] User directory : /home/leopard/.node-red
31 Jul 17:00:15 - [warn] Projects disabled : editorTheme.projects.enabled=false
31 Jul 17:00:15 - [info] Flows file : /home/leopard/.node-red/flows.json
31 Jul 17:00:15 - [info] Server now running at http://127.0.0.1:1880/
31 Jul 17:00:15 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

31 Jul 17:00:15 - [info] Starting flows
31 Jul 17:00:15 - [info] Started flows

31 Jul 17:00:44 - [info] Stopping flows
31 Jul 17:00:44 - [info] Stopped flows
31 Jul 17:00:44 - [info] Updated flows
31 Jul 17:00:44 - [info] Starting flows
31 Jul 17:00:44 - [info] Started flows

i think i will try to use an other node-red version like 2.2.3

Did you run the update and full-upgrade?

You didn't answer that question

I don't think the node-red version will make a difference.

What exactly do you see with the status text under the modbus node?

What does the command
groups show when you are logged in as leopard?