No data output on serial port Raspberry Pi 3

1,240 views
Skip to first unread message

Nikola Trifunovic

unread,
Jul 4, 2016, 5:41:44 AM7/4/16
to Node-RED

Dear Node-Red-Community,

I am trying to make a simple flow with one inject and one serial-out node. But there is no data output on the GPIO14 (TXD0).


I know that my UART port works. I tested it with python. The only difference is that the port name used in python is “/dev/serial0”, while in Node-Red it is “/dev/tty1”.


First I tried to use also in Node-Red “/dev/serial0”, but the debug-info told me that:

“Error: Serialport /dev/serial0 not open.” Every time a message was send by the inject-node.


So I tried “/dev/tty1”. Because in my cmdline.txt stands this:

dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait


By using the port name “/dev/tty1” I get:

[info] serial port /dev/tty1 opened at 115200 baud 8N1

But no message at the output…

 

I also tried to install node-red-node-serialport 0.3.0 explained here http://flows.nodered.org/node/node-red-node-serialport

But still no output…


My System Information’s are

[info] Node-RED version: v0.14.3

[info] Node.js  version: v0.10.29

[info] Linux 4.4.13-v7+ arm LE

Raspberry Pi 3

 

So does anybody know:

Why is there no output data?

And

Why does Node-Red can open /tty1 but not /serial1?

 

Many thanky in advance!

Nikola


BTW:

inject node: [{"id":"df2058f3.62dca8","type":"inject","z":"54775c9b.92d704","name":"","topic":"","payload":"test","payloadType":"str","repeat":"0.1","crontab":"","once":false,"x":670,"y":180,"wires":[["8458c8f0.838f88"]]}]


serial node:

