Serial connection – RPi

In this post:
1) Make serial connection to RPi
2)Troubleshooting

One useful way to connect to Raspberry Pi is using the serial connection.

1) Make serial connection to RPi

For making the connection PC RPi, you need a cable to make the conversion USB serial

You can build your own cable (doing a quick search I found: Make cable (I haven’t tested it)) or you can buy a new one (for example: Buy cable).

serial_usb_cable
(photo from: source)

First, verify in your Raspberry Pi if you have the serial connection enable under the raspi-configuration:
$sudo raspi-config
(choose advance options)
(choose serial)
(yes) – you want to enable it

Getting the hands dirty:

With your raspberry pi unplugged (from the mains) make the following connections:

(photo from: source)

The pins:

photo from: source

Attention to this step: You have to connect the TX of the cable with the RX from the RPi. I only connected three pins: GND, RX and TX.

Before turn on the RPi, make sure that the cable uses 3.3V levels.
To power the RPi I use the power supply connected to the grid.

To “talk” with your RPi you can use PUTTY (PUTTY, or screen (Screen) or another similar tool suitable for you.

1.1) Using PUTTY::

The serial line (depends on your OS – Windows, Linux, MacOS (I will focus the steps on Linux and Windows)).

For Linux users:

On terminal do:
sudo putty

Note: do not forget to run with sudo. Generally, hardware requires the sudo permission.

On Linux, the serial line, typically, will be: /dev/ttyUSB0
If not, search with this code: ls -l /sys/bus/usb-serial/devices
Then, specify the baud rate: 115200.

(continue in step 1.1.1)

For Windows users:

Run PUTTY as administrator (right click on the icon).

On the serial line you have to specify a COM port – to find which one, go to the Device Manager and see under the Ports( COM & LPT) which is the port use by your cable, and write it on the “serial line” field in PUTTY.

(continue in step 1.1.1)

1.1.1)Continuation – Linux and Windows Users:

In the PUTTY window verify the following parameters -> Connection – Serial:
Bits: 8
Parity: None
Stop Bits: 1
Flow Control: None

[Optional] Click on Terminal category and check:
Implicit CR in every LF
Implicit LF in every CR

[Optional] Go to Session category:
Write on the input field Saved Sessions, and click save. Next time you run PUTTY, you just have to select the session and click load, to have the previous configurations.

Click Open and if everything went OK- you have an open serial connection with your Raspberry Pi.

Done 😉

1.2) Using screen [Linux]

sudo screen /dev/ttyUSB0 115200

2) Troubleshoot

2.1) Cable:
2.1.1) Verify cable logic levels: they must be 3.3 V
2.1.2) Run loopback test -> connect the cable to your usb port and then the TXD pin must be connected to the RXD pin. This allows the data to flow from the transmission (TX) to the reception (RX) pins. If you are able to see the data (under PUTTY, or similar) means that you can properly send and receive data.

2.2) Verify connection:
2.2.1) Verify if you are connecting the RX from the cable to the TX of the PI, and the TX to the RX of the PI.

2.3) Permission:
2.3.1) Run as sudo or administrator

2.4) Get the correct serial line device:
2.4.1) Check which Port is the RPi connected

2.5) Check the baud rate and the other parameter values

I hope, that you find the solution for your problem 😉

Done 😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: