Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "RPi Serial Connection"

From eLinux.org
Jump to: navigation, search
(Moving section to separate page)
 
(actualy, this text belongs better here then on its own page)
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
Back to [[RPi Advanced Setup]].
 
Back to [[RPi Advanced Setup]].
  
 
+
The Serial Port is a low-level way  to connect to the Raspberry Pi.
The Serial Port is a simple and uncomplicated method to connect to the Raspberry Pi.
+
The communication depends on byte wise data transmission and is generally available even before boot time.
The communication depends on byte wise data transmission, is easy to setup and is generally available even before boot time.
+
  
 
==First interaction with the board==
 
==First interaction with the board==
  
Connect the serial cable to the COM port in the Raspberry Pi, and connect the other end to the COM port or USB Serial Adapter in the computer.
+
'''Note that the Raspberry has no PREBUILT COM port.  Soldering/protoyping and technical knowledge is required ! '''
 +
 
 +
A UART is available in the Broadcom SoC, and its RxD and TxD lines are available on the [[RPi_Low-level_peripherals|GPIOs]] but you need a board or cable to convert 3.3V UART signals to RS-232. They do however connect directly to a USB serial legacy device, provided it uses 3V3 levels. If the device uses 5V levels you will need level converters (which could be simple resistor dividers, or could be specific IC's)  See [http://codeandlife.com/2012/07/01/raspberry-pi-serial-console-with-max3232cpe/ this tutorial] for one example on how to build 3.3V to RS-232 levels converter with a breadboard, MAX3232CPE and five 0.1 uF capacitors. A 5V to 3V resistor divider can be built from a 2K2 (top) and a 3K3 (bottom) resistor.
 +
 
 +
Connect the serial cable to your COM circuitry , and connect the other end to the COM port or USB Serial Adapter in the computer.
  
'''How''' please? I'm led to believe it's wired at the board end, so needs an accessible 9?? pin male|female 232 connector, then some sort of serial to usb dongle. Any more information on this please?
+
* [http://codeandlife.com/2012/07/01/raspberry-pi-serial-console-with-max3232cpe/ RaspPi UART tutorial]
 +
* [http://www.element14.com/community/groups/raspberry-pi/blog/2012/07/18/look-ma-no-display-using-the-raspberry-pi-serial-console RPi UART via 5V FTDI cable and logic level converter]
 +
* (please add others if you find any)
  
Next is this the preferred way to get low level access to the board, or using the usb for kbd and hdmi for screen?
+
The TxD and TXD signals can also be connected directly to similar signals on a microcontroller board like the arduino provided the signals are all at 3V3 levels. It's still a good idea to put 2K2 series resistors in the lines to prevent damage when two outputs are connected together, which could also happen if a GPIO input pin is accidentally programmed as output.
  
 
==Serial Parameters==
 
==Serial Parameters==
Line 50: Line 55:
 
* '''Windows Users'''
 
* '''Windows Users'''
  
Windows Users above Windows XP must download [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html putty] or a comparable terminal program.
+
Windows Users above Windows XP must download [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html putty], [http://en.wikipedia.org/wiki/Tera_Term TeraTerm] or a comparable terminal program.
 
Users of XP and below can choose between using ''putty'' and ''Hyperterminal.''
 
Users of XP and below can choose between using ''putty'' and ''Hyperterminal.''
  
Line 62: Line 67:
 
If you get some output, you are correctly connected to the Raspberry Pi! Congratulations!
 
If you get some output, you are correctly connected to the Raspberry Pi! Congratulations!
  
 +
==Unwanted serial garbage input==
 +
Note that on older software by accident the internal pullups of the RxD GPIO pins were not enabled, this could lead to lots of serial garbage being picked up if the GPIO pin was touched, or even if a finger was nearby. In extreme case this could lead to kernel warnings and other problems.
 +
 +
==Dedicated control of serial port==
 +
there are several minor things in the way if you want to have dedicated control of the serial port on a raspberry pi
 +
 +
the first is kernel boot messages at startup, those are caused by the kernel parameter console=ttyAMA0,115200 set in /boot/cmdline.txt
 +
 +
next is the login prompt, set in /etc/inittab with the line T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
 +
 +
kernel debuging is also on the serial port and i dont know what effect it may have on the end-use, so you may want to turn that off also in cmdline.txt, just remove kgdboc=ttyAMA0,115200
 +
 +
once all of those are off, you can use /dev/ttyAMA0 like any normal linux serial port, and you wont get any unwanted traffic confusing the attached devices
  
 +
some distro's may be setup differently, just double check 'ps aux|grep ttyAMA0' and 'cat /proc/cmdline' to verify ttyAMA0 is not in use anywhere
 +
 
{{Template:Raspberry Pi}}
 
{{Template:Raspberry Pi}}

Revision as of 06:50, 14 August 2012

Back to RPi Advanced Setup.

The Serial Port is a low-level way to connect to the Raspberry Pi. The communication depends on byte wise data transmission and is generally available even before boot time.

First interaction with the board

Note that the Raspberry has no PREBUILT COM port. Soldering/protoyping and technical knowledge is required !

A UART is available in the Broadcom SoC, and its RxD and TxD lines are available on the GPIOs but you need a board or cable to convert 3.3V UART signals to RS-232. They do however connect directly to a USB serial legacy device, provided it uses 3V3 levels. If the device uses 5V levels you will need level converters (which could be simple resistor dividers, or could be specific IC's) See this tutorial for one example on how to build 3.3V to RS-232 levels converter with a breadboard, MAX3232CPE and five 0.1 uF capacitors. A 5V to 3V resistor divider can be built from a 2K2 (top) and a 3K3 (bottom) resistor.

Connect the serial cable to your COM circuitry , and connect the other end to the COM port or USB Serial Adapter in the computer.

The TxD and TXD signals can also be connected directly to similar signals on a microcontroller board like the arduino provided the signals are all at 3V3 levels. It's still a good idea to put 2K2 series resistors in the lines to prevent damage when two outputs are connected together, which could also happen if a GPIO input pin is accidentally programmed as output.

Serial Parameters

The following parameters are needed to connect to the Raspberry. All parameters except Port_Name and Speed are default values and may not need to be set.

  • Port_Name: Linux automatically assigns different names for different types of serial connectors. Choose your option:
    • Standard Serial Port: ttyS0 ... ttySn
    • USB Serial Port Adapter: ttyUSB0 ... ttyUSBn
  • Speed: 115200
  • Bits: 8
  • Parity: None
  • Stop Bits: 1
  • Flow Control: None

The Serial Port is generally usable by the users in the group dialout. To add oneself to the group dialout the the following command needs to be executed with root privileges:

 $useradd -G {dialout} your_name 
  • Super Easy Way Using GNU Screen

Enter the command below into a terminal window

 screen Port_Name 115200
  • Super Easy Way Using Minicom

Run minicom with the following parameters:

minicom -b 115200 -o -D Port_Name
  • Tedious Old-Fashioned Way Using Minicom

Another method to setup minicom is described in the Tincantools Minicom Tutorial


  • GUI method with GtkTerm

Start GtkTerm, select Configuration->Port and enter the values above in the labeled fields.


  • Windows Users

Windows Users above Windows XP must download putty, TeraTerm or a comparable terminal program. Users of XP and below can choose between using putty and Hyperterminal.

First Dialog

If you get the prompt below, you are connected to the Raspberry Pi shell!

 prompt> #

First command you might want try is "help":

 prompt> # help

If you get some output, you are correctly connected to the Raspberry Pi! Congratulations!

Unwanted serial garbage input

Note that on older software by accident the internal pullups of the RxD GPIO pins were not enabled, this could lead to lots of serial garbage being picked up if the GPIO pin was touched, or even if a finger was nearby. In extreme case this could lead to kernel warnings and other problems.

Dedicated control of serial port

there are several minor things in the way if you want to have dedicated control of the serial port on a raspberry pi

the first is kernel boot messages at startup, those are caused by the kernel parameter console=ttyAMA0,115200 set in /boot/cmdline.txt

next is the login prompt, set in /etc/inittab with the line T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

kernel debuging is also on the serial port and i dont know what effect it may have on the end-use, so you may want to turn that off also in cmdline.txt, just remove kgdboc=ttyAMA0,115200

once all of those are off, you can use /dev/ttyAMA0 like any normal linux serial port, and you wont get any unwanted traffic confusing the attached devices

some distro's may be setup differently, just double check 'ps aux|grep ttyAMA0' and 'cat /proc/cmdline' to verify ttyAMA0 is not in use anywhere