loading

NOOBS requires a monitor, keyboard and mouse, which adds ~$60 (USD) or more in cost. However, once Wi-Fi is working, these devices are no longer needed.

Every time I start a new Raspberry Pi project, I lug out the 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.

This approach is a bit more advanced and uses a MacBook Pro instead of a monitor, keyboard and mouse. So, it saves $45 and takes up less space.

The goals of this project are to:

  • Eliminate the need for a monitor, keyboard and mouse
  • Document my way to setup RPi for future RPi Wi-Fi projects
  • Create a standard micro SD card image so next time I can skip many of the steps

NOOBS (New Out of the Box Software) is the easiest way to setup Raspberry Pi (RPi).

Step 1: Gather Parts

I have found the parts below perform best in my applications. These parts are more expensive than contained in the usual starter kit.

Get parts and tools (prices in USD):

  • MacBook Pro (a PC could be used)
  • Raspberry Pi 2 Model B Element14 $35
  • Panda 300n WiFi Adapter Amazon $16.99
  • 5.2V 2.1A USB Power Adapter from Amazon $5.99
  • Micro USB to USB cable 3ft from Amazon $4.69
  • FTDI TTL-232R-RPI Serial to USB cable from Mouser $15
  • Case from Amazon $6.99
  • SanDisk Ultra 16 GB microSDHC Class 10 with Adapter (SDSQUAN-016G-G4A) from Amazon $8.99

NOOBS uses 8GB, micro SD card, Class 6.

Notes:

  • Text enclosed in spades, such as, ♣replace-this♣, should be replaced with an actual value. Of course, remove the spades.

Step 2: Download Raspbian

Download Raspian

  • If you previously created a standard image in Step 12, then skip this step and go to Step 3.
  • Download latest full version of raspbian
  • When this was written the latest version was: 2015-11-21-raspbian-jessie.img
  • Move image 2015-11-21-raspbian-jessie.img from downloads to a directory where you store images:
♣your-macbook-image-directory♣

Step 3: Burn Raspbian Image to Micro SD Card

IMPORTANT: make sure you type in the correct disk number – if you enter the wrong disk number, you will wipe out your hard disk!

Insert a micro SD card into SD Adapter, and then insert the SD adapter into MacBook.

On MacBook use these instructions from Raspberry Pi. Summarized here:

  • Open MacBook terminal window
  • Change to directory containing raspbian image
$ cd ♣your-macbook-image-directory♣
  • Identify the disk (not partition) of your SD card
  • In this case, disk4 (not disk4s1) and = 4
  • To identify your micro SD card, run the command:
$ diskutil list
  • Unmount your SD card by using:
$ diskutil unmountDisk /dev/disk♣micro-SD-card-disk#♣
  • Copy an image to your SD card. Ensure the image name and are correct.
  • Use either the raspbian image or a standard image created previously in Step 12.
$ sudo dd bs=4M if=2015-11-21-raspbian-jessie.img of=/dev/rdisk
♣micro-SD-card-disk#♣
  • CTRL-t to see the status of the copying.
  • If there are errors, try different values for bs option, such as, 1m, 4m, or 1M. Larger Block Sizes (bs) are required for larger drives.
  • When complete, unmount the SD Card:
$ diskutil unmountDisk /dev/disk♣micro-SD-card-disk#♣
  • Remove SD adapter from MacBook and remove micro SD card from adapter
  • Insert micro SD Card in Raspberry Pi

Step 4: Raspberry Pi Setup and Connections

Heat Sink
Remove tape and press firmly on to processor. The heat sink and chip are almost the same size. It was fairly obvious were it was supposed to go. I did not take a picture.

Case

Take case apart. The older version has three parts: top, bottom and middle. Slide Raspberry Pi into bottom part of case Slide Raspberry Pi into bottom. There are two clips on the end where the SD card is inserted. The board must slide under these clips. It slides in easily, no need to force it. Again, this seemed very straightforward. So, there is no photo. It is good to keep the pi in the bottom part of the case.

Cables and SD Card

Insert these into Raspberry Pi

  • Micro SD card
  • Ethernet cable
  • Wi-Fi dongle
  • USB serial I/O cable (see images above)
    • Ground = Black wire, pin 06 on RPi
    • Tx = Yellow wire, pin 08
    • Rx = Red wire, pin10

Once the above are complete:

  • Insert power cable

Insert USB/Serial cable into MacBook USB port

If using a standard raspbian image previously created in Step 12, skip to Step 9

Step 5: Determine USB Port

Determine USB Port being used by USB-Serial adapter. My MacBook uses a chip from FTDI.

Open terminal window

There are a lot of devices in /dev. Use this command to identify the device:

$ 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

Identify the differences

Step 6: Open Terminal Window and Connect to Raspberry Pi

