Over the past couple of years, I’ve installed operating systems on a number of little boards and I have to say, that while the Raspberry Pi with Raspbian is generally the easiest when it comes to enabling GPIO, the serial port can be a pain.
Here is how to ease the pain.
It completely escapes me why user Pi (the one everyone recommends you use) does not by default have access to the serial ports. This is, after all supposed to be an educational machine, not an example of a security system. There are generally two problems with serial… Pi doesn’t have access and this is by default used for debugging (apparently, though I’ve never used it for that). There have been various explanations as to how to get around this… editing out the bit in /boot/cmdline.txt that refers to the serial port seems to be the important one.
You might expect the serial port, being the only one available, to be called /dev/ttyS0, but you would be wrong, it is /dev/AMA0
You need to give user Pi permission – at the command line prompt…
sudo usermod -a -G dialout pi
That’s a one-off. Done. Now turn off the debugging serial.
Remove references to /dev/ttyAMA0 from /boot/cmdline.txt - which sets up the serial console on boot.
If you have similar references in /etc/inittab do the same. I don’t have that file.
Lastly for Node-Red users, the SERIAL node can be iffy to upgrade. Follow the recommendations from the Node-Red designers if you have trouble. I did have minor trouble on one older installation, not on a new installation. Thanks to their advice the problem went away.
This link is for installing/upgrading Node-Red on the Pi and refers to serial port node issues. https://nodered.org/docs/hardware/raspberrypi
While I’m here – I2c on the PI… (enable if you want to use it) on most boards I’ve set up you need pull-up resistors on data and clock lines, on the Pi these seem to be already fitted. I2c is ready to go.