Nodered doesn't work with serial port

I can’t get the serial port to work

I set in boot config
enable_uart=1

dietpi@DietPi:~$ ls -la /dev/ttyAMA0
crw-rw---- 1 root dialout 204, 64 Nov  9 15:18 /dev/ttyAMA0
dietpi@DietPi:~$ groups nodered
nodered : nodered tty dialout spi i2c gpio
Nov 09 15:19:13 DietPi node-red[1499]: Welcome to Node-RED
Nov 09 15:19:13 DietPi node-red[1499]: ===================
Nov 09 15:19:13 DietPi node-red[1499]: 9 Nov 15:19:13 - [info] Node-RED version: v3.1.0
Nov 09 15:19:13 DietPi node-red[1499]: 9 Nov 15:19:13 - [info] Node.js  version: v21.0.0
Nov 09 15:19:13 DietPi node-red[1499]: 9 Nov 15:19:13 - [info] Linux 6.1.21-v8+ arm64 LE
Nov 09 15:19:16 DietPi node-red[1499]: 9 Nov 15:19:16 - [info] Loading palette nodes
Nov 09 15:19:22 DietPi node-red[1499]: 9 Nov 15:19:22 - [info] Dashboard version 3.6.1 started at /ui
Nov 09 15:19:24 DietPi node-red[1499]: (node:1499) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
Nov 09 15:19:24 DietPi node-red[1499]: (Use `node --trace-deprecation ...` to show where the warning was created)
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [info] Settings file  : /mnt/dietpi_userdata/node-red/settings.js
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [info] Context store  : 'default' [module=memory]
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [info] User directory : /mnt/dietpi_userdata/node-red
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [warn] Projects disabled : editorTheme.projects.enabled=false
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [info] Flows file     : /mnt/dietpi_userdata/node-red/flows.json
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [warn]
Nov 09 15:19:24 DietPi node-red[1499]: ---------------------------------------------------------------------
Nov 09 15:19:24 DietPi node-red[1499]: Your flow credentials file is encrypted using a system-generated key.
Nov 09 15:19:24 DietPi node-red[1499]: If the system-generated key is lost for any reason, your credentials
Nov 09 15:19:24 DietPi node-red[1499]: file will not be recoverable, you will have to delete it and re-enter
Nov 09 15:19:24 DietPi node-red[1499]: your credentials.
Nov 09 15:19:24 DietPi node-red[1499]: You should set your own key using the 'credentialSecret' option in
Nov 09 15:19:24 DietPi node-red[1499]: your settings file. Node-RED will then re-encrypt your credentials
Nov 09 15:19:24 DietPi node-red[1499]: file using your chosen key the next time you deploy a change.
Nov 09 15:19:24 DietPi node-red[1499]: ---------------------------------------------------------------------
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [warn] Encrypted credentials not found
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [info] Server now running at http://127.0.0.1:1880/
Nov 09 15:19:24 DietPi node-red[1499]: 9 Nov 15:19:24 - [info] Starting flows
Nov 09 15:19:25 DietPi node-red[1499]: 9 Nov 15:19:25 - [info] Started flows
Nov 09 15:19:25 DietPi node-red[1499]: 9 Nov 15:19:25 - [info] [serialconfig:9cd68d2d0c2ca419] serial port /dev/ttyAMA0 opened at 9600 baud 8N1
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [info] Stopping flows
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [info] serial port /dev/ttyAMA0 closed
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [info] Stopped flows
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [info] Updated flows
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [info] Starting flows
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [info] Started flows
Nov 09 15:21:02 DietPi node-red[1499]: 9 Nov 15:21:02 - [error] [serialconfig:9cd68d2d0c2ca419] serial port /dev/ttyAMA0 error: Error: Error Resource temporarily unavailable Cannot lock port
dietpi@DietPi:~$ uname -a
Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

did you tried to enable serial port via dietpi-config already?


I tried all options variants, but it didn’t help. How to real should it be set ?
p.s.
same problem with ttyAMA0 and ttyS0
p.p.s.
bluetooth set off
p.p.p.s.
rpi 3 model B v. 1.2

I test with USB-cable (ttyUSB) - working without problems

in nodered
Tx - works, RX - not
Screenshot_20231110_124610

@StephanStS as far as I know, you are using nodered. Do you use serial port as well?

No, I haven’t used it yet. I do not have a serial device to check this.
@Kliurka: Which node-red serial port lib did you choose?

this node-red-node-serialport (node) - Node-RED

I tried both ttyAMA0 and ttyS0, but the error messages are different
if I use ttyAMA0 error mesage:

“/dev/ttyAMA0 error: Error: Error Resource temporarily unavailable Cannot lock port”

if use ttyS0:
doesn’t matter what baudrate set, the error is the same

“serial port /dev/ttyS0 error: Error: Error: Input/output error setting custom baud rate of 9600”

in nodered “serial out” node status “connected”, but “serial in” node status “not connected”

Could you look for these Node-RED forum entries whether they help:

I’m back again with this problem, /dev/ttyS0 as it works, but it starts working only after 4-5 minutes after booting, the same effect it doesn’t work 4-5 minutes after nodered deployment and after that time gets up.
Where to look for the problem?