Connect MacBook to Raspberry Pi using serial cable.

Open terminal window. 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 RPi: username = pi password = raspberry

Note: the 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.

  • The prompt for recovery mode is #
  • Raspbian's normal prompt is $.
  • NOOBS recovery login and password is: root and raspberry

Step 7: Setup Using Raspi-config

Setup raspbian using raspi-config

$ sudo raspi-config
  • Expand Filesystem
  • And reboot (tab to Finish and hit Enter) and reboot
$ sudo raspi-config

Change user password to

Internalisation Options

  • * indicates selected
  • Use spacebar to toggle *
  • For the US, change locale unclick GB (using space bar) and click US English UTF 8 (en_US.UTF-8 UTF-8)
  • Click OK, select UTF and click OK
$ sudo reboot

When the MacBook terminal window gets messed up:

  • Close the terminal window (close all terminal windows and exit terminal app)
  • Unplug the USB cable from MacBook
  • Wait a few seconds and plug the USB cable back in
  • Start a new terminal window and login
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get auto remove
$ sudo reboot

Continue to setup raspbian

$ sudo raspi-config

Internalisation Options

  • Change time zone US and Central
  • Tab to Finish and reboot
$ sudo reboot
$ sudo raspi-config

Advanced Options

  • Change hostname to
  • Enable SSH
  • Finish
  • Reboot

Step 8: ​Always Update and Upgrade

Wi-Fi isn’t working yet, so keep Ethernet cable plugged-in. Run the following commands

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get auto remove
$ sudo reboot

If there are errors, check that an Ethernet cable is plugged in.

Step 9: Setup Raspberry Pi WiFi

Setup wifi using this instructable:

Best USB WiFi Adapter and Setup for Raspberry Pi

If you are setting up a standard image, then wait until the end to create a pre-generated key and a certificate because these depend on the MAC of the Raspberry Pi.

A simplified view of WiFi setup is to run

$ sudo nano /etc/network/interfaces

and edit the file to look like:

#/etc/network/interfaces
# settings.
# Local
auto lo 
iface lo inet loopback

# Ethernet
auto eth0
iface eth0 inet dhcp

# Wifi 
auto wlan0
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "♣ssid♣"
wpa-psk "♣ssid-password♣"

Step 10: Remove GUI

Optional step. My projects don't use a GUI, so remove it. Removing the GUI saves about 2MB of storage and improves performance.

$ sudo apt-get --purge remove 'x11-*'
$ sudo apt-get --purge autoremove

Adding turbo mode has some wifi performance benefits. Edit the file:

$ sudo nano /boot/cmdline.txt

So it is:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes smsc95xx.turbo_mode=Y rootwait

Step 11: Setup Gmail

Mail is very useful for receiving notifications and alerts about issues on the Raspberry Pi.

Ensure repositories are up-to-date. Run the command:

$ sudo apt-get update

Install SSMTP and mail utilities:

$ sudo apt-get install ssmtp
$ sudo apt-get install mailutils

Edit the SSMTP configuration file:

$ sudo nano /etc/ssmtp/ssmtp.conf

as follows:

root=♣your-gmail-account♣@gmail.com
mailhub=smtp.gmail.com:587
hostname=♣your-hostname♣
AuthUser=♣your-gmail-account♣@gmail.com
AuthPass=♣your-gmail-password♣
UseSTARTTLS=YES

Edit the SSMTP aliases file:

$ sudo nano /etc/ssmtp/revaliases

Create one line for each user in your system that will be able to send emails. For example:

root:♣your-gmail-account♣@gmail.com:smtp.gmail.com:587

Set the permissions of the SSMTP configuration file:

$ sudo chmod 664 /etc/ssmtp/ssmtp.conf

Step 12: Find IP by Hostname

My home automation system needs to access my raspberry pis. However, DHCP allocated IP addresses can change. So, I tried assigning static IP addresses. I wasn't satisfied with this solution. Next, I tried using nmap to discover the IP address of a hostname, but this seem rather involved. I was going to set up a DNS server, when I ran across the solution below.

It is easier to refer to a raspberry pi by its ♣your-hostname♣.local.

Install multicast DNS.

$ sudo apt-get install avahi-daemon

Try pinging the device

$ ping ♣your-hostname♣.local

If you would like to change the hostname do the following, otherwise go to the next step

$ sudo nano /etc/hosts

The hostname should default to dietpi. Change the last line from dietpi to the new ♣hostname♣

192.168.1.100     ♣your-hostname♣

CTRL-O, CTR-X, ENTER to save and exit the editor

$ sudo nano /etc/hostname

♣your-hostname♣

CTRL-O, CTR-X, ENTER to save and exit the editor

Commit the changes to the system

$ sudo /etc/init.d/hostname.sh
$ sudo reboot

