Introduction: Headless Pi - Getting Your Raspberry Pi Started Without Any Additional Hardware

Hey there,

The reason you landed up here is, I guess, that you are a lot like me! You don’t want to go easy on your Pi -- plug the Pi into a monitor, hook up a keyboard and a mouse, and voila!…Pfft, who does that?! After all, a Pi is a “pocket-sized PC”, and ain’t no monitor gonna fit in my pocket. So, what do we do? We tinker! We figure out a way to use our laptop’s display, keyboard and trackpad as our Pi’s peripherals.

Here’s what we’ll be needing:

  • Laptop
  • Raspberry Pi
  • Card reader
  • Micro-SD card
  • Micro-USB cable
  • USB to TTL serial Cable (optional)
  • USB WiFi Dongle (optional; Pi 2 and below)
  • Ethernet Cable
  • Wireless Internet Connection

Step 1: Installing Raspbian

If you haven’t already installed an OS onto your board, now would be a good time to do so. Check the official guide or follow these steps:

Windows:

  1. Download the latest Raspbian image from the Raspberry Pi website Downloads page.
  2. After downloading the .zip file, unzip it to get the image file (.img) for writing to your SD card.
  3. Insert the SD card into your card reader and plug it into your laptop.
  4. Download the Win32DiskImager utility from the Sourceforge Project page as a zip file. Extract the executable from the zip file and run the utility
  5. Select the image file you extracted earlier.
  6. Select the drive letter assigned to your SD card in the device box. Be careful to select the correct drive; if you get the wrong one you can destroy the data on your computer's hard disk! If you are using an SD card slot in your computer and can't see the drive in the Win32DiskImager window, try using an external SD adapter.
  7. Click Write and wait for the write to complete.
  8. Exit the imager.

Ubuntu:

  1. Download the latest Raspbian image from the Raspberry Pi website Downloads page.
  2. After downloading the .zip file, unzip it to get the image file (.img) for writing to your SD card.
  3. Insert the SD card into your card reader and plug it into your laptop.
  4. Right-click on the image file you extracted earlier and select Open with -> Disk Image Writer
  5. Select your SD card from the list and hit Start Restoring. Be careful to select the correct drive; if you get the wrong one you can destroy the data on your computer's hard disk!
  6. Enter your password to grant root privileges and wait for the write to complete.
  7. Exit the utility.

Do not eject the SD card yet! There are just two more things to do.

  1. In order to enable shell access over SSH: browse to the boot directory and, using any file editor, create an empty file named ssh (without any file extension)
  2. In order to enable serial communication: browse to the boot directory again, open up the config.txt file using any file editor and add the following line (without the quotes) to the end of the file "enable_uart=1". Save the file and you're done!

Step 2: Getting to Know Your Pi's IP

Once you are done installing the OS, simply insert the micro-SD card into your Pi and power your board up using the micro-USB cable. Now, assuming that your laptop has a wireless internet connection (WiFi/USB dongle), plug in one end of the Ethernet cable to your Pi and the other to your laptop.

Method 1 (Ubuntu)

  1. Open the "Network Manager" and click on "Edit Connections"
  2. Select "Wired Connection 1" and click on "Edit". If you do not have a wired connection setting, click on "Add"
  3. Under the "Wired" tab, set the "Device MAC Address" field to xx:xx:xx:xx:xx:xx (eth0) option from the drop-down list
  4. Under the "IPv4 Settings" tab, set the "Method" field to "Shared to other Computers" option from the drop-down list
  5. Open up the terminal and run ifconfig to note the IP assigned to eth0
  6. Now bringing up the ARP table using the command arp -a, scroll to the interface specifying the IP assigned to eth0 and examine the entries to figure out the IP assigned to your Pi (192.168.1.109, in my case). Ping the IP to verify
  7. Alternatively, after step (4), you could have directly pinged raspberrypi.local to determine your Pi’s IP or you could have used nmap

