Cannot connect serial port(uart) to Node red Raspberry Pi

Hello, the topic is old, but I’m bringing it up again. I’m trying to connect a serial port (UART) to Node red but I’m not having any success. Can you explain in detail how the access to the serial port in Dietpi is organized, because from enough attempts, all of them have been unsuccessful. What is /dev/ttyS0 and /dev/ttyAMA0? In both cases, I get not connected in Node red. As far as I know, one port is software and the other is hardware, but both ports available in Node red are the same.

hiiii, @devifast

I found this : Data from RPI with UART to NR - General - Node-RED Forum (nodered.org) and : Cant get serialport to work - General - Node-RED Forum (nodered.org)
and a way to around problem on GitHub : Cannot start service nodered /dev/ttyAMA0 · Issue #248 · gcgarner/IOTstack · GitHub

You can check out this thread:
https://dietpi.com/forum/t/using-uart/2276/3?u=jappe

dietpi-config > Advanced Options > Serial/UART
  • Enable serial console with dietpi-config should already do all steps for you, but to be sure:
  • Verify that /DietPi/config.txt contains the line enable_uart=1.
  • Verify that /DietPi/dietpi.txt contains the line CONFIG_SERIAL_CONSOLE_ENABLE=1.
  • By default on RPi3 the hardware UART (aka full UART) on /dev/ttyAMA0 is used by the Bluetooth device.
  • But if you disable Bluetooth completely, you can still use it for other tasks.
  • Otherwise the software UART (aka mini UART) is available on /dev/ttyS0 which is as well by default configured to be available on the GPIO ports, so being the primary UART, on RPi3.

Instead of making the tty world-writeable, please add the nodered user to the tty group: usermod -aG tty nodered

test3

bluetooth is off!!!

Guys, have you really put so much effort into creating a high level operating system loved by hundreds of thousands of users and have a problem with an interface like UART? It was the same when I asked for the SPI interface. Three hundred commands to join? Then you entered it thanks to me.
Why?
Now I need the simplest UART, why doesn’t it work?

test6

systemctl restart node-red
journalctl -u node-red

Have a looke for any error messages.

