As I mentioned in an earlier blog, the RPi-Cam-Web-Interface package is a much better fit for Raspberry Pi, and particularly a Pi Zero than packages like motion / motioneye. This is primarily because RPi-Cam-Web-Interface exploits the tight integration between a Raspberry Pi and a Raspberry Pi Camera, to be faster and more efficient than is possible using more generic interfaces. This allows the reliable use of faster framerates and / or higher resolutions.
This post describes the initial setup of a Raspberry Pi, including connecting it to a home network and accessing it from a PC, laptop or tablet on the home network.
Preparing to power on for the first time
This stage has the following steps:
- Put raspbian onto the micro SD card
- Tweak the micro SD card to enable access from you wifi network
- Insert into the raspberry pi and power on
- Access the Raspberry pi from another computer.
Put Raspbian onto the the micro SD card
Normally you only need to to this once, but if you want to start again from square one for any reason, then you can do this again. It WILL overwrite the SD card so any files there before you do this will disappear.
The easiest way to get a shiny fresh installation of Raspbian onto the SD card is to use Etcher, which works on Windows, Linux and MAC - it doesn't however run on tablets or phones, so for now this step has to be done on a desktop or laptop PC.
There is an
excellent and full guide to using Etcher here, and there is
a fairly detailed video here. Below are a couple of extra bits of info and a short guide if you don't need all the background info.
Use Raspbian Lite NOT full Raspbian.
Don't immediately put the SD card into your pi after running Etcher - there are a couple of extra things first (see step 99 below).
To minimise the overheads and get the best out of your pi I recommend using Raspbian Lite - this is especially useful on a Raspberry Pi Zero which has more limited processor power and memory than its bigger brothers.
Text version - flashing the SD card:
- Download Etcher from here. The Download for xxx button normally has the right version selected, so you don't need to be puzzled by the various option that appear if you open the drop down box.
- Install Etcher on your PC
- Download Raspbian Lite - Click on Download ZIP under Raspbian Stretch Lite on the right of this page On the pop-up window, ensure Save File is checked and click OK. If you start at the main Raspberry Pi download page, click on Raspbian (NOT NOOBS) to get to the page with Raspbian Lite on it.
- Put the micro SD card in a suitable adapter - either a USB adapter or a full size SD card adapter if your PC / laptop has a full size SD card reader.
- Plug in the adapter. Ignore any messages from the operating system, and close any windows that pop-up ( DONT CLOSE ETCHER!)
- Run Etcher - on Windows press the Windows key and it should be near the top under "recently added". You can also press the Windows key and type etcher, and it should appear beside something that looks like a very small (vinyl) record.
- In Etcher Click on Select Image and then click on downloads at the top of the left pane. Select the ZIP file downloaded from raspberrypi.org.
- The middle section of Etcher should already be showing your micro SD card and will skip straight to highlight Flash. Click on Flash! and wait for the card to be flashed and verified.
- Remove the SD card adapter from the PC, DONT PUT IT IN THE PI YET!
Text version - final tweaks to the card:
After watching countless numbers of really awful videos, this one is reasonable. Ignore the first part about imaging the disc - start at around 1:40. This video does things in reverse order, and carries on to some of the configuration steps I have in the next section. Use the extended info below for the wpa-supplicant file however.
- Put the adapter back in the PC and, using File Manager, find and open the boot disk - look in This PC to find it.
- Right click in the file area and from the drop down select New then Text Document. Rename the new text document to ssh and remove the '.txt' (you will probably need to enable File name extensions in the View Tab at the top of the screen)
- Now create another new document and add the following contents:
country=GB
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="MyNetworkSSID"
psk="mypassword"
}
- change MyNetworkSSID to the name of your wifi network, and likewise the password. Leave the quotes in place.
- rename this file to wpa_supplicant.conf
- Safely remove the adapter from your PC and remove the micro SD card.
First switch on and connecting from PC
Starting the Pi
This is easy. plug the micro SD card into the Pi and then connect power to the micro USB power adapter (the one at the very end of the card). The green light should flicker a bit after a few seconds. It will take 20 seconds to 1 minute to start this first time, subsequent boots will be faster.
Connecting from linux
This one is really easy:
- Open a new terminal window and enter this command:
ssh -l pi raspberrypi
- Enter yes at the fingerprint prompt, hit Return
- Enter the preset password raspberry at the password prompt, hit Return. The session should start
If the device cannot be found (
ssh: Could not resolve hostname raspberrypi) see the problem solving section at the end of this blog
Connecting from Windows
Installing PuTTY
Once only, you need to install PuTTY. There
is a good guide here, it is best to follow that guide.
Connecting
Once installed,
run PuTTY as described here.
The previous video also has a good section on this starting at around 5:15. When you first power up your pi it should connect if you enter
raspberrypi
as the host name. If that does not work, try
raspberrypi.local
Login with username pi and password raspberry. Now it's time to do a little bit more setup.
If even raspberrypi.local fails see the problems section at the end of this post.
Connecting from Mac
For now the best advice I can give
is to follow this.
Final setup of Raspberry Pi
Once logged in there are a few further steps before setting up the camera software:
- Change the hostname
- Change the password
- set the local language (which also makes the keyboard behave)
- enable the camera
These are all done using raspi-config.
sudo raspi-config
This
also is in the video at 6:55. It doesn't cover enabling the camera, but it is in raspi-config in the Interfacing Options sections.
Reboot the Raspberry Pi. Now we are ready to setup the camera software which I'll cover in a separate post.
Problems?
ssh / putty fails to connect
Sometimes
raspberrypi fails to connect.
try
raspberrypi.local instead.
If that fails you will need to use the pi's IP address. You should be able to find this in your router's web pages, but exactly how varies from router to router.