Editing the /etc/network/interfaces file is not needed, and in fact, it shouldn't be modified. If you need a static IP that's done in /etc/dhcpcd.conf now. If you are using DHCP you should not need to edit anything but /etc/wpa_supplicant/wpa_supplicant.conf in Jessie or Stretch. You can actually place that file in the small FAT32 boot partition to connect to your wireless network automatically.
This is the procedure I use for setting up headless boot with SSH and wireless network. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3, or a Raspbian compatible USB WiFi dongle on other models (tested on an old model B, Pi2 and Pi Zero). Everything is done before you boot the SD card, and can be done on a Windows or Mac computer which only has access to the small FAT32 boot partition of a Raspbian SD card.
- Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
- Grab the Etcher software from https://etcher.io/
- Install Etcher and use it to write the Raspbian image to your SD card. You don't need to extract the image or format the card prior to writing. Just choose the Raspbian .zip, pick your SD card and write (if you have trouble, verify the SHA256 checksum of the download).
- Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the SD card.
- On that small partition, create a file with the name ssh (or ssh.txt).
- To connect to a wireless network, create another file on the FAT32 partition called wpa_supplicant.conf which has the following inside:
Code: Select all
ssid="Your network SSID"
psk="Your WPA/WPA2 security key"
- Edit country=, ssid= and psk= with your information and save the file.
- Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. You can try to connect to the Pi with ssh [email protected]
(or raspberrypi.local), and if that doesn't work, login to your router to find the Pi's IP address. If you have an ASUS router they have a nice phone app to access and control the router.
If this doesn't work, then check your router for security settings like MAC address filtering or wireless client/AP isolation. Also, make sure you are editing wpa_supplicant.conf with a pure text editor (anything that adds hidden formatting codes will mess it up).
Another nice tool to have is a serial console cable which will let you monitor output and login to the Pi without a network connection. I use a CP2102 USB TTL serial adapter, which is compatible with the Pi's 3V3 GPIO and can be found on ebay for less than $2 (or $5-$10 on Amazon).
Here is my Pi Zero connected to an old Netbook with the CP2102 adapter (with a pcDuino WiFi dongle for wireless).
For the Pi3 or Zero-W you'll have to disable Bluetooth to restore GPIO serial console output, but it's plug-n-play with other models. To disable Bluetooth add dtoverlay=pi3-disable-bt to config.txt, and for the Desktop version of Raspbian, add enable_uart=1 to enable the serial console.
Search ebay for CP2102. There are zillions of them and prices are all over the place. As long as it's a CP2102 chip based model it should work the same as any other. Typically they run in the $2-$5 range, but there are a few for under $2, and even some under $1.50.
There are 5 and 6 pin models. The 5 pin models are mostly missing the DTR line, which is important for Arduino but not needed for the Pi serial console (Pi only needs RXD, TXD and GND, which they all have). So if you don't care about Arduino compatibility, get either type. The ones I have are all 6 pin, but even some of those don't have DTR, so it's a little whacky because they all aren't wired the same.
As long as you follow the labels on the output pins you'll be okay. The connections from the USB TTL adapter to the Pi are:
GND (ground) > GPIO pin 06 (GND)
RXD > GPIO pin 08 (TXD)
TXD > GPIO pin 10 (RXD)
Note that in my picture the Pi Zero has four connections, and no micro-USB power cord. The CP2102 also has 3V3 and 5V outputs, so for the Zero I connected the 5V to GPIO pin 02 (5V) to provide power. It would probably be okay for a model A or B as well (although it would bypass the power protection), but a Pi2 or Pi3 should have its own power supply and only the 3 connections listed above.
For a serial terminal under Linux I install screen and open the serial terminal with sudo screen /dev/ttyUSB0 115200. Under Windows you can use PuTTY with Serial as the connection type, the COM port number under Serial line, and 115200 as the speed (check the port number in Device Manager). With Windows 10 you can also use the Windows Subsystem for Linux (WSL), but you'll need the Fall Creators Update to use serial ports. The procedure is similar to Linux, but the COM port will be ttyS# (note the capital S), with # being the port number Windows 10 assigned to your adapter (if Device Manager shows COM4, you'll use sudo screen /dev/ttyS4 115200 to open the serial terminal). WSL is still beta, so PuTTY might be a little more reliable, but I have found that hitting enter a few times will often connect when the terminal window isn't showing any output.
Linux supports the CP2102 directly. Windows will need a driver: CP210x_Windows_Drivers.zip
(not sure about Mac).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?