Method 1 (Windows)

  1. Go to the "Network and Sharing Center" and click on "Change Adapter Settings"
  2. Right-click the "WiFi adapter" and click on "Properties"
  3. Under the "Sharing" tab, check the Allow other users to connect through this networks Internet connection option and select the appropriate Ethernet adapter from the list. You should now see that the connection has been marked as Shared
  4. Right-click the "Ethernet adapter" and click on "Properties"
  5. Under the "Networking" tab, double-click the "Internet Protocol Version 4" option and ensure that some dynamic IP has been assigned to the Ethernet port
  6. Open up the command prompt and issue a ping command on the broadcast address of the assigned IP. Since the IP assigned to the Ethernet port on my laptop was 192.168.137.1, I will simply ping 192.168.137.255
  7. Now bringing up the ARP table using the command arp -a, scroll up to the interface specifying the IP assigned to the Ethernet (192.168.137.1, in my case) and examine the entries to figure out the IP assigned to your Pi (192.168.137.99, in my case). Ping the IP to verify
  8. Alternatively, after step (5), you could have directly pinged raspberrypi.mshome.net to determine your Pi’s IP

Method 2 (Windows)

If for some reason the above method didn’t work for you, try bridging the two networks.

  1. Open up the adapter settings again, enter the WiFi properties and disable sharing.
  2. Enter the Ethernet properties like before, double-click the "Internet Protocol Version 4" option under the "Networking" tab and select the option to "Obtain an IP address automatically"
  3. Now, go back to the adapter settings, highlight both the connections (WiFi and Ethernet), right-click and select the option "Bridge Connections"
  4. You should see a new connection, called Network Bridge, appear.
  5. Open up the command prompt and run ipconfig. Scroll down to the entry named Ethernet adapter Network Bridge and note down the IP address
  6. Since, in my case, the IP assigned to the Network Bridge is 192.168.1.101, the IP assigned to the Pi should be within the range 192.168.1.2 to 192.168.1.254 (192.168.1.1 is the default gateway and 192.168.1.255 is the broadcast address). Now, use any IP scanner to search for all active clients within this IP range and look for the IP assigned to the Pi.
  7. Alternatively, you may try assigning a static IP to your Pi.

Method 3 (Ubuntu in a VM)

Consider this, you’ve got Ubuntu installed in a VM running on a Windows host and you need to access your Pi via Ubuntu i.e. you must first figure out a way to share your Ubuntu’s internet connection (which is nothing but the underlying network connection of your host translated to give your guest access to the external network; let’s not get into the details) with your Pi. This can be troublesome at times. However, I recently came across a really simple solution -- Network Bridging.

Method 4 (Ubuntu/Windows)

Alternatively, if you haven’t a free Ethernet port, you can directly connect your Pi to the network via your home Router or Ethernet Switch.

  1. Power your Pi and connect it to your network via an Ethernet port on an accessible switch/router, connected to your home network, using an Ethernet cable.
  2. You should see the PWR and ACT LEDs blinking implying that the Raspbian image is being booted up. You should then see the green "LNK" LED and the "10M" orange LED light up near the Ethernet port on your Pi implying that an IP address has been assigned to it by your router’s DHCP.
  3. Now, to figure out this IP simply visit your router’s page by entering the router’s local IP address (192.168.1.1 for iBall) in your browser. Log in and check the DHCP client list for the IP assigned to your Pi (Look for an entry that lists "Raspberry Pi Foundation", probably next to its MAC address). If this doesn’t work try using an IP Scanner such as nmap.

Step 3: Accessing the LX Terminal

Bringing up the shell is easy once we have our Pi’s IP. We’ll be using SSH to remotely login to our Pi and access the LX-Terminal. To do so,

Windows users will have to install Putty, an easy-to-use SSH client.

  1. Once installed, run Putty, set the connection type to SSH and port value to 22, enter your Pi’s IP and hit Open.
  2. Select “Yes”, if asked whether you trust this host and you will see the LX-Terminal prompting you for the login details.
  3. Go ahead and enter “pi” as the username and “raspberry” for the password (the password won't be visible when you type it in, so don't panic)
  4. Ping google.com to check if the internet’s working, and voila!

