RaspberryPi Headless Setup SD Card Preparation

You may have heard of, bought or thinking of doing a project on RaspberryPi to enter the world of IoT. RaspberryPi is the first step to dive in head first into Internet of Things. It is the most simplest piece of technology that you can get your hands on to develop quick and efficient prototypes.

IoT devices are generally small and basic equipments, most of the times without event a display. Most of the times you will be using RaspberryPi as well, without a display or a monitor. You need to remotely access these computers to configure them and work your way up.

The makers of RaspberryPi provides – Raspbian Linux, which is a Debian based operating system. It is the official Linux version which has been recommended to be used. Installing Raspbian is very easy with the right tools and experience.

To start with a basic Raspbian installation, you would need the following:

Hardware

Software

Please note: The above links to Amazon.com are my affiliate links. This helps us to keep the blog alive!

Preparing Raspbian SD Card

  • Download the Raspbian image from RaspberryPi’s official Website. I recommend to use the Lite version. At the time of publishing this article, Stretch is the Raspbian Version.
  • Insert the blank SD card via a USB card reader to your computer.
  • Download and install Etcher. Once installed open up the program and you should have a screen like below
image-1
  • In the first step select the Raspbian image which was downloaded from Step 1
  • In the next step, select the USB card reader device where the SD card is placed to burn the operating system
  • In the last step confirm your settings and let the program create the Raspbian disk.
  • Once the OS is burned to the SD card, there are 2 things which you need to follow to make your life easier. These are a) Enable SSH and b) Preload WiFi credentials so that RaspberryPi is connect to your network as soon as it is powered on. These steps are mentioned below

Enable SSH

For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.
Source: https://www.raspberrypi.org/documentation/remote-access/ssh/

If you have loaded Raspbian onto a blank SD card, you will have two partitions. The first one, which is the smaller one, is the boot partition. Place the file into this one.

Preload WiFi Credentials

Create a file in this directory called wpa_supplicant.conf onto the boot partition of the SD card. The file should contain the following details:

 ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 network={
     ssid="YOUR_NETWORK_NAME"
     psk="YOUR_PASSWORD"
     key_mgmt=WPA-PSK
 }

Source: https://howchoo.com/g/ndy1zte2yjn/how-to-set-up-wifi-on-your-raspberry-pi-without-ethernet

And that’s it folks! Now insert your SD card in RaspberryPi and power it on. Wait for a few minutes for it to setup. You can check in your router page to a new device and get its IP address. You can now ssh into your Pi with the default username pi and password raspberry

Level: Intermediate

Technologies: Linux / Unix, Git

post via Codincafe