As has been answered in the comments, Raspberry Pis don't generally have a /dev/ttyS0
device. The GPIO serial port is typically /dev/ttyAMA0
, although that's not always the case on a Raspberry Pi 3.
All available serial ports belong to the dialout group, so for convenient read/write access it's best to issue this command once:
sudo usermod -a -G dialout pi
(This may be a default now on Raspbian.) You need to log out and back in again for this change to work, but then it should be valid indefinitely.
Serial ports can also have aliases. /dev/serial0
(or dev/serial1
by default on a 3) points to /dev/ttyAMA0
. There are also the /dev/serial/by-path/*
and /dev/serial/by-id/*
devices that can be helpful for identifying particular ports. If you have multiple USB serial devices, the system will allocate ttyUSB0
to the first one identified, ttyUSB1
to the next, and so on. These aren't always in the same order, so the by-path and by-id aliases help you find the right physical port.