Friday, August 4, 2017

Raspberry PI without monitor and Wired Connection

Today I bought a new Raspberry PI 3 Model B. I wanted to run a bare version of Raspberry PI, that works without using any peripherals (keyboard, monitor, mouse etc.). To reach that goal, these are the steps that I followed:


Downloading the Proper OS

As I was planning to use headless version(without GUI), I downloaded the Lite version of the Raspbian OS from here.

Writing Image to SD Card

Although my laptop have a SD card reader, I didn't have a micro SD to SD card converter. Thereby I had to use my mobile phone as card reader. After several trial and error I realized the best suggestion is to put your phone in USB storage mode. This avoids any issue related to not writing in root partition etc.

Arrange SSH connection at boot

Enable SSH by placing a file named “ssh” (without any extension) onto the boot partition of the SD card:

Boot your PI

At next step boot your PI by connecting power cord or micro USB and wired Ethernet connection. Please note that, wired connection is mandatory only for the first time. After that we will config the system to use wireless connection available at raspberry pi model 3.

Find your IP Address

Find out your IP address. For TP-Link routers, it's under DHCP > DHCP Clients List. The host name for the device will be raspberrypi. Please check the IP address allocated here shows permanent and we will get back on how to do that and why(This screenshot is taken after wlan connection).


SSH into Raspberry PI

Use regular SSH client(such as Putty). The default credentials for Raspbian are as follows:
user : pi
 password : raspberry

 Configure to use WiFi

Edit the file "/etc/network/interfaces" using your favorite editor(vi, nano etc) as root. At the end of file add this text
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "Your Wi-Fi name" // replace with your Wi-Fi name
wpa-psk "Your Wi-Fi password" // replace with your Wi-Fi password
 After everything is configured go for a reboot of raspberry pi. Although general instruction says only restarting the network would do, but I didn't have much success. Please let me know in comments if you have any success with that.
sudo reboot

Make the Wi-Fi IP permanent

After reboot the system should automatically attach to the router and visible in previous client list. In order to save and connect to my PI permanently, I suggest to fix the IP address permanently. To do that go to DHCP > Address Reservation or similar in your router.


After these steps you should be able to boot into your Raspberry PI in headless mode, without using any monitor or wired connection. The only thing I wish is if I could power it over Wi-Fi as well :P. Happy hacking!!!

References:
  1. https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0
  2. https://unix.stackexchange.com/questions/92799/connecting-to-wifi-network-through-command-line