Raspberry Pi Nestbox Camera - Setting up the Raspberry Pi

In the introduction to our Raspberry Pi Nestbox Camera system, we looked at what we needed to get started. If you've got all the bits and pieces in front of you, we can get cracking with setting up our Raspberry Pi computer that is going to do all the work. Straight out the box, the Raspberry Pi can't do much. The point of this tiny computer is to deliver an affordable way of teaching people about computing and as such, it does away with fancy casings and so on. So, where do we go from here? There's no mouse, no keyboard, no monitor and not even an operating system yet! Luckily, it's possible to remotely access the Raspberry Pi with the help of SSH. SSH stands for Secure Shell and you can think of it as the basis for remotely logging into other computers securely. On its own we'll have to send instructions using the command line but you can also log in with a graphical user interface but more on this later. The bottom line is that with the Raspberry Pi connected to a network, it's possible to access it using another computer using the SSH protocol. The latest editions of the operating system we'll use have SSH enabled by default so connecting really only requires that we know the IP address of the Raspberry Pi.

Download and prepare the operating system

First up, we need to prepare the operating system for the Raspberry Pi. The operating system and other files all reside on the SD card you plug into your Raspberry Pi, it's basically the hard drive. Over at the Raspberry Pi Foundation website, there's a thorough guide on how to set up you SD card and for first timers they recommend the NOOBS option which gives you a choice of which OS to install. You might want to look into this at another time but right now, we're only concerned with Raspbian which we can download separately. Why? Well it's the most widely used OS on the Raspberry Pi so it's well supported and by choosing only one OS, the Pi will install Raspbian automatically without the user having to do anything! This is really useful when setting up the Raspberry Pi without a monitor and keyboard. It also saves some precious space on the SD card.

extract_image

Windows users should download and use the SD image formatter to ensure your SD card is formatted correctly. With the SD card connected to your computer open up the program, select the SD card from the drop down menu, specify a name and click format.

Next, download and run the Win32DiskImager (you might have to run it as an Administrator). Browse and select the operating system image file you extracted to your desktop and select the correct device (the SD drive number e.g. F:\). It's really important you get the correct device or else you might starting writing over your computer's hard drive so double check this step!

Once complete, you're SD card will be ready to go.

Mac users can also download the SD image formatter and run it (just like the Windows users). To write the operating system to the SD card, we're going to use the terminal but first we need to know the disk name. To find this click on the the spotlight menu (command+space) and type System Information. Click the application to bring up a report of your computer. Find the SD card (it'll either be under 'Card Reader' or 'USB' depending on how you've connected it to the computer). You're looking for the BSD name and it should be something like 'disk3'. You might also see a BSD name such as disk3s2 - ignore this, we're only interested in that first number.

Now we've got the number, open the terminal (command+space > type 'terminal' and select it). Run the following command replacing the '/path/to/OS/image.img' with the path to the extracted Raspbian image on your desktop and the 'disk' with the number we just found.

sudo dd if=/path/to/OS/image.img of=/dev/disk bs=4m

You'll end up with something like: sudo dd if=/Users/chris/Desktop/raspbian.img of=/dev/disk3 bs=4m

You'll have to enter a password to begin writing the image to the disk. This takes a while so don't worry if nothing happens for a while. Hit Ctrl+T to see how things are progressing. around about 700 records need to be written in and out.

Starting up the Raspberry Pi headlessly

  • Now we have our operating system successfully loaded onto our SD card so we're ready to boot up the Raspberry Pi for the first time. Insert the SD card and connect the Pi to your router using the ethernet cable. Finally, plug the power supply in and with all being well, your Raspberry Pi should light up. Take another short break and let the Pi run for the first time and install the operating system.
  • While that's happening, let's get ready to find the IP address of the Pi. To do this, use your browser to access your router's webpage. It's usually something like 192.168.1.1 and the address is often on the router itself. Through this, you should be able to see a list of devices connected to your router both wired and wireless. IP addresses are simply addresses for any device connected to a network (like the internet or your local network at home).

UPDATE: l recently had to find the IP address of my Raspberry Pi where I was unable to access the router. Luckily this can still be done using software to scan for all the devices attached to your local network. This narrows down the IP address to only a couple of possibilities making it easy to find out which one belongs to the Raspberry Pi. Check out MAC Scanner on Windows.

  • Once your Raspberry Pi has installed the software, it should show up on the connected devices list. We're looking for a wired connection that should be easy to identify as the Raspberry Pi. Here I can see the device raspberrypi and clicking on it gives me the IP address. Let's use an example: 192.168.1.87.

wired connections - Raspberry Pi nestbox camera

  • Now that we know the address of the Raspberry Pi we can access it through another computer and this is where the SSH protocol that I mentioned at the beginning comes in.

Windows users will need to download an SSH client such as PuTTY. Enter the IP address of your Raspberry Pi into the hostname field and hit open.

Mac users don't need a special program since this is what Terminal can be used for. Start it up by going to the spotlight menu (command+space) and type Terminal. Click the application to start it up. Type the following command:

ssh 192.168.1.87 -l pi

 The IP address will be the one you discovered earlier. The -l pi part send a command that we want to log in as user pi.

  • If prompted for a username, the default is pi since we haven't set up any other users. The default password is raspberry. Note that if you'er using a Mac, the characters don't show up when typing the password. This is normal so type the password and hit return.
  • If all goes well, you should be looking at a command prompt looking something like this pi@raspberrypi ~ $. Good work - we're now able to control the Raspberry Pi through the command line from this computer.
  • Packages for the various software held on the operating system are updated often so we need to make sure we have the most up to date versions on our system. There are two simple commands we can send to the Raspberry Pi to fulfil these requirements:

sudo apt-get update

sudo apt-get upgrade

  • Once these two commands have run their course, you'll have an up to date Raspberry Pi.

In the next part, we'll look at setting up the motion detection software and configuring how and where the images are saved to.