Pi Zero‘s are even cheaper versions of the Raspberry Pi. The price you pay is that they’re harder to connect to since all the ports are small (micro-USB’s and mini-HDMI’s), so you need adapters to connect to keyboards, mice, and monitors. However, if you have the wireless version (Pi Zero W) you can set it up to automatically connect to the WiFi network, and work on it through there using the command line. This is a brief summary of how to do this (it’s called a “headless” setup) based on Taron Foxworth’s instructions. It should work for the full Raspberry Pi as well.
Set up the Operating System
You can install the Raspbian Stretch (or Raspbian Lite which does not include the desktop GUI that you will not use) on a SD card (I used 8 or 16 Gb cards).
- Download Raspbian.
- SD Card Formatter to format the SD Card. It’s pretty quick, just follow the instructions.
- Etcher: to install the operating system on the SD Card
Set up automatic connection to WiFi
You may have to remove and reinsert the SD Card to get it to show up on the file system, but once you have you can set it up to automatically connect to WiFi by:
- Go into the
/boot
partition (it usually shows up as the base of the SD Card on your file manager) and create a file named “ssh”. - Create a text file called “wpa_supplicant.conf” in the /boot folder, and put the following into it, assuming that the wifi router you’re connecting to is called “myWifi” and the password is “myPassword”.
country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="myWifi" scan_ssid=1 psk="myPassword" key_mgmt=WPA-PSK }
Now put the SD Card into the Pi and plug in the power.
Find the IP address
First you have to find the Pi on the local network. On Windows I use Cygwin to get something that looks and acts a bit like a unix terminal (on Mac you can use Terminal, or any shell window on Linux).
To find the ip address of your local network use:
on Windows:
> ipconfig
look for the “IPv4 Address”.
Mac (and Linux?)
> ifconfig
look under “en1:”
Connecting
To connect you use ssh on the command line (Mac or Linux) or something like Putty
Static IP
Without a static IP address it is possible that the Pi’s IP address will change occasionally. I followed the instructions on Circuit Basics and MODMYPI, but basically you have to:
- Identify your network information:
- Find your Gateway:
> route -ne
> cat /etc/resolv.conf
interface wlan0 static ip_address=10.0.0.99 static routers=10.0.0.1 static domain_name_servers=75.75.75.75
A Web Server
Adding a webserver (apache with php) is pretty easy as well, just run the commands (from the Raspberry Pi Foundation)
Apache web server:
sudo apt-get install apache2 -y
PHP for server-side scripting
sudo apt-get install php libapache2-mod-php -y
Now your can find the webpage by going to the ip address (e.g. http://10.0.0.1).
The actual file that you’re seeing is located on the Pi at:
/var/www/html/index.html
You will probably need to change the ownership of the file in order to edit it by running:
> sudo chown pi: index.html