The more we know the harder it is to defeat us!

Raspberry Pi is a small factor fully-featured computer. It can be used for multiple purposes such as a controller.

In most of applications it is necessary to use some kind of communication interface. Raspberry Pi delivers, among others, UART, SPI and I2c. However, UART (serial port) is most commonly used if you just want to send some data between RPi and other devices. While using SPI or I2c in i.e. python script is rather straightforward, using serial port, or making it to work, isn’t so easy as it might seem.

First of all, you have to add user to two groups: tty and dialout by typing in terminal:

After that you need to disable system service that is using the serial port with following command

When you successfully complete above steps you have to remove any ttyAMA0 (serial port device in /dev) related entry in /boot/cmdline.txt. This will prevent RPi from using the serial port as a debug serial port. The debug serial port is a simply a terminal available on GPIO pins. If something goes wrong with your RPi or you do not have LCD screen with HDMI connector you can always use serial adapter to communicate with your mini computer by using those means.

To apply all the changes and ensure yourself that everything is working fine you have to reboot with

When the system is running once again you can test if the serial port is available and ready to use. For this you can install minicom — a small application to communicate over serial port.

You can try it out with:

Now you are ready to write some python scripts.

One Response to Using serial port on Raspberry Pi

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Donate

If you like my blog please consider a small donation.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 235 other subscribers