root@root:~# systemctl restart node-red
root@root:~# journalctl -u node-red
-- Journal begins at Mon 2022-12-12 00:44:49 EET, ends at Mon 2022-12-12 01:47:52 EET. --
Dec 12 00:45:02 root systemd[1]: Started Node-RED (DietPi).
Dec 12 00:45:10 root node-red[581]: 12 Dec 00:45:10 - [info]
Dec 12 00:45:10 root node-red[581]: Welcome to Node-RED
Dec 12 00:45:10 root node-red[581]: ===================
Dec 12 00:45:10 root node-red[581]: 12 Dec 00:45:10 - [info] Node-RED version: v3.0.2
Dec 12 00:45:10 root node-red[581]: 12 Dec 00:45:10 - [info] Node.js  version: v19.1.0
Dec 12 00:45:10 root node-red[581]: 12 Dec 00:45:10 - [info] Linux 5.15.76-v8+ arm64 LE
Dec 12 00:45:14 root node-red[581]: 12 Dec 00:45:14 - [info] Loading palette nodes
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] Settings file  : /mnt/dietpi_userdata/node-red/settings.js
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] Context store  : 'default' [module=memory]
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] User directory : /mnt/dietpi_userdata/node-red
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [warn] Projects disabled : editorTheme.projects.enabled=false
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] Flows file     : /mnt/dietpi_userdata/node-red/flows.json
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [warn]
Dec 12 00:45:19 root node-red[581]: ---------------------------------------------------------------------
Dec 12 00:45:19 root node-red[581]: Your flow credentials file is encrypted using a system-generated key.
Dec 12 00:45:19 root node-red[581]: If the system-generated key is lost for any reason, your credentials
Dec 12 00:45:19 root node-red[581]: file will not be recoverable, you will have to delete it and re-enter
Dec 12 00:45:19 root node-red[581]: your credentials.
Dec 12 00:45:19 root node-red[581]: You should set your own key using the 'credentialSecret' option in
Dec 12 00:45:19 root node-red[581]: your settings file. Node-RED will then re-encrypt your credentials
Dec 12 00:45:19 root node-red[581]: file using your chosen key the next time you deploy a change.
Dec 12 00:45:19 root node-red[581]: ---------------------------------------------------------------------
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [warn] Encrypted credentials not found
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] Server now running at http://127.0.0.1:1880/
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] Starting flows
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [info] Started flows
Dec 12 00:45:19 root node-red[581]: 12 Dec 00:45:19 - [error] [serialconfig:9f0f141e86deaa27] serial port /dev/ttyS0 error: Error: Error: Permission denied, cannot open /dev/ttyS0
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [info] Stopping flows
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [info] serial port /dev/ttyS0 closed
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [info] Stopped flows
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [info] Updated flows
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [info] Starting flows
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [info] Started flows
Dec 12 00:48:07 root node-red[581]: 12 Dec 00:48:07 - [error] [serialconfig:9f0f141e86deaa27] serial port /dev/ttyAMA0 error: Error: Error: Permission denied, cannot open /dev/ttyAMA0
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [info] Stopping flows
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [info] serial port /dev/ttyAMA0 closed
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [info] Stopped flows
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [info] Updated flows
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [info] Starting flows
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [info] Started flows
Dec 12 01:28:48 root node-red[581]: 12 Dec 01:28:48 - [error] [serialconfig:9f0f141e86deaa27] serial port /dev/ttyS0 error: Error: Error: Permission denied, cannot open /dev/ttyS0
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [info] Stopping flows
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [info] serial port /dev/ttyS0 closed
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [info] Stopped flows
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [info] Updated flows
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [info] Starting flows
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [info] Started flows
Dec 12 01:32:15 root node-red[581]: 12 Dec 01:32:15 - [error] [serialconfig:9f0f141e86deaa27] serial port /dev/ttyAMA0 error: Error: Error: Permission denied, cannot open /dev/ttyAMA0
Dec 12 01:46:43 root systemd[1]: Stopping Node-RED (DietPi)...
Dec 12 01:46:43 root node-red[581]: 12 Dec 01:46:43 - [info] Stopping flows
Dec 12 01:46:43 root node-red[581]: 12 Dec 01:46:43 - [info] serial port /dev/ttyAMA0 closed
Dec 12 01:46:43 root node-red[581]: 12 Dec 01:46:43 - [info] Stopped flows
Dec 12 01:46:43 root systemd[1]: node-red.service: Succeeded.
Dec 12 01:46:43 root systemd[1]: Stopped Node-RED (DietPi).
Dec 12 01:46:43 root systemd[1]: node-red.service: Consumed 16.220s CPU time.
Dec 12 01:46:43 root systemd[1]: Started Node-RED (DietPi).
Dec 12 01:46:46 root node-red[2458]: 12 Dec 01:46:46 - [info]
Dec 12 01:46:46 root node-red[2458]: Welcome to Node-RED
Dec 12 01:46:46 root node-red[2458]: ===================
Dec 12 01:46:46 root node-red[2458]: 12 Dec 01:46:46 - [info] Node-RED version: v3.0.2
Dec 12 01:46:46 root node-red[2458]: 12 Dec 01:46:46 - [info] Node.js  version: v19.1.0
Dec 12 01:46:46 root node-red[2458]: 12 Dec 01:46:46 - [info] Linux 5.15.76-v8+ arm64 LE
Dec 12 01:46:49 root node-red[2458]: 12 Dec 01:46:49 - [info] Loading palette nodes
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] Settings file  : /mnt/dietpi_userdata/node-red/settings.js
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] Context store  : 'default' [module=memory]
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] User directory : /mnt/dietpi_userdata/node-red
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [warn] Projects disabled : editorTheme.projects.enabled=false
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] Flows file     : /mnt/dietpi_userdata/node-red/flows.json
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [warn]
Dec 12 01:46:52 root node-red[2458]: ---------------------------------------------------------------------
Dec 12 01:46:52 root node-red[2458]: Your flow credentials file is encrypted using a system-generated key.
Dec 12 01:46:52 root node-red[2458]: If the system-generated key is lost for any reason, your credentials
Dec 12 01:46:52 root node-red[2458]: file will not be recoverable, you will have to delete it and re-enter
Dec 12 01:46:52 root node-red[2458]: your credentials.
Dec 12 01:46:52 root node-red[2458]: You should set your own key using the 'credentialSecret' option in
Dec 12 01:46:52 root node-red[2458]: your settings file. Node-RED will then re-encrypt your credentials
Dec 12 01:46:52 root node-red[2458]: file using your chosen key the next time you deploy a change.
Dec 12 01:46:52 root node-red[2458]: ---------------------------------------------------------------------
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [warn] Encrypted credentials not found
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] Server now running at http://127.0.0.1:1880/
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] Starting flows
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [info] Started flows
Dec 12 01:46:52 root node-red[2458]: 12 Dec 01:46:52 - [error] [serialconfig:9f0f141e86deaa27] serial port /dev/ttyAMA0 error: Error: Error: Permission denied, cannot open /dev/ttyAMA0
root@root:~#

There you have it

[error] [serialconfig:9f0f141e86deaa27] serial port /dev/ttyAMA0 error: Error: Error: Permission denied, cannot open /dev/ttyAMA

don’t understand exactly what this is about?

How to check ports on terminal?

ls -la /dev/ttyAMA0
root@root:~# ls -la /dev/ttyAMA0
crw-rw---- 1 root dialout 204, 64 Dec 12 00:44 /dev/ttyAMA0

You need add the user nodered to the group dialout.

usermod -a -G dialout nodered
1 Like

It’s two in the morning with us, I’m going to bed. Thanks for the support