Introduction: Raspberry Pi Made Easy - Part 1 (getting the Thing Working)
I've been around microcontrollers for several years but started using the Raspberry Pi ( often called RasPi or RPi) only six weeks ago. I soon discovered that while there is an abundance of good information and tutorials on the Internet, I had to peruse several sites to find a complete solution at each step of my learning. This searching made the learning much longer and more painful than it needed to be. (I'm sure there are sites that would have met my needs, I just couldn't find them. Even the official Raspberry Pi Foundation site, as excellent as it is, took me awhile to successfully navigate to find what I needed. Perhaps I'm just slow.)
In this, my first instructable, I will endeavour to make learning the RasPi easier for anyone who comes after as we simply get the OS installed and perform a few basic configurations. We'll look at connecting to LEDs, buttons, sensors, motors, etc. in later instructables. Before too many, we'll even introduce some simple IoT applications. So if you are new to the RasPi, get ready to discover how easy it is to use and how satisfying it is to complete a working program that actually controls something.
What you'll need
- A Raspberry Pi - I'm using an old Model B, Revision: 03, Memory: 512MB, with only 2 USB ports for this instructable; but, I would rather have a Raspberry Pi 3 Model B. One place to get one is here.
- An SD card - 8GB is recommended. I have seen it work with 4GB cards and I have used 32GB cards. Go for quality rather than price. I have had to discard a few already because they failed. You can buy an SD card with NOOBS already installed; however, it does cost a little more. We walk through the process of loading NOOBS onto a blank card so don't worry if that's what you have.
- A keyboard and mouse - I have used corded and cordless; both have worked right out of the box. We only need these for the initial interface because we will discover how to control the RasPi remotely from our desktop in a future instructable.
- A monitor - The RasPi can connect to a monitor using HDMI or to a TV using RCA composite video. Naturally, suitable cables for this hookup are also needed. Again, once we discover how to control the RasPi remotely, we won't need the monitor for many applications.
- A micro USB cable - This is used only to provide power from our desktop/laptop to the RasPi. Depending upon what our application is, a separate external power supply might be needed because computer USB ports have limited current capability. For this instructable, USB power is fine.
- A PC - This is needed for two things in this instructable: first, to provide power through the USB port; and second, to download the RasPi's OS and prepare the SD card if you don't have an SD card with NOOBS already installed. More about NOOBS in the next step. I'm using a laptop with Windows 10 for this instructable.
- An SD card reader - many computers and laptops now have these already installed. If you don't have one, you'll need to get one to write NOOBS to the SD card. I've seen these for just a few dollars in dollar stores.
- A cabled Internet connection - This allows us to update the RasPi's OS and download additional software as it's needed. In a future instructable we'll discover how to use a wireless Internet connection; but, that won't work without proper configurations.
Step 1: Prepping the SD Card
If you have an SD card with NOOBS already in it, you can proceed to step 2.
NOOBS is the Raspberry Pi Foundation's "easy operating system installer which contains Raspian." Raspian is the recommended Linux distribution modified for the RasPi. While certain other OS's will work, I suggest you stick with the recommended OS until you have a specific need for which some other variant might be better suited. You'll need a copy of NOOBS so download the latest from here. As of this writing, the latest version is 1.9.2.
Unzip the downloaded file to a location you can easily find. Once it is unzipped, we no longer need the downloaded file so it can be archived or deleted.
Next we need to prepare the SD card for NOOBS. For this we'll need SD Formatter 4.0, EaseUS, or similar software. While SD Formatter is older and hasn't been upgraded for Windows 10 (as of this writing), it still works and the price is right - free. Download the software of your choice. The card must be formatted as FAT32.
Assuming you chose SD Formatter, unzip the downloaded file to a location you can easily find. Once unzipped, execute the setup.exe program to install.
Insert your SD card into the reader on your PC and start SD Formatter. The program will automatically display the available size of the SD card and the letter of the drive into which it is inserted. Depending upon how the card is currently configured, its full size may not show.
Under SD Formatter's Options, select FORMAT TYPE of FULL (Overwrite) to ensure no residual data can interfere with the new OS. Also select FORMAT SIZE ADJUSTMENT of ON so the card can be partitioned to make all of its space available to the new OS. You can add a Volume Label if you wish although it is typically overwritten when the OS is actually installed (in the next step). Then click OK to prepare the card. Depending upon the size of your SD card, this can take 10's of minutes so be patient. Once formatting is complete, we are finished with SD Formatter so you can close it.
In Window's File Manager, open the folder in which you unzipped NOOBS. Copy all the files (do not copy the folder itself) and paste/drag them onto the SD card.
This completes our SD card preparation; now we can actually install it onto the RasPi.
Step 2: Installing Raspian
We now have a formatted SD card containing NOOBS files. We are ready to install the OS.
Attach the monitor, keyboard, mouse, and Internet to your RasPi. Insert the SD card into the SD card slot on the bottom of the RasPi. It will only fit one way so do not try to force it. Only after everything else is attached, connect power through the micro USB cable connected to your PC.
Since this is a first boot, it may take a little longer than you typically expect a computer to boot - this is not your PC and probably operates much slower. Mine is clocking at 700MHz - blazingly fast for a microcontroller; painfully slow for a modern computer. Please be patient.
You must select your OS of preference once the opening screen is presented. Select the Raspberry Pi Foundation's recommended choice of Raspian then click the Install button.
Raspian is a Linux distribution formulated specific to the RasPi. Other distros might be preferable for specific applications; however, we want the general nature of Raspian.
There are OS's available which are not listed in NOOBS, such as a Windows 10 IoT version. While I have read good things about other OS's, let's stick with the Foundation's recommendation.
This install will take several minutes so this is a good time to look over the Raspberry Pi Foundation website. Be patient.
********** Time passes during the install ***********
After several minutes and a successful install, your will be prompted to restart the RasPi. Do so by clicking the appropriate button.
By default, Raspian now boots into a Windows-like GUI with an automatic login. This can be changed but we won't get into that now. If you ever find yourself booting to the CLI (Command Line Interface) you can start the GUI by entering the command startx. If the automatic login should ever fail, you can manually login using the user name pi and the password raspberry if you haven't changed them from the default values. It is common for the password to not be echoed to the screen as you type.
You must have a Internet connection for the remainder of this instructable.
While some (if not all) of the following configurations can be performed in the GUI, my experience is that the Command Line Interface (CLI) performs the configurations with better results. In the top left area of the screen is an icon resembling a computer monitor, click this icon to initiate the Terminal. The Terminal is the CLI in a window.
At the command line prompt, type sudo apt-get update -y. (After each command you will need to press the ENTER key.) This command examines the already installed software and prepares a list of available package/software updates. The "-y" appended to an instruction tells the command to assume "Yes" should it ever need permission to continue with an action. The "apt-get" is the utility that actually prepares the list. More information about it can be found here.
Depending upon the command being issued, Raspian enforces a level of user permissions/rights to prevent accidental corruption of the system. Some commands can only be performed by a superuser (Linux's term for Administrator). The "sudo" tells Raspian to execute the command with superuser privileges. More information about it can be found here.
After just a few minutes, the command will terminate and the command line prompt will return. At the command line prompt, type sudo apt-get dist-upgrade -y. This command downloads and installs the updates from the list just created. There is another command that will perform the same function; however, this one performs is more completely; so while it might take a little longer, I prefer it. More information about it can be found here.
This step can take 10's of minutes so be patient. It will probably appear as if the RasPi has become unresponsive; believe me, it hasn't; it is just busy executing the lengthy command process.
When the command line prompt returns, type sudo rpi-update. This command downloads and installs any firmware updates. This action is akin to updating the BIOS on your PC.
When this update is complete, Raspian will prompt for a restart. If necessary, at the command line prompt, type sudo reboot and wait while the RasPi shuts down and restarts.
Step 3: Initial Configuration Changes
The next few steps could be performed in the GUI by clicking the Menu button; then selecting Preferences; then selecting Raspberry Pi Configuration. However, I have found that making configuration changes in the Terminal tends to give better results so that is what we'll do.
Once the RasPi has rebooted, open the Terminal again. At the command line prompt, type sudo raspi-config. This command starts the Raspian configuration utility. If the RasPi appears unresponsive during the next few instructions, please be patient.
Use the arrow keys to highlight Internationalisation Options and press ENTER.
Use the arrow key to highlight Change Timezone and press ENTER. Use the arrow keys to highlight the locale of your choice, in my case this is "America". Press ENTER. Use the arrow keys to highlight a city in your time zone, in my case this is "Toronto". Press ENTER.
You'll be returned to the main Raspian configuration menu. Return to Internationalisation Options and press ENTER. Use the arrow keys to highlight Change Keyboard Layout. Press Enter. Use the arrow keys to highlight your particular keyboard, in my case this is the "Generic 104-key PC". Press ENTER. On the next screen highlight the keyboard layout of your choice, in my case this is "English (US)". Press ENTER. On the next screen you are given the option of selecting a key to initiate an alternate keyboard layout. I recommend that unless you know what you are doing, you should select No AltGr key. Press ENTER. The next screen deals with a "compose key". Again, unless you know what you are doing, select No compose key. Press ENTER. The next screen deals with the combination of Control+Alt+Backspace keys. Select No and press ENTER.
You'll be returned to the main Raspian configuration menu. Return to Internationalisation Options and press ENTER. On the next screen, highlight Change Wi-fi Country. Press ENTER, On the next screen use the arrow keys to highlight the country of your choice, in my case this is "CA Canada". Press ENTER. On the confirmation screen, select OK and press ENTER.
You'll be returned to the main Raspian configuration menu. Use the TAB key to select Finish and press ENTER. You will be prompted for a reboot. Select Yes and press ENTER.
Step 4: All Done
If all goes according to plan, your RasPi will reboot with all updates and configurations in tact. I said if; however, I have never gone through this procedure and had it not work - and I have gone through it plenty of times.
You screen should look similar to the image in this step. One noticeable difference will be the IP address showing in the center of the title bar. It shows on mine because I am using what is called a remote desktop. More on remote desktops in my next instructable.
Congratulations! The initial setup is complete and you can start using your RasPi.
Please leave comments if you have found this instructable useful. Please point out any errors or omissions. Thanks for reading.