USB to Raspberry Pi using an FTDI cable
Note: This guide should no longer be used. Most distributions allow some files to be edited on the microSD card prior to inserting the microSD card into the Raspberry Pi. Specifically, SSH and Wi-Fi can be enabled, and then the Raspberry Pi distribution can be set up using only a laptop.
FTDI is semiconductor company specializing in USB connections. An FTDI USB cable allows a PC or a MacBook to communicate with a Raspberry Pi.
Most Raspberry Pi distributions (e.g., raspbian, dietpi) require a monitor, keyboard and mouse to set up the distribution. However, once Wi-Fi and SSH are working, these devices are no longer needed.
Every time I start a new Raspberry Pi project, I lug out a monitor, keyboard and mouse and find a place to set them up. After completing my third Raspberry Pi project, I thought there must be a better way.
First Pass instructions are indicated by FP. On Subsequent setups (SS) skip all the FP steps
Unique Parts:
FTDI TTL-232R-RPI Serial to USB cable from Mouser $15
Step 1. Raspberry Pi distribution
If FP: Download a Raspberry Pi distribution and burn to a microSD card using Etcher
If SS: Burn image saved in last step to microSD card using Etcher. Go to Step 6
Step FP 2. Setup Raspberry Pi
Setup a Raspberry Pi with the appropriate connections following your preferred instructions.
microSD card installed
HDMI cable connected to a monitor
Keyboard and Mouse
power cord
Step FP 3. Setup the distribution
Setup the distribution following your preferred instructions.
The first setup requires a keyboard, monitor and mouse. The final step in this instructable is to save an image of the setup distribution. Subsequent setups can start with the configured distribution. So, a monitor, keyboard and mouse are not required.
At the end of setup, you should have changed the following:
username = ♣your-username♣
password = ♣your-password♣
hostname = ♣your-hostname♣
Step FP 4. Enable serial communication
Usually, by default, serial is disabled. Enable this service so we can use it in the future.
$ sudo nano /boot/cmdline.txt
In the file, add before console=tty1
console=ttyAMA0,115200
CTRL-o, ENTER, CTRL-x to save the file and exit
Enable the serial service and restart the Raspberry Pi
$ sudo systemctl enable serial-getty@ttyAMA0.service $ sudo reboot -h 0
Step FP 5. Attach FTDI USB cable
If not plugged-in, plug-in the FTDI USB to serial cable
USB serial I/O cable (see image above). The outer corner of the Raspberry Pi has pin 2. The outer row closest to the edge are even numbered pins (2, 4, 6), and the inner row are odd numbered
Ground = Black wire, pin 06
Tx = Yellow wire, pin 08
Rx = Red wire, pin10
Step 6. Determine USB Port being used by the MacBook
Determine USB Port being used by USB-Serial adapter. My MacBook uses a chip from FTDI.
Open a terminal window on a MacBook
There are a lot of devices in /dev. Use this command to identify the device (in this case, it is FT9314WH):
$ ls /dev/tty.* /dev/tty.Bluetooth-Incoming-Port /dev/tty.usbserial-FT9314WH
Here is an alternate way to discover:
$ ls /dev | grep FT | grep tty tty.usbserial-FT9314WH
If neither of the above work, then try this:
Insert USB cable into MacBook, and run:
$ ls /dev | grep tty
Unplug USB cable, wait a few seconds and run:
$ ls /dev | grep tty
If you are able to identify differences in the listing after plugging and unplugging the cable, then this is probably the USB port being used.
Step 7. Setup terminal window preferences
Open (or continue using) terminal window on MacBook.
See the image above and set up the terminal window preferences.
Terminal, select Preferences, click Advanced tab
xterm and vt100 work, but ansi works better when using nano
Set Western ASCII instead of unicode (UTF-8))
In a terminal window enter:
$ screen /dev/tty.usbserial-FT9314WH 115200
Using terminal window on MacBook, login in to Raspberry Pi:
username = ♣your-username♣
password = ♣your-password♣
Step FP 8. Save the distribution image
Power down the Raspberry Pi
$ sudo shutdown -h 0
Wait until the Raspberry Pi lights stop flickering and remove the micro USB power cord
Remove the microSD card, insert the microSD card into a USB card reader, and insert the card reader into a MacBook. Save the image so it can be used on subsequent setups
Notes:
A USB-serial cable can drop characters. If characters are dropped you may not get a prompt, press Return or enter username and press Enter.
If recovery mode appears, then micro SD card is not set up correctly. Start over.
Prompts:
Diet Pi's prompt for root user # (on raspbian recovery mode uses a # prompt)
Raspbian's and Diet Pi's normal prompt for a non-root user is $