Step 13: Backup the Micro SD Card

When Raspberry Pi is setup, then back up the image. Use this image to create the next project.

Also, backup the project when it is complete. If anything goes wrong with the SD card, then it is easy to restore it.

Shutdown the Raspberry Pi

$ sudo shutdown –h 0

Wait until the card has shutdown, and then remove the power supply, and then remove micro SD Card

Insert micro SD card into SD Adapter, and then insert the SD adapter into MacBook

On MacBook use these instructions from The Pi Hut with modifications as follows:

Open terminal window

Change to directory containing raspbian image

$ cd ♣your-macbook-image-directory♣

Identify the disk (not partition) of your SD card e.g. disk4 (not disk4s1). From diskutil output, = 4

$ diskutil list

IMPORTANT: make sure you use the correct – if you enter the wrong , you will end up wiping out your hard disk!

Copy the image from your SD card. Ensure the image name and are correct:


$ sudo dd if=/dev/disk♣micro-SD-card-disk#♣ of=♣your-macbook-image-directory♣/SDCardBackup♣description♣.dmg

CTRL-t to see the status of the copying.

When complete, unmount the SD Card:

$ diskutil unmountDisk /dev/disk♣micro-SD-card-disk#♣

Remove SD adapter from MacBook and remove micro SD card from adapter

Insert micro SD Card in Raspberry Pi

On the next project, use this image and skip many of the steps in this instructable.

And you are done!

Step 14: Appendix: Pre-generated Key

Pre-generated keys depend on the Raspberry Pi's MAC and are not unique to a micro SD card. These need to be setup for each device.

Create a pre-generated PSK key. Login to Raspberry Pi and run the command:

$ wpa_passphrase ♣your-ssid♣ ♣your-pass-phrase♣ 

output:


network={
	ssid="♣your-ssid♣"
	psk=♣your pre-generated key♣
}

/etc/wpa_supplicant/wpa_supplicant.conf

Each parameter in the /etc/network/interfaces file was measured.

The wpa_supplicant.conf file must be correct or wifi won't work.

Login into raspberry pi and run the command:

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Edit the file to look like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
	ssid="♣your-ssid♣"
	# use a pre-generated key
	psk=♣your-pre-generated-key♣
	# if creating a standard image for many projects, then use pass phrase 
	# instead of generated key
	# a generated key depends on the Raspberry Pi's MAC
	# psk="♣your pass phrase♣"
	# specify for clarity
	key_mgmt=wpa_psk
	proto=rsn
	# CCMP is the correct encryption to use for WPA-PSK
	pairwise=CCMP
	group=CCMP
}

CTRL-o to write file

ENTER to confirm write

CTRL-x to exit nano editor

Step 15: Appendix: Add Client-side Certs to Web Servers

My projects are focused on home automation, and while it is useful for me to have access, I don't want the world to control my home. A server/client certificate pair prevents unauthorized users from accessing.

Follow this instructable to add certs: Restrict Access to Raspberry Pi Web Server

Step 16: Appendix: RSA Key Issue

While experimenting, I received the message below when I tried to login.

$ ssh pi@192.168.1.94 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     
@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
eb:98:60:31:52:ac:7b:80:8e:8f:41:64:c1:11:f9:ef.
Please contact your system administrator.
Add correct host key in /Users/jeffcartwright/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/♣your-username♣/.ssh/known_hosts:16
RSA host key for 192.168.1.94 has changed and you have requested strict checking.
Host key verification failed.

There is an easy fix.

Open a MacBook terminal window and the vi editor

$ sudo vi /Users/♣your-username♣/.ssh/known_hosts

Login with you MacBook password.

The first entry is 1, press the down arrow key (16 - 1) until you are on the 192.168.1.94.

Type (delete line, write file , and quit):

dd
:w!
:q!

Now, login should work

$ ssh pi@192.168.1.94

If asked to continue connecting, confirm by typing yes.

The authenticity of host '192.168.1.94 (192.168.1.94)' can't be established.
RSA key fingerprint is eb:98:60:31:52:ac:7b:80:8e:8f:41:64:c1:11:f9:ef.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.94' (RSA) to the list of known hosts.

Step 17: Appendix: Updates

11JUN2016

  • Removed Appendix on static IPs
  • Replaced with hostname.local

<p>I have a Raspberry Pi 3 Model B. Would the process be the same skipping the wifi setup? </p><p>Thank you</p>
<p>Yes, skip WiFi. I scanned through and the other steps should work for RPi3. Let me know if you have any issues.</p>

About This Instructable

18,967views

15favorites

License:

More by jeff.cartwright.562:Install and Setup Shinken Network Monitor on Raspberry Pi Improve AT&T U-Verse Download Speed from 18Mbps to 22Mbps Accordion Menu  
Add instructable to: