Modbus RPI USB RS485 RPI CH340C Device doesn't work - Error connecting

Aim: read Modbus RTU RS485 Data from Sensor
System: OH3.2 (openHABian - Hassle-free openHAB Setup)
Binding: Modbus-Binding (3.2 stable)
Device: RPI USB RS485 Raspberry Pi - USB-RS485-Schnittstelle, CH340C
[RPI USB RS485: Raspberry Pi - USB-RS485-Schnittstelle, CH340C
info for Device

Hello,
I have pluged in the Modbus-USB-device into USB after I have installed the Modbus-Binding.

Then I made the bridge and the poller, like this:

UID: modbus:serial:c18b3dbb63
label: Modbus Serial Slave
thingTypeUID: modbus:serial
configuration:
baud: 9600
timeBetweenTransactionsMillis: 35
connectMaxTries: 1
stopBits: “1.0”
parity: odd
receiveTimeoutMillis: 1500
dataBits: 8
echo: false
encoding: rtu
flowControlIn: none
port: /dev/ttyUSB1
flowControlOut: none
connectTimeoutMillis: 10000
id: 1
enableDiscovery: false

UID: modbus:poller:c18b3dbb63:a43d95c311
label: Regular Poll
thingTypeUID: modbus:poller
configuration:
length: 2
start: 25
refresh: 500
maxTries: 1
cacheMillis: 50
type: holding
bridgeUID: modbus:serial:c18b3dbb63

The bridge is online but after saving the poller, there is following problem/ are 4 errors:
2022-02-03 15:29:45.202 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection [m_SerialPort=null, m_Parameters.getPortName()=/dev/ttyUSB1] for endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB1]: Could not get port identifier, maybe insufficient permissions. null

2022-02-03 15:29:45.203 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB1] – aborting request ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=25, length=2, maxTries=1] [operation ID 1b8f9fd7-0718-4378-afd5-978492af7102]

2022-02-03 15:29:45.203 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB1] – aborting request ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=25, length=2, maxTries=1] [operation ID 1b8f9fd7-0718-4378-afd5-978492af7102]

2022-02-03 15:29:45.203 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB1] – aborting request ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=25, length=2, maxTries=1] [operation ID 1b8f9fd7-0718-4378-afd5-978492af7102]

what ist the problem?

my check for permission:
ls -l /dev/ttyUSB*

in an other binding (PHC) I read something about the driver for like in my device - but I didn’t want to install that…:


PHC - Bindings | openHAB
GitHub - aperepel/raspberrypi-ch340-driver: CH340/341 (HL340/341) Serial-to-USB UART Driver for Raspberry Pi

thx

Not sure what’s under the red blob in your permissions screenshot, but runtime user is openhab

thx for your reply!

so you mean that my change of the (standard) username “openhabian” to another could be the problem?

No idea what you’ve done. The user that is running the openhab service needs permission to access the serial port. openhabian/console users are unrelated to this. (openhabian is a setting up tool, openhab is the actual product here)

how can I find out what is the “user that is running openhab” - can you explain me, please!

I changed my user, at the beginning…:
image

should I rename (hostname) it to “openhabian” as it was in the beginning?

I don’t think that matters to openhab software, it’s probably still running under user ‘openhab’?

re - The user 'openhab' is aleady a member of 'dialout'
That looks promising.

This might help -

thx alot, I will try it!

Changing Linux user is a bad idea unless you know all the implications on openHAB(ian) - which you apparently don’t -, and not of any or just of negligible benefit anyway.
You should change the user back but I’d rather suggest you reinstall to be sure there’s no leftovers.
If you want to use some other username you could do that at installation time via /etc/openhabian.conf but you must not do that manually. But it’s still no good idea.

Thanks alot for reply!

Sry I’dont understand. Maybe I wrote something wrong above - I think have only changed the hostname - is that also a “bad idea” (in sudo openhabian config)?!:

image

how can I find out my current linux-user…?

Smartanemo is a host - name of the computer/system.
openhabian is your user
@all, he did not changed the user. This is the default user on openhabian installed system. Mine is the same.

1 Like

Thanks alot for your answer!