457 76 2MB
English Pages 
352 47 2MB Read more
402 51 3MB Read more
620 157 1MB Read more
625 216 9MB Read more
RASPBERRY PIDownload This Great Book Today! Available To Read On Your Computer, MAC, Smartphone, Kindle Reader, iPad, or
593 105 96KB Read more
558 159 16MB Read more
501 176 12MB Read more
RASPBERRY PI PROJECT AN ADVANCED GUIDE TO SETUP, EXPERT PROGRAMMING (CONCEPTS, THEORIES AND TECHNIQUES) AND BUILD RASPBERRY PI PROJECTS
Copyright © 2020 Steve Jons All rights reserved. This book is copyright and no part of it may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. Printed in the United States of America Copyright 2020 @ Steve Jons
Contents INTRODUCTION ........................................................... 1 REQUIREMENTS ........................................................ 2 KEYBOARD AND A MOUSE ......................................... 7 OPTIONAL ACCESSORIES ........................................... 11 ETHERNET CABLE ................................................... 12 HOW TO INSTALL THE RASPBIAN OPERATING SYSTEM VIA THE RASPBERRY PI IMAGER ............13 HOW TO CONNECT YOUR RASPBERRY PI ......... 18 RASPBERRY PI 4 ........................................................... 21 HOW TO START UP YOUR RASPBERRY PI .......... 23 FINISH THE SETUP ..................................................24 HOW TO USE AND MAKE THE BEST OUT OF YOUR RASPBERRY PI ..............................................................28 KEYBOARD AND MOUSE SETTINGS .................... 30 HOW TO CONNECT TO A WIRELESS NETWORK .................................................................................... 33 HOW TO INSTALL SOFTWARE ................................. 37 HOW TO UPDATE YOUR PI .................................. 40 HOW TO ACCESS YOUR FILES ................................. 44 HOW TO USE THE TERMINAL ..................................47 HOW TO CONFIGURE YOUR PI................................ 51
INTERFACES ................................................................. 53 PERFORMANCE ....................................................... 54 HOW TO GET HELP ............................................... 56 RASPBERRY PI COMPUTER WITH A CAMERA MODULE PORT ........................................................... 58 HOW TO CONNECT THE CAMERA MODULE.... 60 HOW TO CONTROL THE CAMERA MODULE VIA THE COMMAND LINE ............................................ 62 HOW TO CONTROL THE CAMERA MODULE WITH PYTHON CODE ........................................................... 64 HOW TO CHANGE THE IMAGE SETTINGS AND IMAGE EFFECTS .......................................................... 69 HOW TO CHANGE THE LOOK OF THE ADDED TEXT .......................................................................... 71 HOW TO CHANGE IMAGE WHITE BALANCE ........ 77
computers, continues to prove its claim of meeting technological needs with mind-blowing innovations. In this article, we'll take you through the necessary steps needed to jump-start your Raspberry device and by extension, how to make the best use of it.
REQUIREMENTS WHICH RASPBERRY PI MODEL SHOULD YOU GO FOR? Out of all Raspberry Pi models available, the Raspberry Pi 4 Model B is the fastest and the most easy to use. It comes in a 2GB and 4GB RAM variety. For hobbies and movie lovers, the 2GB variety is recommended. This model is capable of making you do without your desktop computer.
On the other hand, the Raspberry Pi Zero and Zero W are smaller models that require little power for most software projects. This is highly recommended for geeks and nerds. To be more efficient, you can start an artificial intelligence project on the Raspberry Pi 4 and move to the Pi zero for testing and completion. POWER SUPPLY Typically, the Pi 4 comes with a USB-C port while the micro USB type is what obtains on Pi 3, 2 and 1. Just like most smartphones, all you need is to connect the device through its USB port to a power source.
Other necessary and specific power requirements:
For Raspberry Pi 4, you need 3.0 amps
For Raspberry Pi 3, a minimum of 2.5 amps is needed.
A MICROSD CARD Just like many other devices, you'll need a microSD card for file storage on your Raspberry Pi. This is well supported by the operating system, Raspbian.
Typically, an 8GB microSD card is recommended as it's capable of taking care of your storage needs. However, there are other SD card types that are compatible with the Raspberry Pi operating system, Raspbian.
KEYBOARD AND A MOUSE
Keyboards and mouse are important accessories that will enhance a hitch-free use of your device. After creating Pi setting for mouse and keyboard using USB, it will be easier to connect Bluetooth enabled accessories thereafter. A TV OR COMPUTER SCREEN FOR DISPLAY Connect the Pi through a cable to an external display to ensure full utilization of audio and display features. The external display could be a desktop monitor or a TV, the bigger the better.
HDMI Most computer displays come with DVI or VGA ports. However, The Raspberry Pi has an HDMI port which is compatible with HDMI ports on TVs and computer screens. 7
You also have the option to connect two displays to the Raspberry Pi 4 using its double micro HDMI ports.
The basic requirement for connecting your Raspberry Pi 4 to an external display is a micro HDMI that works with HDMI cable. If you don't have that, get a HDMI cable from both ends and add a micro HDMI adapter.
Raspberry models 1, 2 and 3 have just a standard HDMI port. To connect to an external display on these models, all you need is the regular HDMI cable.
DVI If the external display you wish to use has a DVI port, simply connect your device using the HDMI-DVI cable.
VGA Many displays come with only VGA ports.
To connect to an external display that has only the VGA port, use HDMI-VGA adapter.
AN EXTERNAL CASE It's not a bad idea to get a case for your Raspberry Pi. This will further ensure protection and longevity. For users with Raspberry Pi 4, Zero, and Zero W packages, an official accessory comes with them.
HEADPHONES OR SPEAKERS The
smartphones and MP3 players is what obtains on bigger Pi models. This means that you can connect stereo speakers or an headphone to your Raspberry device. If you're connected to an external display with in-built speakers, you'll also be able to play sounds and other media through them. Lastly, you can share audio connection with other devices using your Raspberry Pi.
ETHERNET CABLE Internet connection is an important part of a device's setup. Raspberry Pi 4, 3, and Pi Zero W comes with an easy wireless connection feature. As for bigger Pi models, except Pi Zero and Zero W, they use a regular Ethernet port. Other models like the Pi Zero require a USB-to-Ethernet adaptor for Internet connection.
HOW TO SET UP YOUR SD CARD Raspberry Pi supports SD cards but it has to be Raspbian compatible. Rasbian is the official operating system on Raspberry devices. There's little you can do with an SD card without Raspbian. The good news is, you can install the operating system on any SD card yourself. To do this, get a computer with an SD card port.
HOW TO INSTALL THE RASPBIAN OPERATING SYSTEM VIA THE RASPBERRY PI IMAGER If you wish to install Raspbian on your SD card, the fastest and easiest way is to use the Raspberry Pi Imager Note: You'll find good information here on how to install operating system images if you're a software geek.
RASPBERRY PI IMAGER
Make sure to choose a link that indicates the Raspberry Pi Imager for your operating system.
After download, click to start the installation process.
HOW TO USE THE RASPBERRY PI IMAGER It's important to note that this process overwrites all information on your SD card. Hence, it's advisable to back up all necessary files in other to avoid file loss. Windows will show you the prompt below as soon as you
administrative authorization, which is a requirement for most installations.
When this prompt appears, tap More info and click Run anyway.
From here, follow the on-screen instructions to install the Raspberry Pi Imager.
Insert the SD card into the computer or laptop through an appropriate port.
To install the Raspbian software within the Raspberry Pi Imager, tap the OS of your choice and choose the desired SD card.
The next thing is to tap the WRITE button.
Wait for the Raspberry Pi Imager to finish the installation process.
When you have a message like what's shown below on the screen, eject your SD card.
HOW TO CONNECT YOUR RASPBERRY PI To keep your accessories and external hardware safe, connect them to your Raspberry Pi properly.
At the base of the Raspberry Pi, there's a microSD card slot where you can insert the new SD card with the Raspbian Operating system.
Note: Typically, most MicroSD cards are housed in bigger adapters. To remove the card, press the lip at its edge gently.
To connect a mouse, attach its USB end to a USB port on Raspberry Pi.
To connect a keyboard, attach its USB end to a USB port on Raspberry Pi.
To connect an external screen,
Plug in the external display to a wall socket and switch on.
Locate the HDMI port on your Raspberry Pi, it has a flat extension at the top, which is what differentiates it from other ports.
Use an adapter and connect the display with a cable through the HDMI port.
RASPBERRY PI 4
Usually, it's recommended to connect your screen to the first port on your Raspberry Pi 4; it is identified as HDMI0.
Repeat the same steps above if you wish to connect another display.
For Raspberry Pi 1, 2, 3 All you need to do is to connect the external display to the single HDMI port.
Note: the display initially appears blank because Raspberry Pi is inactive.
Even though wireless connectivity is easier and more convenient, if you wish to go the wire route, an Ethernet cable is all you need. Locate the Ethernet port on Raspberry Pi, connect one end of the cable there. Connect the other end to the Internet router.
When you successfully set up an external display with in-built audio features, you should hear it work right away. You can plug in headphones or external speakers if you wish.
HOW TO START UP YOUR RASPBERRY PI Since the Pi comes without a power button, to turn it on, simply connect to a power source.
To do this, get a USB power cord. Attach one end to the Raspberry Pi power port, while the other end goes into a socket.
As soon as the Pi receives power, you'll see a red LED light bleep. Also, at the corner of the screen, you'll see animated Raspberries grazing the display.
FINISH THE SETUP During your first setup stages, you'll see a series of instructions on the Welcome to Raspberry Pi display screen. These instructions are to help you navigate the device.
Firstly, Tap Next to start the setup
Next, select your country, Language, and Time zone; tap Next again for the next instruction
You'll be prompted to input a new password that authorizes access on your device. Click Next as soon as you're done.
You'll also be prompted to choose and connect to a WiFi network. If you have one, select its name, input password, and tap Next.
Note: when you don't have wireless connectivity on your Pi model, the display is blank. At this stage, click Next and allow the install wizard to search and install available updates. Be patient as this takes a while.
To finalize the setup process, click Done or Reboot. Note: You're required to reboot the device after any software update.
HOW TO USE AND MAKE THE BEST OUT OF YOUR RASPBERRY PI
RASPBERRY PI DESKTOP Raspberry Pi uses a linux-based operating system; just like what obtains on Windows and macOS. The desktop appears directly on your display.
On the desktop, you'll see a Pi icon at the top-left corner of the screen which leads you to the menu on clicking. Most applications on the device can be accessed here. To open a text editor, simply go to Accessories, and then tap Text Editor. 28
To exit the text editor, use the x icon at the topright corner of the window.
You can also go through other interesting applications in the menu such as productivity tools and games.
KEYBOARD AND MOUSE SETTINGS To create mouse and keyboard settings directly from the menu, go to Preferences and tap Mouse and Keyboard Settings.
MOUSE In the mouse tab, you can adjust the speed, time lapse for double-click and also re-arrange the buttons.
KEYBOARD In the keyboards tab, you can adjust interval values and repetitive keys behavior.
You can also change keyboard appearance using the Keyboard Layout. Choose your preferred layout theme from the list of countries available.
CONNECTING TO THE INTERNET Like we noted above, Internet connection is an important part of a device's setup. 32
Raspberry Pi 4, 3, and Pi Zero W comes with an easy wireless connection feature. As for bigger Pi models, except Pi Zero and Zero W, they use a regular Ethernet port. The Pi Zero requires a USB-to-Ethernet adaptor for Internet connection.
HOW TO CONNECT TO A WIRELESS NETWORK
At the edge of the screen, tap the wireless network icon. Choose your network from the list provided.
Simply input the password to gain access into the wireless network if its password protected; tap Ok. 33
When you're connected to the internet successfully on the Pi, a wireless LAN symbol that imitates this connection is displayed; and the red crosses are no longer displayed.
To determine the strength and speed of the internet connection, simply search or surf the web using the browser. HOW TO SET UP THE SOUND Audios signals can be gotten on the Raspberry through two major routes. The first is through in-built speakers in an external display. The external display is connected to your device through an HDMI port. The second way is through headphones which receive direct frequencies.
At the top corner, right-click the speaker icon and select Audio Outputs. Also, select the desired connection profile; HDMI or AV Jack.
Re-tap the speaker icon if you wish to adjust volume using the virtual slider in a vertical direction.
HOW TO INSTALL SOFTWARE
The Raspberry Pi affords users the opportunity to install and use various software. However, you'll need to be connected to the Internet for this.
Recommended Software. Here, you can either browse through your app recommendations or simply save time by filtering results.
To start installation of any software, simply mark the check box beside it.
Finally, tap Ok to install. You can also visit the huge library of available programs to see more relevant applications. To do this,
Go to the menu, select Preferences and click Add/Remove Software. 38
For practical purpose, we'd like to install a drawing application known as Pinta. The first thing you must do is enter Pinta in the search box and tap Enter. From the list of programs displayed, choose Simple drawing/ painting.
Go to menu, tap Graphics and choose pinta if you wish to
installation. HOW TO UPDATE YOUR PI It's highly recommended to check for periodic updates on your Raspberry Pi. Updates usually come with better and enhanced features which will further smoothen your device use. Go to the menu, select Preferences and click Add/Remove Software. Refresh the software list by tapping on Options at the left corner of the display. Choose Refresh Package Lists.
Doing this makes the device present a fresh list of packages.
After the refresh action, tap Options and choose Check for updates.
To download recent updates, tap Install Updates Input your password or 'Raspberry if you haven't changed the default.
The updates are installed automatically after the download. The progress bar is located at the bottom of the display.
HOW TO ACCESS YOUR FILES
You can access your files through the file manager. All files are stored on the SD card. To access the file manager, go to menu, Tap Accessories and File Manager. You can also select the File manager icon directly on the menu bar When the file manager opens, the first thing you'll see is the Pi directory where you can save files and create subfolders.
To unlock the directory, tap the Document icon twice.
To open a file, double-click its file name. To see more options, right-click on the file name.
You can save files and create a backup on a USB drive with Raspberry Pi. To do this, insert the USB stick. Select OK to open in File Manager. These displays the files OK the drive.
HOW TO USE THE TERMINAL
Learning how to use the command prompt is an household skill. Here, we'll teach you how to use the terminal to control and navigate file directories instead of going through the menu. To start, select the terminal window, from the menu, tap the Terminal icon at the corner of the screen; tap accessories and click Terminal. 47
At this point, you can input commands into the dark window. Press enter at the end of each command to parse the instruction on your Pi. The terminal displays the Pi directory by default. Here, you can access all files and their subdirectories.
You can change the directory to desktop. Try to create a list of all files on the desktop using the terminal. Remember to always press enter after every command.
You can also exchange information at the command level aside creating a list and displaying files. Try the command pinout below, which displays a detailed GPIO diagram and other vital information about your Pi.
To close the terminal window, tap x or type the command "exit".
HOW TO CONFIGURE YOUR PI
To change your Pi’s authorization settings, go to Preferences and choose Raspberry Pi configuration. SYSTEM Change your Pi settings from the configuration box displayed
Password – The device comes with a default password but it's recommended to change it to something more personal. This is better and safer. 51
Boot – when you switch on your device, allow the CLI (Command line interface). Auto Login – when you enable this feature, you do not need a password to gain access to your device. Network at Boot – when you enable this feature, your Pi comes on as soon as it detects a network connection. Splash Screen – this shows the startup screen as soon as your Pi boots.
connection types which allows you to enable and disable any desired connection.
Camera – this option is used to toggle the Raspberry Pi Camera Module on SSH – when you share SSH, this enables remote access to your Pi from another device. 53
VNC – when VNC is shared between devices, this feature enables remote access to the Pi desktop from a computer. SPI –this option is used to toggle on the SPI GPIO pins. I2C –this option is used to toggle on the I2C GPIO pins Serial –this option is used to toggle on the Serial (Rx, Tx) GPIO pins. 1-Wire –this option is used to toggle on the 1-wire GPIO pin Remote GPIO – this feature enables sharing GPIO pins from third party computers.
PERFORMANCE Under the performance window, you can change the performance settings to suit your demands and needs. Warning: when you change the performance settings, you might experience some glitch. 54
Overclock – activate this feature if you wish to adjust the speed of your CPU to enhance performance GPU Memory –this option is used to change the storage size of GPU memory.
This option allows you to change your Raspberry Pi settings to a specific region, location and country. Locale – set a desired country, language, and character type for your Pi Timezone – allots a specific time zone. Keyboard – this can be used to change your keyboard theme. WIFI Country –input the Wi-Fi code by a specific country.
HOW TO GET HELP If you encounter any issue with your device, you can get help through any of the following avenue;
Go to raspberrypi.org, then click on the help section and the troubleshooting guide.
You can check the Pi forum for newbies and experts to seek solutions for any problem concerning your Pi.
On social media, get support from various Raspberry communities.
You can also submit a query on the Raspberry Pi Stack Exchange
Lastly, there are Raspberry Jam events where you can benefit from other user's experiences.
RASPBERRY PI COMPUTER WITH A CAMERA MODULE PORT
There's a port that allows every Raspberry Pi model to connect and use the Camera Module.
Note: for Pi Zero, you'll need a Camera Module ribbon cable that goes with the smaller Camera Module port on the device.
RASPBERRY PI CAMERA MODULE
There are two versions for the Camera Module; A standard version that captures image under normal light and a NOIR version, which captures images under extreme low-light situations using an infrared source of light.
HOW TO CONNECT THE CAMERA MODULE The first thing is to switch off Raspberry Pi. On your device's hardware, touch the Camera Module port. Remove the plastic clip and attach Camera Module ribbon cable into the port properly. Release the clip.
Switch on the device. Select the Raspberry Pi Configuration tool on the menu at the home page.
To enable your camera, choose the interface window and reboot.
HOW TO CONTROL THE CAMERA MODULE VIA THE COMMAND LINE You can input instructions via the raspistill and raspivid command line tools after making sure your Camera Module is connected. To open a terminal window, click the black icon in the taskbar Input the command below for a picture that will be saved on your Desktop.
Click enters and the camera will be enabled. It opens its window box as a picture is taken for five seconds. To view the image, search the picture file icon on the Desktop, tap twice.
You can also change the dimension of the raspistill image using specific commands such as adding -h and -w to adjust the height and width of the image.
To record a video when Camera Module is active, use the raspivid command line.
To play the video file on VLC Media Player, tap the video.h264 file icon on the Desktop
HOW TO CONTROL THE CAMERA MODULE WITH PYTHON CODE
To do this, open Thonny Python IDE, a Python 3 editor.
Try to create a new file and save as camera.py and not picamera.py Input the code shown below: 64
Save the code and execute. Note: camera preview is disabled if you're using remote access connection, such as SSH or VNC. If your preview orientation is not proper, switch to 180 degrees using the code below:
Adjust the image orientation through 90, 180 and 270 degrees. Set camera rotation to 0 degrees in the next code. 65
As you make changes with the code, the preview settings can be adjusted. Use a description called alpha level if you wish to adjust the opacity of your camera preview.
Alpha value is between 0 and 255. HOW TO TAKE STILL PICTURES WITH PYTHON CODE To debug your code using this method, use camera.capture():
Note: if you pause the capture time, this allows the sensor to adjust to any perceived change in light. 66
Execute the code. The preview lapses for five seconds while capturing the image. Also, you're free to adjust the resolution of the image to your preference. The new image can be found on your Desktop.
To capture 5 images at once, you can add a loop.
Note that the I in the range counts the number of times the loop runs. It starts from 0 to 4. On your SD card, the images are stored as image0.jpg, image1.jpg etc.
Re-execute the code
The camera captures an image for about five seconds and the preview ends after the fifth picture. The images can be found on your Desktop. 67
HOW TO RECORD A VIDEO WITH PYTHON CODE To record a video using python code, You need to rewrite your code by substituting capture() method for start recording() and stop recording() methods. Your code should appear like this:
Execute the code. At this point, the video preview opens, records for 5 seconds, and then disappears.
HOW TO CHANGE THE IMAGE SETTINGS AND IMAGE EFFECTS
On Python picamera software, you can navigate and try out so many effects and configurations.
HOW TO SET IMAGE RESOLUTION From the Camera Module, you can change image resolution. Image resolution is usually adjusted to match external display. For still images, the highest resolution is 2592 × 1944 while for videos, it's 1920 × 1080. The lowest resolution is 64 × 64. To set maximum resolution for a picture, jse the code below. The frame rate must be 15 for maximum resolution
HOW TO ADD TEXT TO YOUR IMAGE Use the code annotate text and execute if you wish to add a caption to your image.
HOW TO CHANGE THE LOOK OF THE ADDED TEXT You can Increase or decrease font size as shown below.
The default is 32 while the range is within 16 and 160. At the top of the program, you can add color to your import line of code.
Change the code to look like the image below under the import line.
HOW TO CHANGE THE BRIGHTNESS OF THE PREVIEW The default brightness is 50 with a range between 0 and 100. Execute the line of code below.
The loop below adjusts the brightness of your preview which allows you to add the brightness level as text:
HOW TO CHANGE PREVIEW CONTRAST Your can adjust preview contrast the same way we did for brightness. Execute the code below to try it out.
HOW TO ADD COOL IMAGE EFFECTS You can apply impressive effects to images using this method; camera .image effect. The following image effects are available:
Default images have no effect. Select any desired effect and use it for your image. 74
Loop all the effects on your image using this code; camera. Image_effects;
HOW TO SET IMAGE EXPOSURE MODE To make your image resonate a dominant theme, use the camera. Exposure mode in your line of code. Exposure modes available are: 75
If you wish to select all exposure modes and apply on the image randomly, use this line of code; camera. Exposure modes
HOW TO CHANGE IMAGE WHITE BALANCE Camera.awb_mode allows you to set the white balance to a preset mode. The following are the white balance modes available for your automatic settings:
Execute the auto white balance modes with the camera.awb_modes code syntax. TO SUM IT UP, As it is, you're well equipped with necessary information as regard how to navigate and manoever camera module using Python and other modes. You can also try the following:
Add extra buttons to the control using the GPIO Zero Python code on your camera.
Integrate device camera with Minecraft Pi.
Share the created images on twitter.
If you wish to get more hands on experience, you can experiment with the following tasks; 78
Create a cool push button to stop motion film.
Create a Minecraft photo booth.
On twitter, allow Babbage bear share pictures.
Use the NOIR Camera Module to design an infrared bird box.