Raspberry Pi-serial port configuration method

Source: Internet
Author: User

Is Raspberry Pi able to use the serial port? The answer is yes. The specific method is as follows:

1. The third, fourth, and fifth ports in the first row of Raspberry Pi are respectively, that is, ports 6, 8, and 10 are respectively, TX and RX, respectively, and connected to the connected device. Note that the TX of Raspberry Pi is connected to the RX from the device, and the RX of Raspberry Pi is connected to the TX of Raspberry Pi.

2. There is only one serial port on Raspberry Pi. The system uses it as the debugging port by default, so it cannot be programmed and used as a common serial port. You need to remove the configuration of the debugging port before using it. Two files need to be modified here

2.1 Modify/boot/linline.txt

Enter the following command on the terminal:
  sudo nano /boot/cmdline.txt
Delete the red part after logging = 0 console = ttyAMA0, 115200 kgdboc = ttyAMA0, 115200 console = tty1 root =/dev/mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait is deleted, save and exit dwc_otg.lpm_enable = 0 console = tty1 root =/dev/mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait.
2.2 Modify/etc/inittab and enter the following command on the terminal:
 sudo nano /etc/inittab
After opening, comment out the last line and add a # sign before it. # T0: 23: respawn:/sbin/getty-L ttyAMA0 115200 vt100

3. After modification, you need to install a mini-com on Raspberry Pi. Here, mini-com is a serial debugging tool on the Linux platform, which is equivalent to a serial debugging assistant on Windows.

3.1 run the following command to install minicom:

sudo apt-get install minicom 

3.2 after installation, You need to configure minicom. The configuration file requires the root permission. Otherwise, the configuration parameters cannot be saved. Enter the following command in the command line:

sudo passwd root
After executing this command, the system will prompt you to enter the root password twice, enter the password you want to set, and then execute
sudo passwd --unlock root
In this way, the root account is unlocked.

3.3 switch to the root account, open the command line again, and enter the minicom parameter configuration command

minicom -s
In Serial Port Setup, the third item in the main menu, go to the next menu, select according to the prompt letter of the menu item, and press A to change the Serial Port device to/dev/ttyAMA0

, Press E to change the baud rate to 9600 or the expected value. After setting, return to the main menu and select Save Setup as Dfl.

Then select Exit. If it is normal, you can send and receive data through the serial port. Here, my Raspberry Pi is connected to a PC, and I have successfully sent and received data using the serial port debugging software of the PC.

Tips: press CTRL + A, and then press Z to view the help of minicom.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.