[{"id":"8458c8f0.838f88","type":"serial out","z":"54775c9b.92d704","name":"","serial":"2ecdb484.25cea4","x":960,"y":180,"wires":[]},{"id":"2ecdb484.25cea4","type":"serial-port","z":"54775c9b.92d704","serialport":"/dev/tty1","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"4","bin":"false","out":"count","addchar":true}]

Julian Knight

unread,
Jul 4, 2016, 6:01:57 AM7/4/16
to Node-RED
I think that you have system output going to serial0 which is why you can't use it. If I remember rightly, you need to remove the reference to serial0 in cmdline.txt


Here are the instructions from my notebook - though I think there is a command to do this now....


To Disable Serial Port Login

You need to edit two files in order to use the serial port with your own programs.

When the Raspberry Pi boots, the bootup information is sent to the serial port. You can disable this by editing the/boot/cmdline.txt file

The contents of the file look like this

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Remove all references to ttyAMA0 so the file looks like this:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Save the file to save your changes.

The second file to edit is  /etc/inittab

Edit using: sudo nano /etc/inittab

The /etc/ inittab file has the command which enables the login prompt which needs to be disabled.

Near the end of the file will be a line similar to this:

respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable this line by adding a # character to the beginning.

#respawn:/sbin/getty -L ttyAMA0 115200 vt100

Save the file.

You should then reboot your raspberry pi with the following command

sudo shutdown -r now

You can now use your serial port with other applications on your Raspberry Pi.

karthhic Mukil

unread,
Jul 4, 2016, 8:54:41 AM7/4/16
to Node-RED
hi,

the serial pins are now changed as /dev/ttyS0.
and in the rpi configuration select serial.
you should be root to access the port.

BR
K

karthhic Mukil

unread,
Jul 4, 2016, 9:07:23 AM7/4/16
to Node-RED


On Monday, July 4, 2016 at 12:41:44 PM UTC+3, Nikola Trifunovic wrote:
ss.jpg

Nikola Trifunovic

unread,
Jul 4, 2016, 1:05:24 PM7/4/16
to Node-RED

Hello Karthhic,
Thank you for your help.
But it doesn't work with "/dev/ttyS0". --> Error: Serialport /dev/ttyS0 not open.

And what do you mean with selecting the serial in the pi configuration? I have already enabled the serial in the pi-config.

Maybe it is because I am not root, although I started the server with "sudo node-red-start". But the server writes:

Started Node-RED graphical event wiring tool..
Welcome to Node-RED
===================
4 Jul 16:57:42 - [info] Node-RED version: v0.14.3
4 Jul 16:57:42 - [info] Node.js  version: v0.10.29
4 Jul 16:57:42 - [info] Linux 4.4.13-v7+ arm LE
4 Jul 16:57:42 - [info] Loading palette nodes
pi : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/python -u /usr/lib/node_modules/node-red/nodes/core/hardware/nrgpio.py info
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
noble warning: adapter state unauthorized, please run as root or with sudo


Thanks again!

Nikola Trifunovic

unread,
Jul 4, 2016, 1:11:16 PM7/4/16
to Node-RED
Hello Julian,

Thank you for your help.

I tried to change my uart setting as you recommended. But I can not find the inittab.

Thanks again!
Nikola

Dave C-J

unread,
Jul 4, 2016, 2:11:10 PM7/4/16
to node...@googlegroups.com
by default pi gpio 14 and 15 - should be the /dev/ttyAMA0 port. not sure where all this S0 has come from. :-(

Nikola Trifunovic

unread,
Jul 4, 2016, 2:22:54 PM7/4/16
to Node-RED
Thank you Dave,

I can open the "/dev/ttyAMA0/" port, but again nothing comes out...

But maybe my settings of the nodes are not correct.
Can somebody please check them?
Many thanks in advance!



Auto Generated Inline Image 1
Auto Generated Inline Image 2

Mark Setrem

unread,
Jul 4, 2016, 6:07:36 PM7/4/16
to Node-RED
You won't find inittab on Jessie as it has been replaced

See explanation here, https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=123081

Julian Knight

unread,
Jul 4, 2016, 6:57:11 PM7/4/16
to Node-RED
Thanks for that Mark, the part of that thread that I think Nikola needs is:

Under Raspbian Jessie, you can use:
CODE: SELECT ALL
sudo raspbian-config
Then choose "Advanced Options", then "Serial" and answer "No" to the question "Would you like a login shell to be accessible over serial?" However, this also removes the /dev/ttyAMA0 device.

Otherwise the serial TTY takes over the serial port. However, I'm not sure about the part that talks about the ttyAMA0 device being removed. I suppose it is different for me as I am using 2 serial ports but both are additions, an Arduino connected to USB that I manually edited to make sure it always appears as /dev/arduino and a Ciesco SRF device that presents as /dev/ttyAMA0. I use a Pi2 that had a fresh install of Jessie.

The article here: http://elinux.org/RPi_Serial_Connection - seems to have some good information on the Pi's serial port. Or maybe here: http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/

Nikola Trifunovic

unread,
Jul 5, 2016, 7:36:05 AM7/5/16
to Node-RED
Hello Julian,

I changed the "Advanced Options" and still no data...

What I don't understand is, why does nodered writes


pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root

when I start the server like this: "sudo node-red-start"

I mean a program can not stop my sudo command or can it?

Because in Python I am using "/dev/serial0" and I start it with "sudo python myscript.py" and it works...

Julian Knight

unread,
Jul 5, 2016, 7:57:57 AM7/5/16
to Node-RED
That is the message from the Linux authorisation function, PAM, telling you that NR has shell'd out - it is saying that NR (running as root) has created a new BASH shell to run a command and then is closing the shell. If you ran NR as user Pi, that is what you would see in the PAM message, NR is still running the command. If you run a shell command from NR that produces stdout, you will see it between those 2 messages.

I actually find those messages really annoying as I run some shell commands every few seconds to track active devices on the network & they fill up the logs. I wish there were a way to get rid of them.

-- off topic --
You should, of course, check the permissions on your serial devices to see who has access and then add the Pi user to that group. Then you don't need to run NR as root since that is a security problem waiting to happen - not too bad if you only ever run the Pi on a local network but could be a problem if/when you connect to the Internet (inevitably having forgotten about running NR as root).

I am running as user Pi and have no need to to run as root even though Pi has access to serial, usb and even bluetooth. Of course, being in IT Security, I AM paranoid ;) and so I still don't connect my Pi directly to the Internet but rather from behind a proxy server that also provides https termination.
-- on topic --
Message has been deleted

karthhic Mukil

unread,
Jul 5, 2016, 10:23:38 AM7/5/16
to Node-RED
Hi,

I faced the same issue, but when i tried sudo node-red, but i entered as root using su and then it was so clean that i had to install all the modules again, luckily i am having a script where i always add the module which i install so i dont need to search and install it again every time i clean my sd card. but the installation place has to be different for it its /root/.node-red [because i used sudo startx before].

since i am busy on other stuffs, i dont have that time to experiment on this.

All the best to get the answer

Best Regards,
K

Nikola Trifunovic

unread,
Jul 5, 2016, 11:14:18 AM7/5/16
to Node-RED
@All
I solved it. I can now send with 1Mbaud over the UART with the part name "/dev/serial0".

With "ls -l /dev/serial0" I found out that serial0 is just a symbol name for ttyS0 (@karthhic: you were right). So I added "/dev/ttyS0" to the dialout group, because user "pi" is part of it.
(The serial is enabled in the raspi-config advanced options.)
 
Last thing:
$ ls -l /dev/ttyS0
  crw--w---- 1 root dialout 4, 64 Jul  5 11:43 /dev/ttyS0
$ sudo chmod g+r /dev/ttyS0
$ ls -l /dev/ttyS0
  crw-rw---- 1 root dialout 4, 64 Jul  5 11:43 /dev/ttyS0

And that was it.
Node-Red could not open the "/dev/serial0" because of the user rights.
What acually worked with Python just by using sudo --> well, what a stupid system...

Anyway thank you all for your help!!!
All the best!
Nikola

Jamie Owst

unread,
Aug 5, 2016, 4:58:42 AM8/5/16
to Node-RED
sorry for hijacking the post but i am having a similar problem how did you  add "/dev/ttyS0" to the dialout group?

I thank anyone who replies in advance.

Jamie Owst 
Reply all
Reply to author
Forward
0 new messages