未加星标

Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

When it comes to configuring a Raspberry Pi for the first time, there are a few options, many of which can be a pain. This includes configuration of a Raspberry Pi and the smaller Pi Zero. Previously I had written about using a Raspberry Pi as a headless unit , but in that tutorial there was an ethernet requirement. Recently I had written about connecting to a Pi Zero through a standard micro USB cable and SSH , which wasn’t difficult, but it required a few potentially time consuming steps.

Is there a better way to connect to and configure these Internet of Things (IoT) devices?

I wouldn’t necessarily call it a better way, but more of another option towards Raspberry Pi configuration. You can actually connect to the Raspberry Pi and Pi Zero through the available GPIO pins with a USB to TTL serial cable. We’re going to see how to do that.

Going forward, you should note a few things. First off, this was inspired by the Adafruit guide for using a console cable . It didn’t exactly work for me, but it put me on the correct path. I’ll be making a few references to my Raspberry Pi Zero’s GPIO pins, but you should note that in most scenarios, the Pi Zero does not ship with a GPIO header attached. I soldered mine on, and as a first time solderer, it wasn’t so bad.


Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable
Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable
Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable

In the above images you’ll see the GPIO pins on various Raspberry Pi units. The pin configuration is the same for all Raspberry Pi devices regardless the shape, size, or version. You’ll also note the cable we’re going to be using to connect. Let’s break down what the full specs of what we’ll need to be successful.

The Requirements

There are only a few requirements towards being successful with this project. They are found below with a link to purchase them:

Raspberry Pi or Raspberry Pi Zero Male 2×20, 40-pin headers (Pi Zero) USB to TTL serial cable

This guide won’t show you how to solder your own headers, so if you’re not comfortable with the task, you should probably stick with a standard Raspberry Pi. If you haven’t already flashed your Raspberry Pi micro SD card, you can see how to do thishere. No need to go through the other steps after installing Raspbian linux.

Preparing Your Computer for Terminal Emulation

When working with the GPIO, you’ll need special drivers. Using the Terminal or PuTTY on windows isn’t enough to get the job done.

I’m using a Mac, so I won’t be of much help in the realm of Windows and Linux, but from what I understand, the process isn’t too different. On Mac, download the following chipset drivers:

Prolific Chipset Drivers

SiLabs CP210X Drivers

Installing both is safe, but if you know exactly what chipset you’re using, then go for the specifics. When it comes to Linux and Windows, head over to the Prolific and SiLabs websites to get what you need, or get the specifics from Adafruit .

With the computer software ready to go, we need to make some change to our Raspbian setup.

Enabling UART Mode on the Raspberry Pi

At this point we haven’t connected to our Raspberry Pi yet. It is alright if you’re not using a fresh installation.

Insert the micro SD card into a computer and open the mounted boot drive. At the root of this drive should be a file called config.txt . We need to add a particular line to the end of this file to enable UART mode.

enable_uart=1

After the above line has been added, it is safe to plug the card into the Raspberry Pi device that you plan to use. The configurations are now complete and it is time to wire up the unit and connect via your Terminal or PuTTY.

Connecting the Colored Wires to the GPIO Header

Before we start connecting wires, we need to be aware of something. One wire on the serial cable is responsible for powering the Raspberry Pi. If we decide to use this wire, and it is optional, we absolutely must not plug in a standard USB power cable. Providing two sources of power will break your unit.

With that said, your TTL serial cable should have four colored wires with the red wire being for power. The cable configuration should look like the following:


Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable

The red wire, if used, should be plugged into the first pin on the upper level. We’re going to assume the upper level is the row closest to the edge of the Raspberry Pi. The black wire should be attached to the third pin, the white on the fourth pin, and the green on the fifth pin. All pins should be on the upper level.

Once connected, insert the USB into a computer or other compatible power source.

Connecting to the Raspberry Pi with the TTL Serial Cable

By now the cables should be connected and the emulation software should be installed. We just need to establish the connection via the software now.

I’m on a Mac, so I haven’t been able to verify connecting via a Microsoft Windows or Linux computer. On a Mac, open the Terminal and execute the following:

screen /dev/cu.usbserial 115200

This command differs to the commands I’ve seen elsewhere on the internet. To be fair, I am running El Capitan (10.11.6), but I think it will be consistent through the different versions as well. If you don’t have /dev/cu.usbserial on your machine, see what other /dev/cu.* files you have and execute what is appropriate.


Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable

After connecting, if you see a blank screen, don’t worry. Just hit the enter key and the shell information should appear on the screen prompting you to sign in.

As of right now, the first-time credentials for Raspbian will be pi as the username and raspberry as the password.

For Linux and Windows, I encourage you to visit the

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: Raspberry PiLinuxWindowsUAHead
分页:12
转载请注明
本文标题:Connect To A Raspberry Pi And Pi Zero With A USB To TTL Serial Cable
本站链接:http://www.codesec.net/view/533605.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(33)