By default Raspbian configures the Raspberry Pi serial port
(GPIO14-GPIO15) to provide boot-up information. It also allows you to
login via a connected device. If you need to use the Pi’s serial port
for something else (i.e. a specific add-on board) you will need to
disable this default functionality.
The Broadcom UART appears as
/dev/ttyAMA0 under Linux. There are several minor things in the way if you want to have dedicated
control of the serial port on a Raspberry Pi. This link describes the process for free the serial port:
http://elinux.org/RPi_Serial_Connection. There is a brief script to automate the same steps:
https://github.com/lurch/rpi-serial-console.
If you want to test the serial port to send/receive data:
- First have a look at the permissions on that file, lets assume you are using
/dev/ttyAMA0:
ls -l /dev/ttyAMA0
- You will want read.write access, if this is a shared system then you
should consider the security consequences of opening it up for everyone:
- You have to setup the baud rate with the next instruction:
stty 115200 -F /dev/ttyAMA0
- A very simple crude method to write to the file (send data to the serial port), would use the simple
echo command in one terminal:
echo -ne 'ri_07_02' > /dev/ttyAMA0
- And to read use the
minicom command (maybe with another terminal):
minicom -b 115200 -o -D /dev/ttyAMA0