Book Image

Raspberry Pi 3 Home Automation Projects

By : Shantanu Bhadoria, Ruben Oliva Ramos
Book Image

Raspberry Pi 3 Home Automation Projects

By: Shantanu Bhadoria, Ruben Oliva Ramos

Overview of this book

Raspberry Pi 3 Home Automation Projects addresses the challenge of applying real-world projects to automate your house using Raspberry Pi 3 and Arduino. You will learn how to customize and program the Raspberry Pi 3 and Arduino-based boards in several home automation projects around your house. This book aims to help you integrate different microcontrollers like Arduino, ESP8266 Wi-Fi module, Particle Photon and Raspberry Pi 3 into the real world, taking the best of these boards to develop some exciting home automation projects. We will start with an interesting project creating a Raspberry Pi Powered smart mirror and move on to Automated Gardening System, which will help you build a simple smart gardening to keep your garden healthy with minimal effort. You will also learn to build projects such as CheerLights into a holiday display, a project to erase parking headaches with OpenCV and Raspberry Pi 3, create Netfl ix's "The Switch" for the living room and lock down your house like Fort Knox with a Windows IoT face recognition-based door lock system. By the end of the book, you will be able to build and automate the living space with intriguing IoT projects and bring a new degree of inter connectivity to your world.
Table of Contents (7 chapters)

Moving on to the LXTerminal

While the Raspberry Pi has a healthy variety of applications and programs for our consumption, we’re going to be primarily using the LXTerminal to download and interact with the Magic Mirror program. For those of you unfamiliar with the Terminal, it’s essentially a program that allows a user to directly manipulate their computer system through the use of commands. As we move through the text, when I refer to the command line, I’m talking about the Terminal and the location where a user will input the commands.

Understanding how the Terminal works and being able to use the command line is a very powerful tool when working to manipulate files on the Raspberry Pi. Commands can be strung together and input in order to efficiently carry out tasks that other applications cannot. When you initially open LXTerminal, you will see a screen with a blinking cursor. On the left-hand side, there will be a prompt that shows your current username and the hostname of the Pi. Both the username and hostname can be changed later on in settings if you’d like to tailor the Pi further for your uses:

Basic Linux commands

There are basic Linux commands that are going to be very useful in your navigation through your filesystems through the Terminal. In this section, I want to list some essential commands that will help you when building the Magic Mirror. With each command, I’ll provide a brief explanation. As with anything, the best way to learn how to successfully use these commands is with practice. Also, note that syntax is important when working with the command line. The computer interprets capitalized and uncapitalized letters as two different symbols, so we have to make sure we type our commands as they are shown. A good rule of thumb is that if something doesn’t work the first time, go back and proofread what you have typed.

Helpful commands

Here are some helpful Linux or NOOBS commands that will come in handy when you work on your Raspberry Pi:

  • sudo: Short for super user do, this command is powerful and necessary. When used before any others in the command line, you're telling the computer that you are running the command as the root user. This gives you the ability to alter files that may be unalterable to the regular user on the computer. When first working with the Terminal, I suggest you use sudo primarily, as opposed to su (though su is needed for particular actions). This will curtail your use of the super user command, putting a slight speed bump between you and any commands that may unintentionally delete necessary files from your system.
  • su: While similar to sudo, instead of running a command as root, su makes you root. As I said earlier, sudo is useful for targeted commands, but if you’re working extensively as root, su may be the better option. Just make sure you stay aware that you're working as a root user, as you do not want to delete anything necessary in your Raspberry Pi system files.
  • cd: This changes your location to a directory of your choosing. Remember, a directory is essentially a folder, and this allows you to navigate to a specific folder as long as you know the pathway. Furthermore, if you are in a specific directory and want to return to your /home directory, typing in cd will bring you immediately back to /home.
  • cd –: To build on the cd command, a useful command is to add the dash after the space after cd. This will allow you to immediately return to the previous directory in your pathway, for example, cd /MagicMirror/modules/. This will bring you to the modules folder within the MagicMirror folder. If you want to go back to the MagicMirror folder, you would then type cd –.

  • ls: When you're in a directory and wish to know the folder's contents, typing in this command will list the files within the folder.

  • pwd: This stands for print working directory. It is very useful if you’ve forgotten your current pathway or need to access that information.

  • mkdir: This command enables you to create a directory with a name of your choosing.

  • cp: This is the copy function. It allows you to copy a file from its source destination to another destination of your choosing.

  • nano: This command calls upon the Terminal’s nano text editor, enabling you to access and modify the contents of the file from within the Terminal emulator. This is very useful for quick changes to files on the Pi, and I will be using this as the command-line editor for this text.

Let's move forward. I find these to be the most useful commands for this project; however, there is a vast array of commands that will make your navigation more efficient. As you learn more with the Pi, it’s encouraged that you research more commands and how they work in order to maximize your experience in LXTerminal.