Linux users have the functionality built-in.

  1. Open up the terminal and run the command ssh pi@x.x.x.x (x.x.x.x being your Pi’s IP) or try ssh pi@raspberrypi.local
  2. Type in “yes”, if asked whether you trust this host, hit return and type in your Pi’s password (default password: “raspberry”)
  3. Ping google to check if the internet’s working, and voila!

Bonus: Shell Access over a Serial Connection

In case your Ethernet port is busy, you can utilize your Laptop’s USB port to establish a Serial connection with your Pi. To do so, you are going to need a USB to TTL serial cable or a USB to Serial device such as the FTDI FT232 basic breakout board.

Since Windows does not include a Terminal application that would allow us to connect over serial, we’ll be making use of Putty. We’ll also need to install FTDI Drivers.

  1. Run wires from the TTL header to the corresponding pins on the chip. Be sure that the pins are routed correctly as shown in the table.
  2. Connect the other end of the TTL cable to a USB port on your PC. Open the Device Manager and look under “Ports (COM & LPT)” to check the COM number assigned to your Pi.
  3. Run Putty, set the connection type to Serial, enter the assigned COM number, set the speed to 115200 and hit Open.
  4. Select “Yes”, if asked whether you trust this host and you will see the LX-Terminal prompting you for the login details.
  5. Go ahead and enter “pi” as the username and “raspberry” for the password

Linux users may need to install Screen.

  1. To check if you’ve already got screen installed on your Linux machines, simply open the Terminal type screen and hit return. Should you get an error, run the command sudo apt-get install screen to install Screen.
  2. Next, install the FTDI Drivers and you are good to go. Run wires from the TTL header to the corresponding pins on the chip. Be sure that the pins are routed correctly as shown in the table.
  3. Connect the other end of the TTL cable to a USB port on your PC. Open the terminal and run the command sudo screen /dev/ttyUSB0 115200 and hit return.
  4. Type in “yes”, if asked whether you trust this host, hit return and type in your Pi’s username and password (default username: “pi” default password: “raspberry”)

Alright, we have access to the shell, but what about the internet?! Since we haven’t used an Ethernet cable to connect to our Pi, there is no way we can share an internet connection with it. However, we can use a USB WiFi Dongle (Pi 3 has built-in WiFi) with our Pi to connect to a WiFi and access the internet.

Step 4: Accessing the LXDE Desktop

Now that we have access to the Shell, let’s move forward and get our hands on Raspbian’s Desktop GUI environment, called LXDE. We can access the LXDE desktop over HDMI by typing "startx" in the command line window. However, this won’t work over SSH. Luckily, we can still remotely access the LXDE Desktop via VNC.

Windows

  1. Begin by installing VNC server on the Pi. Type sudo apt-get install tightvncserver in the SSH shell
  2. Start the server on your Pi by issuing the command vncserver :1 (start vnc server on display 1). You will now be prompted to enter an 8 character password which will be used each time you access your Pi remotely (the password won't be visible when you type it in, so don't panic). If prompted to enter a read-only password hit “n” and return.
  3. Next, install the VNC client on your laptop as you would normally install any other software.
  4. Run the client, select "New Connection" under the "File" menu, enter your Pi’s IP (192.168.1.108:1, in my case), give a name to the connection (say, Raspberry Pi) and click on "Save".
  5. Double click on the click on the connection just created, click on "Connect", enter the previously configured password when prompted, and there you go, the LXDE Desktop!

Ubuntu

  1. Begin by installing VNC server on the Pi. Type sudo apt-get install tightvncserver in the SSH shell
  2. Start the server on your Pi by issuing the command vncserver :1 (start vnc server on display 1). You will now be prompted to enter an 8 character password which will be used each time you access you Pi remotely. If prompted to enter a read-only password hit “n” and return.
  3. Next, install the VNC client on your laptop. Open a new terminal and run sudo apt-get install xtightvncviewer
  4. Once the installation is complete, run the client using the command xtightvncviewer
  5. This should bring up a small message box. Type in your Pi’s IP and display number (192.168.1.109:1, in my case), hit return and you will be prompted to enter the previously configured password. Type in the password, hit return again and there you go, the LXDE Desktop!