Raspberry Pi TXD and RXD, USB serial port

For Raspberry Pi serial port settings, because I want to use Raspberry Pi with an external device connected to the serial port is about to set common serial port .

1, disable the onboard Bluetooth

 

     First, open your Terminal, enter what statement:

   sudo systemctl disable hciuart

 

     Then, edit the document /lib/systemd/system/hciuart.service, the command is as follows:

   sudo nano /lib/systemd/system/hciuart.service

 

      Document all the "ttyAMA0" changed to "ttyS0", a total of two to amend, modify after a good save and exit. (Note: If you do not modify the place do not control)

 

 2 , restore the serial port and the serial port is set to Universal

      First, edit documents /boot/config.txt, the command is as follows:    

sudo nano /boot/config.txt

 

       At the end of the document, add the statement:

 

    dtoverlay = miniuart PI3-bt

       Then, we edit the document /boot/cmdline.txt, the command is as follows:

sudo nano /boot/cmdline.txt

 

       The document with the following contents completely replaced (the specific operation is to delete the original document superfluous statement):

dwc_otg.lpm_enable=0  console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4  elevator=deadline fsck.repair=yes   rootwait

 

Here we should pay attention to: the replacement is directed to the common serial port settings, this content is actually closed the serial console, because only in this way before the serial port into a general-purpose, namely the Raspberry Pi can connect an external device. If you want to use a serial connection, log in and control Raspberry Pi, you need to enable seiral console.

 

Finally, we execute the following command in order to complete all the configuration and reboot:

  1.     sudo apt-get update
  2.  
  3.     sudo apt-get upgrade
  4.  
  5.     sudo reboot

     After completing the above steps, we can now connect through an "ttyAMA0" with external devices.

Third, the serial test

        In this section, I will use the laptop and connect raspberry pie, so as to achieve the purpose of Test serial port can be used normally. Among them, computers need to use USB to TTL module to achieve connection with the raspberry pie.

 

        1, a computer terminal

 

        My computer system is win10, use USB to TTL module model CP2102, the driver of the module can be found and downloaded on the CSDN. After installing the driver, you can directly insert the module into the computer USB port, the computer's "Device Manager", we can see the "port" option, after opening the CP2102 will see the device and display its port number (example : my port number is COM3), right-click and select "properties" at the device, if you can see its "working properly", then prove successful driver installation module and can be used normally. Then the next we can be specific "port", its baud rate to 115200 or 9600 may be other options unchanged. Finally, we need to download a "serial debugging assistant" as the computer serial port terminal debugging software.

 

        2, Raspberry Pi end

 

        First, open the Terminal raspberry pie, utilities available when you download a debug: minicom, command is as follows:

 

    sudo apt-get install minicom

        We can do basic configuration of the serial port in minicom, for you can save the configuration to the default settings, then execute the following commands on the serial port configuration in minicom:

   sudo minicom -s

        In the pop-up menu, select "Serial port setup", then we can make changes to these options by typing different letters. We need to change the serial port / dev / ttyAMA0, and then change the baud rate of 115200 or 9600 (to ensure that the same baud rate and external devices can be connected), and to ensure that the bottom two options are: NO . Finally, click the Enter button to return to the previous menu, and select "Save as df1" option, so that you can just change the configuration of the default configuration of minicom. After we configured the exit minicom.

 

 

        After completing the above preparations, now we can begin to test the specific serial port. First, the USB module connected to TTL Raspberry Pi GPIO port, RXD and TXD connection of the module to send raspberry, TXD and RXD connections of the module to send raspberry, raspberry connection module to send a GND mutually. Note that, when connected only connection the three interfaces, but do not connect the power port, Raspberry Pi uses its own external power supply, or easy to burn out because the voltage instability board. After connecting the module into the computer, to send the power is turned on raspberry. Turn on the computer end of the "serial debugging assistant", choosing the port number (can be viewed in the "Device Manager"), then click on the menu bar of the "play" button to indicate a connection start, at the same time, we in the Raspberry Pi Terminal command is used to open minicom:

      sudo minicom

 

            After opening, you can enter a random, then you will find just the information sent by the computer end of the "serial debugging assistant", and vice, and you can also send in the computer-ended input, and saw in the raspberry pie.

 

Guess you like

Origin www.cnblogs.com/SkystarX/p/12286033.html