In this section we will look at the basics of getting the Raspberry PI up and running fresh out of the box. It is surprisingly easy to get the |Raspberry PI up and running and serving a web page on a home network. There are ample resources out on the internet if you run into problems. Chances are if something does not work for you, Google it and most likely someone else has fixed a similar problem.
In this phase of the project we want to perform the following with the Raspberry PI:
The first step is to create a SD card that contains an OS image from the Raspberry PI website. The Raspberry PI boots from the SD card and stores data on the SD card. It has no attached hard drive. I selected an 8G byte SD card to provide enough storage to log data from the weather station.
You will want to download an image from the Raspberry PI downloads page located here
I selected the "Raspbian Debian Wheezy" install. You can't just put the file on the SD card, it won't work. You need to image the file onto the SD card using an image writing program. To properly image the OS onto the SD card you need to follow the instructions here:
Installing Raspberry PI OS image onto SD card
The instructions are dependent on the operating system you have on your host machine. If you are using windows, you will need to download win32diskimager, you can find that here:
Now comes the fun part. We need to power up and boot the Raspberry PI. About the only things that can go wrong here are having something connected incorrectly, or not imaging the SD card properly.
You will want to connect the following to the appropriate ports on the Raspberry PI.
Once you have verified your connections, plug power in using the micro USB jack. Power is supplied through this micro USB jack. You can use any micro USB power supply, like a phone charger etc. Make sure that the power supply can supply at least 1 amp. The Raspberry PI uses about 700ma (0.7A).
If all goes well, you should see a bunch of messages on your monitor as the Raspberry PI boots. If it does not boot, check your connections and make sure that you properly imaged your SD card with a valid OS image.
If all goes well, you should get a prompt like this:
Login with the user name pi and the password raspberry Note that the password is not echoed to the screen
Now that you have logged in successfully, you will want to update the Raspberry PI to the latest patch level. To do this type the following commands at the prompt
sudo apt-get update
sudo apt-get upgrade
If it asks you for a password, use the same default password raspberry .
Next you want to set your home router to assign the same IP address each time it finds the Raspberry PI on your network. If you don't do this, your Raspberry PI may get a different IP each time, making it difficult to find reliably on your home network.
Login to your home router and look for a setting called DHCP reservation. Select the Raspberry PI from the list of computers on your network and enable a DHCP reservation for it. Pick an IP address in your routers range that is easy to remember. For example 192.168.0.101. Make note of this IP address, you will use it later to remotely login to it.
Reboot the Raspberry PI so that it can get the new IP address. To do this type:
Next you will want to be able to login remotely to the Raspberry PI. The easiest way to do this is to download PuTTY for Windows:
After you have downloaded it, run PuTTY and put the IP address that you set in the DHCP reservation for the Raspberry PI in the host name field. Select SSH as the connection type and click open. The user name and password are the same as before: user name pi , password raspberry .
You should now have a terminal just like the one you had with the monitor and keyboard. Now you don't need the monitor and keyboard attached to the Raspberry PI anymore, you can access it from your laptop or other computer instead.
The Raspberry PI reads the time from the internet using a time server. However, by default the timezone is set to UTC time. So if you type date, you will get the current time where the minutes may be correct but the hour is off. To fix this you need to set your default timezone. To do this type:
sudo dpkg-reconfigure tzdata
Follow the on-screen instructions to select your region and nearest city. After this is done, type date and you should see the correct time.
In order to serve a web page, you will need to install Apache on the Raspberry PI. To do this, simply type:
sudo apt-get install apache2 php5 libapache2-mod-php5
By default, Apache installs a default web page that says Hello World. To test that everything is working, we want to change this. Edit the file:
Change Hello World to Hello your_name and save the file.
At this point, if everything is working you should be able to open a web browser on your laptop and go to the IP address you assigned your Raspberry PI and see your web page with your name displayed.