Ultimate Guide to Raspberry Pi : Tips, Tricks and Hacks | Lee Assam | Skillshare

Ultimate Guide to Raspberry Pi : Tips, Tricks and Hacks

Lee Assam, University Instructor, Software Developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
71 Lessons (4h 35m)
    • 1. Introduction

      3:29
    • 2. What is a Raspberry Pi?

      4:08
    • 3. Hardware Components that you will need

      2:49
    • 4. Let's Connect Everything Together

      1:26
    • 5. Understanding some basics about SD Cards

      5:26
    • 6. Accessing SD Cards

      3:26
    • 7. Downloading and Installing Etcher for Flashing your SD Card

      2:15
    • 8. Installing the Raspbian Operating System by Flashing our SD Card

      3:07
    • 9. Resource for checking the validity of your SD Card

      1:01
    • 10. Tips for Preventing SD Card Corruption Issues

      4:20
    • 11. Standard configuration settings and best practices

      4:55
    • 12. SSH (Secure Shell)

      6:46
    • 13. VNC (Virtual Network Computing)

      4:29
    • 14. SFTP (Secure (SSH) File Transfer Protocol)

      3:51
    • 15. SCP (Secure Copy)

      3:18
    • 16. RDP (Remote Desktop Protocol connection - Windows)

      2:21
    • 17. Introduction to the Terminal

      0:43
    • 18. Understanding User Modes in Linux

      3:39
    • 19. Useful General Terminal Commands for the Raspberry Pi

      7:15
    • 20. File and Directory Commands

      9:10
    • 21. Networking Commands

      6:16
    • 22. System Commads

      5:03
    • 23. Keyboard Shortcuts

      5:16
    • 24. Understanding the APT Ecosystem

      3:16
    • 25. Installing Software using APT

      6:43
    • 26. Creating a One Line Web Server with SimpleHTTPServer

      5:55
    • 27. Installing the Apache Web Server

      5:32
    • 28. Installing the PHP Application Server

      5:18
    • 29. Introduction to GPIO pins

      7:38
    • 30. Standard Components Needed

      1:23
    • 31. Downloading Code and Resources for the Course from Github

      1:46
    • 32. Powering an LED

      6:37
    • 33. Wiring Change to Blink an LED

      2:10
    • 34. Demo the circuit

      1:05
    • 35. Blink LED Code Review

      2:41
    • 36. Button Press Introduction and components that are needed

      1:06
    • 37. Button Press Wiring

      3:18
    • 38. Button Press Demo

      1:44
    • 39. Button Press Code Review

      4:42
    • 40. Button Press LED Intro

      1:42
    • 41. Button Press LED Wiring

      4:50
    • 42. Button Press LED Demo

      1:48
    • 43. Button Press LED Code Review

      5:21
    • 44. Introduction to PIR Sensors

      1:43
    • 45. PIR Sensor Components Needed

      0:53
    • 46. PIR Sensor Wiring

      3:01
    • 47. PIR Sensor Demo

      2:31
    • 48. PIR Sensor Code Review

      3:04
    • 49. PIR Sensor Alarm Intro

      1:13
    • 50. PIR Sensor Alarm Wiring

      5:59
    • 51. PIR Sensor Alarm Demo

      2:51
    • 52. PIR Sensor Alarm Code Review

      7:15
    • 53. Working with Cameras and Images Introduction

      1:06
    • 54. Connecting your USB Web Cam

      1:06
    • 55. Installing and Configuring Motion to setup a Web Cam Server

      6:49
    • 56. Demo of the Motion Web Cam Server

      3:19
    • 57. Preparing your System and installing fswebcam

      4:49
    • 58. Using fswebcam

      3:40
    • 59. Using a script to take images with fswebcam

      3:19
    • 60. Fswebcam script code review

      2:13
    • 61. Introduction to the Pi Camera Module and how to connect it to the Raspberry Pi

      2:21
    • 62. Getting a Preview using the Pi Camera

      4:10
    • 63. Capturing a Still Picture of Image with the Pi Camera

      2:17
    • 64. Capturing a Series of Photos with the Pi Camera

      3:38
    • 65. Recording Video with the Raspberry Pi Camera Module

      3:59
    • 66. Using special effects with the Pi Camera Module

      10:08
    • 67. Why build an Amazon Echo Clone?

      1:39
    • 68. Alexa Clone Components Needed

      2:03
    • 69. Setting up your Amazon Developer Account and Registering your Amazon Echo Clone

      10:11
    • 70. Installing Git and the Alexa Pi Software

      5:33
    • 71. Alexa Clone Demo

      4:47
12 students are watching this class

About This Class

This course will provide the information you need to Master the Raspberry Pi 3! It assumes no prior programming or electronics knowledge and walks you through everything you need to know to use the platform to the fullest! Learn how to setup the Raspberry Pi, install software, work with Linux, work with GPIO pins and circuits and build projects like an Amazon Echo Clone.

e30a9939

This course will provide the information you need to Master the Raspberry Pi 3! It assumes no prior programming or electronics knowledge and walks you through everything you need to know to use the platform to the fullest! Here are some of the topics that are covered:

  • We will first dive into what the Raspberry Pi is and learn what components you need to set everything up

  • Step by step videos on how to set it up

  • We will walk through how to easily flash an SD card with any OS for the Pi

  • We will talk  about tips to prevent SD card corruption

  • We will show configuration tips for the Raspbian Operating System

  • Multiple methods of connecting remotely to your Raspberry Pi will be covered to show how you can run it in "headless mode" without a monitor

  • We dive into the Terminal and Linux commands to show how you can navigate your system, work with files, perform network and system commands and keyboard shortcuts

  • We dive in depth into the APT Package system for installing software and show how to install any software for your Pi

  • Best practices for securing your Raspberry Pi are covered

  • We install a Web Server using different approaches

  • We work with GPIO pins and show how you can control LEDs, determine if a button is pressed, work with a PIR sensor and will make a PIR sensor alarm circuit

  • We will do Python code reviews for the projects so you will understand how the software and hardware work together

  • We work with cameras and images and show how you can setup a USB web cam and install software to create a live streaming camera feed

  • We use the Raspberry Pi Camera module and show how you can interact with it programmatically to take photos, video and create special effects

  • We create a working Amazon Echo Clone with the Alexa Voice Service

  • Much much more!

No previous programming or electronics knowledge is required.

You get the best information that I have compiled over years of trial and error and experience!

Learn the Raspberry Pi 3 fast! Install software, build circuits, make projects! 

Get started now!

Checkout the Project for all the Presentations, Resources and Links you will need for this course.

Transcripts

1. Introduction: This is the respirator pie. What a truly amazing piece of hardware on this tiny board is packed. Everything that you'll need to make a personal computer. Ah, home entertainment system, a security system, a gaming system, an Amazon echo Clunes, a Google home coun and much, much more Possibilities are endless high family Assam. I'm an electrical engineer, professional software developer on university instructor. But most importantly, I have been playing around with the raspberry pi since its inception in 2012. Along the way, I have learned quite a lot. Now it's time for me to share all of that information with you to bring you tips, tricks and hacks to make you more productive on your respirator pie. I've packed years of experience, trial and error on the research that bring you the very best information for this course, which is the ultimate guy to respirator pie. Here is a look at what the course will cover. We fools get into the hardware components that you will need to set up your respirator pie , and I will show you how to connect everything up. We then dive into SD cards where I will show you how to easily flash and prep an SD card for any operating system for your raspberry pi. We then go into talking about how to configure your raspy and install on. I will show you the different ways you can connect remotely to your raspberry pi. We also get hands on with the terminal, where I will show you a multitude of Lennox commands and tips and tricks to be productive. The fund then begins with G P. I opens on. We will connect several circuits on. You will see how we can use python to programmatically send outputs. Take readings from sensors on build interesting circuits. Along the way we will be learning some python, which is the programming language of choice for the raspberry pi. We, then del Vinto working with USB Webcams and the Raspberry Pi camera module. We will see how you can programmatically take pictures and video so that you can embed these capabilities into your Internet of things. Projects with n tackle, A few fun projects like building an Amazon echo clue. I will walk you through how to do this step by step. Alexa. Yes, What is Falcon heavy Much, much more. No previous programming or electron ICS knowledge is required for this course. I will teach you everything you need to know from scratch. If you heard about the raspberry pi and want to learn more on, see what it can do all. You just want to have a deeper understanding of the raspberry pi platform. Take the ultimate guide to rest rape I This is the course for you. Check out the free preview lectures on I can't wait to get started with. You were going toe. Have a blast. See you soon. 2. What is a Raspberry Pi?: The Raspberry Pi is a small single board computer that was developed in the UK by the Raspberry Pi Foundation in order to promote teaching of basic computer science in schools and developing countries. It is very inexpensive on with the latest model. For only 35 bucks, you can get on entire computer on a single board, complete with WiFi and Bluetooth functionality built in. Since the release of the first vision in 2012 the popularity of this board, especially in education, has skyrocketed. So what can you do with a raspberry pi? You can install an entire operating system and use it as a fully functioning computer, allowing you to edit documents, surf the Internet, program computer software and use it as a D today computer. It runs a variety of Lennox distributions with raspy in being the most popular, which is what we will be installing in this course. And it even has a Windows distribution when those I ot core, which runs on it. Okay, great, you may see, but what exactly can you do with a team? A ask? Well, because of the GP I opens, which provide the ability to connect an interface with external sensors and electrical components. It can be used in robotics and prototyping projects. You can also use it for home automation on industrial automation. You can also set up your own gaming system to play older Nintendo Super Nintendo Sega PlayStation games Fire Emulation Software on you can set up a media server to stream and play your digital movies. Music on online content The possibilities are endless, and we will learn some of these applications in this course. Now let's take a look at the respirator pie three Model B, which is the model we will be using for this class. You can certainly do the class with earlier models, but you'll need a WiFi dunkel to get connected to the Internet with version two models and earlier. Alternatively, you can use ah hardwired networking connection by on RG 45 networking cable. The earlier visions will also not be as fast as Division three. Here is a rundown of the Raspberry Pi version three TCP. You uses 64 bit quad core architecture and runs at 1.2 bigger hoods, and this could be over cracked. It has a one gigabyte of memory. It has four USB ports, which enables you to connect to peripherals like a mouse, keyboard, microphone and speakers, etcetera. There's an HD in my connection, allowing you to connect to a monitor or TV for the spleen content. It also has built in WiFi and Bluetooth capability, allowing you to easily take your projects in tow. Wireless mood. It also has an Ethernet port toe. Allow connections to traditional RJ 45 network cables. Forward connectivity. There is a 15 pen, maybe camera interface connector that can be used with a raspberry pi camera. There's also an analog audio port that works with a 3.5 millimeter jack on. It has 40 GP I opens or general purpose input output pins that can be used to interface with your electronic components on sensors. A power connector is also present as it requires fables to operate, and it also uses a micro SD card slot, which is the onboard storage. The SD card contains the operating system. We will be talking about how to get this or prepped unloaded to run your operating system. That is quite a bit of power and functionality on a single board for only $35. So know that we have an idea of what the raspberry pi is and what it can be used for. In the next few lessons, we will look at how we set everything up. 3. Hardware Components that you will need: No. Let's talk about the various components that you're going to need for a respirator pie. But those who are beginners to respirator pie. This would be a discussion on everything you need to get your by up and running. And for those experience veterans, you can feel free to skip ahead for this lesson. So, first, of course, we're going to need a raspberry pi itself. I am using the arrest Reap I three here. But of course, you can use any version of the respirator part that you may have available next. You also need ah, power supply. So this is a fight full power supply with an adapter that you plug into your esprit pie that's needed to provide the power needed for the pie to operate. You also need an HD. My cable on this can connect to ah, monitor under will enable you to see the output of the respirator pie on a screen. Alternatively, if you don't have on each dear my monitor, another option is on each day. Am I to V G a cable? So this end can connect directly into the raspberry pi, whereas the other energy conceit is a PGA connection on this can connect to your VG monitor , so this is a handy component. If you don't have on each day, monitor on Al. Put a link to this in the resource is for the video. Next up, we are going to need an SD card. Onda. Of course, we have to flash this first and prepare it with the operating system for a pie. In order to access the SD card. We're also going to need some type of SD card reader. So a couple options. You have this SD card adapter that you could insert your SD card in here and then insert this into a laptop or PC toe Access. The SD card or an alternative vision is this USB fob, where you can insert your SD card into here and then insert this into a USB slot to access the SD card. Next, you'll need a USB keyboard and a mouse. As you can see here, I have a keyboard and a mouse that's combined in one. Andi. It is wireless and works fire a USB connection, so I just need toe plug this into my spray pie and by just using one USB port and ableto have both the keyboard and the mouse. Alternatively, if you have, ah, separate USB keyboard and mouse, that would work fine as well. So there you have it. That's all you need for your esprit pie. And of course, in addition to this, you will need a monitor that you would connect the raspberry pi to in order to display output. But those are all the components that you need to get your system up and running. 4. Let's Connect Everything Together: Now let's take a look at how we connect all the components together for our raspberry pi. So first you get the raspberry pi itself. Andi, you would then insert That's through the SD card first. Of course, the SD card has to be flashed on prepared and we will address that in another video. But once your SD card is prepped and flashed with your operating system, he can proceed to ensued. This for study back of your aspect by next weaken Set up the power supply. So I'm gonna just take this power supply. Andi, on the raspberry pi board itself, there would be the power connector. So go ahead and insert that into there. Next, I'm going to insert the USB keyboard and mouse. As I mentioned in my case, I have a wireless USB keyboard mouse that's combined. All I need to do is plug in my USB connector here and one of the USB slots. Then we need to connect the each in my cable. So here are plug this into the each day, my slot on the raspberry pi and the other end will go to my monitor. So that's essentially it once. Ah, SD card is flashed ready to go and we've connected all the components we can plug in our pie. Onda, boot up our system. 5. Understanding some basics about SD Cards: Let's talk about a very important topic in the world of respirator by hardware SD CARDS These are essential to getting your esprit by up and running there. What the OSO operating system are installed on on contain all the data configuration and software needed to make your pie function. What we're looking at here is the downloads page from the Respirator Pie website. As you can see, we have a variety of operating systems that we can choose from. Please bear in mind that this peach main looks likely different when you are viewing this video as it is updated frequently, but the concept should remain the same. First we see Nub's, which is a collection of us, is catered for newbies, then the ever popular raspy in which is the most installed us for raspberry pi scrolling down. You can see we also have some third party operating systems that we can choose. From here we can see versions off, a boon to to choose from when those 10 I ot core, which at the moment is the only Windows beast os created that runs on raspberry pi. Then we have USMC on the library elect, which are distributions that serve as media entertainment centers to collectively store, organize and distribute your movies, music, TV shows and photos. So what's a good guideline for the capacity in terms of size of the SD cards that you will need for these distributions here have created a summarize breakdown for you that conserve as a guide. Nubes, crispian, baboon to and Windows 10 I ity core all recommend SD cards with at least eight gigabytes of capacity for successful installation and operation. Of course, if you can go a little bit higher with a 16 gigabyte or even a 32 gigabyte SD card, that would be even better. Raspy in Light, which is a lean, slimmed down version of raspy in based on Debian, requires much less capacity. On the only needs a four gigabyte SD card. Some of the other third party installations, such as USMC Onda Liberally Elect, are built to be less resource intensive and can operate on less than one gigabyte of space . A two gigabyte or a four gigabyte SD card would suffice and might be the best for those. If, however, you intend to store your movies or media on the SD card itself. With these distributions, you'll need a big arrested cart. The standard practice, however, and configuring these media players is to connect to a USB attached hard drives or USB memory stick or access a network attached storage module over the network. Fire various particles such as ssh, Samba, sftp or even air Plea. What's my recommendation? Well, I say go the 16 gigabyte SD card, which would allow sufficient storage and flexibility for any operating system of your choice. That's no address. Another concept you might hear about when referring to SD cards. The SD card class. When you hear the term class you can think of it does essentially be right speed for the card. As an example, a Class four car typically rights at four megabits per second, whereas a Class 10 card can conceptually rewritten with speeds of up to 10 megabits per second. Now you meeting that a Class 10 would always perform better than a class four as the right speed is faster. This, however, is not always the case because right speed is achieved at a cost to read speed faster. Right speeds usually imply longer seek times, which affects the rate at which the data is read from the card, resulting in slow a performance. What's my recommendation here? Well, for later visions of raspberry pi It's better to go with a Class 10 SD card windows. Coyote core, as an example, requires a Class 10 card. Overall, a Class 10 should give you the best operation on the most circumstances. All their models of the raspberry pi made typically operate fairly well on lower class sizes. Let's no talk about the physical size of SD cards. There are two means sizes that you have to look out for. They are the full size SD card and then the micro SD card. The original raspberry pi model A and model be used the bigger full size SD card, while the newer versions of raspberry pi, such as theme model A plus B plus raspberry pi to Model B and the respirator by zero on the respirator by three Model B used the smaller micro SD card 6. Accessing SD Cards: Let's get a little more hands on and take a look at SD cards. And here we have a couple of examples. The 1st 1 is a micro SD card, but as you can see, it's Ah, it's pretty tiny Andi. Here is the original SD card full size SD card. Notice how much bigger it is than the micro SD card on DA. Basically, these are the two sizes that we spoke about physical sizes and one thing that I also wanted the address was. How do we read these SD cards? Or how do we communicate to them when we're flashing images, fire our laptop or PC? And they're a couple of ways that we can do it. This here is on SD card adapter that we can use to read our micro SD cards. So essentially, how this works is we take our SD card. We insert it into the SD card adopter and then this is inserted into the SD Card reader slot in your PC or your laptop. So that's one way that we can access. Ah, the micro SD cards. Another way is that here is an example of a USB fob and it has a connector that we're able to insert the SD card in. So here I'm gonna insert the micro SD card on. Once that's done, I simply need to insert this into the USB slot in my piece here on my laptop on, I'll be ableto see the SD card and read and write to the SD card. So that's another option or an adopted at Seoul that can allow you to access the micro SD card. Of course, for the fools of Size SD card. If you have an SD card reader in your laptop or PC, just insert this into the slot and you'll be able to access this full size SD card. So just to show also how these are inserted into your raspberry pi, have a couple of raspberry previsions here. Here's an original raspberry pi one on. As you can see, this particular one uses the bigger full size SD card, so at the back noticed the slot. Here, you can take your full size card and the simply inserted in. Once you've flashed it with the sell, this sticks out quite a lot, but that was the original design, and that's how you'll be able to boot up your pie and access the contents of that S D card . So here is a respirator by three. As you can see at the back, it uses the micro SD card with a smaller version. So you simply take that micro SD card and inserted into the back. OK, notice how much it it's doesn't protrude like the original raspberry pi. But these are wholly smaller. Micro SD cards work with frost, very private versions three and some of the newer visions. So there you have it. So just wanted to cover those couple of concepts around the SD cards the physical size is and how they are inserted into the various versions of the raspberry pi. 7. Downloading and Installing Etcher for Flashing your SD Card: when it comes to flushing an SD card and prepping it with an West image for a spray pie. No other tool even comes close to nature. You can get to enter by typing in nature that I own a browser, and that should land you on the at your home page. It is by far the easiest and most simple tool to get the job done after essentially allows us to select an image. We want to flash on our card and click on the flash button, and it takes it over from there. It Ben would form at the card for you. If it is not empty, copy the corresponding image and then verify it was successfully transferred. The process only takes a few clicks and you are done. Etro also makes it our proof so that you don't select your hard drive that has your operating system and stolen at the flash. It will only allow you to select USB drives or any SD cards that were inserted into your PC or laptop in order to flash. And that's a great safety mechanism. Let's go ahead and install the letters software. The installation process is extremely straightforward I have a Mac, so I get the default option to download from Marco s. If you click on this drop down link here, you'll see different options for different OS distributions. So, for example, if you're running a Windows 64 bit machine, you can select the first install a link, which would give you the exit file to install. Better. Also, if you're running a little machine, their options for you to install the LETRAS software as well. For Mac users, the process is extremely straightforward. Go ahead and click on download from our quests. You can see this anywhere in your system. Once you double click the DMG file, he just drag and drop it to your applications folder and you are done. So no matter what operating system you're running, Marco s Windows or Lennix is a vision of nature that could be installed. Eso go ahead and I would highly recommend you install at your for flushing. The SD cards fair are spread by 8. Installing the Raspbian Operating System by Flashing our SD Card: know that we have assurance told, let's demonstrate the process of flushing an SD card. So the first thing that we'd want to do is download on particular image that be one to flash on our card. Let's choose recipe in. So I'm gonna click on the raspy in link here from the raspberry part or website on going to download the zip file for the raspy in stretch with Best Up. As I mentioned, this site may have changed on me. Looks likely different when you visited from when the video has been recorded. So just go ahead and download the appropriate vision of raspy in on DA. The ZIP file is actually what we're interested in. So click on download zip. We're going to see this on your computer. You conceive it so you know anywhere you want. Get that download going. So going toe, pause the video here and we'll resume once the download has finished. Okay, so our download has completed and ah, the raspy in images stored on our our Dr or the Actually the zip file. So now let's fire a picture. So I'm gonna open up at your que and it loads up here. So the first thing that we need to do is insert our as D card into our if it's, ah, USB connector using Go Ahead and Sirti SD card did USB slot? Or if you have an SD card reader with an adopter, you should go ahead and insert that in. That's the first thing that you should do. Then click on Select Image. So here we're gonna select that. Is it file that we don't noted for ESPN. Click on Open here. Now you'll notice that at the middle here, what should show up is the SD card selected by default that you inserted and your USB drive or your SD card reader. So again, ETRA makes it very easy for you. Select this by default. It would not mess up your mean hard drive or system or flashy mean system. There is a security mechanism that's built in, so just give a quick verification that decides that you see here is the size of your SD card. In my case, it's a 16 gig SD card that I'm using. So once that looks good to go click on the flash button. So now the process is starting so it may take a couple minutes to complete this process. So I will pause the video here and we will resume when the flashing process is completed. Okay, so now or flashes completed on DA, the process is all done, or SD card is prepped. We can proceed to take the SD card inserted into our Asprey buy and boot up for the first time. So the process was a simple and easy and painless as that editor definitely simplifies the entire process for us. 9. Resource for checking the validity of your SD Card: here is a great resource that I have found that has generally kept up to date. It shows various brands and makes off SD cards on the results of tests that will run to see if they work with the raspberry pi. It might be a good idea to take a look at this list before you purchase an SD card for your pie to ensure that it is compatible on that it would work well and reliably, I will post a link to the site. In their resource is for the lecture as an example. Here we have the Amazon be six SD card. Andi, it looks like it tested okay to be used for the raspberry pi. The size was an eight gigabyte and class was a 10 on this particular record. Here s O. That particular combination worked well and it probably would be safe to use that one on your raspberry pi 10. Tips for Preventing SD Card Corruption Issues: before we finish our discussion around SD cards, there is one last topic that I'd like to address and that is how do we prevent SD card corruption issues? This is more common than you think. And as a matter of fact, a couple of days ago one of my SD cards got corrupted Onda. What have compiled here is just a list of best practices that I have found that really helps to ensure that you get the best performance out of your SD cards. You avoid corruption on that. They work a little bit more reliably. So the first point on there is around using genuine SD cards. On. There are lots of cheap SD cards that you can get on sites like E B and Alibaba, Onda, Amazon and and so on. You just have to be mindful of the type of SD card that you get. Verify that it is first of all compatible with your esprit pie from that resource that a I spoke about in the previous lecture on. Also, you want to check the reviews for the different types of cards are card that you're interested in. Make sure there have been a lot of positive reviews from customers who have purchased it and could attest the reliability of the card. So that's something you just want to look out for when you're getting an SD card. Next up is using a good quality PPO supply. Believe it or not, this can corrupt your SD card. If there's a fold in your power supply or if it doesn't deliver enough current, it could cause the pie to become unstable. Onda could potentially result in corruption issues on the SD card, so of course, the power supply has toe provide five volts DC But just ensure also that a good current rating of about one AMP or more. If that's the reading on your pro supply, that would probably be better to ensure reliability and stability of your raspberry pi. So again, just if you're buying a power supplies separate from a kit that comes in a kit, just make sure you check out the reviews and see what other customers have. You know the feedback that they have left on the par supply Onda choose one that's right for you. Next up is also using a good quality USB cable for the power supply. Sometimes if there is a short in the cable or if there are issues with the connection. This good results in corruption issues and the SD card. So just verify that cable as of a good quality. And this could be a difficult issue to troubleshoot. It has happened to me in the past. This is just something to be aware off another that practice. And actually we will delve a little bit deeper into this when we talk about working with the terminal in another section in the course. But before you shut your pie down, typing in pseudo space holt from New Terminal at the command line. That's a good practice because it generally closes off. Any exist in processes and but your pie in a good state before you shut it down. So I would highly recommend before you shut your pie around typing in pseudo space Holt Onda that also prevents SD card corruption issues as it leaves your pie in a good state before you part off. The last point on there is around over clocking, and we actually will delve more deeply into over clocking than what it is in another section of the course, but essentially over clocking is getting your pie to perform faster than the default settings of the operating system. So this can be tweaked, and I'll go into how we can do that in another lecture. But this has been loaned to cause as the card corruption issues. So just be mindful of that Onda. Take that into account when you're over clocking, and you may have to strike a right balance on not over clock to the highest extent possible , but finds a medium that would ensure reliability and stability of your pie and prevent SD card corruption issues. 11. Standard configuration settings and best practices: Now we're going to take a look at some standard configuration and best practices for setting up your raspy an operating system. So here we have raspy in installed on. Of course, the first thing that you'd want to do after you boot up your pie for the first time with a newly flashed raspy an image is to connect the Pi toe wireless network. So if you go to the icon at the top right, the WiFi icon here he will see WiFi networks that you can connect to them and click on it. Actually, if you have a network, your home network here, you can just simply click on it. Provide the credentials and you'll be able to get your pie connected to your network for Internet connectivity. So once that is complete, let's go and tweak our configuration settings. So if you click on the raspberry icon and you go down to preferences and raspberry pi configuration, this brings up a simple, gooey interface toe. Allow you to change your settings and configuration for your restaurant pie. So the first thing we'd want to do is change our password. This is a basic security mechanism, and the default user for respirator pie as pie P i and the password as raspberry Our a s p b r r y. But of course, if you leave this potentially anyone who has access to your network could get access to your Asprey part. So it's a good security measure to change the default password. So go ahead and click on change password. Enter a new password here of your choosing, okay. And we're not stunned. You click. OK, all right. And you get a confirmation that he password has been changed successfully. Next up, we can click on interfaces and their several different options here. As we progress in the course, I will describe these options in detail and basically how they're used. But for now, what we can do is enable the camera ssh secure show SP I on die Squared C. Those are communication particles that we will delve into a little more detail in a later lecture. In the course, we can click on cereal Onda removed cheap value. Okay, And once that's done, let's go ahead and click on localization performance. We're going to talk about that a little later on, but let's for now, Let's go ahead and pick on localization, said Loco. Andi. Essentially, this is where we can set based on your language and your keyboard preferences and your environment and so on. We want to set these settings so that they're putting into you and can make you more productive on your respirator party. So go ahead and click on set. Look out, Onda. You select your language. Of course, Mine's is English on the country. I'm just going to select the United States here, in my case for character set on. Leave that as utf it look OK, next we're going to set up the time zone on Dhere. I am just going to select the times on that relevant to me, which is central time. And of course you can choose which of a setting is appropriate for you here for the keyboard. We want to ensure that the keyboard that we're working with his set up for the appropriate language, country and variant. So I'm going to select country here. United States Onda variant English, us on. Of course, you select here whatever is appropriate for you, click on OK, and then finally the WiFi country. I'm just going to select here the United States Click King Andi. Then we should be done. So when you click OK, you should get a prompt to reboot, meaning that the changes and meaning that in order for these changes that take affect your esprit pie has to be rebooted. So go ahead and do that now. Yes, on those new changes would take effect. So those are there some standard recipe in configuration settings that would enable you to be more productive on your raspberry pi. 12. SSH (Secure Shell): so the first way that we can connect remotely toe our raspberry PiS via ssh or secure shell . Essentially, this is a command line utility that allows us to connect to our esprit pie where week would be logged in, and we can perform instructions from the command line to control our pie. So before we get going, the first thing we need to do is make a note of the I. P address that was assigned to us when our pie connected to our network. So if you hover over the WiFi icon here, you'll be able to easily see what the I P addresses. In my case, it's 10.0 dot 0.106 or alternatively, via the command line you can type in i f conflict and looking at the W lan zero here. As you can see this, you will also see the I P address here tend not 0.0 dot 106 So make a note of that I p address because it's important we're gonna need that when we connect via a sausage. Something else that we need to ensure is that connecting via ssh is enabled on your esprit pie. And if you followed along in the configuration settings And when we looked at the various options here, you'll be able to see on interfaces. Ssh was enabled. So this needs to be enabled for us to connect fire, assess age on also weaken See via v NC, which we will address a little bit later. These two need to be enable the before we can connect remotely. So once we have taken care of those housekeeping rules, let's go ahead and first look on a Mac or Lennox machine how we can ssh fire a terminal. So on the mark, I'm gonna just fire up here a terminal Onda. You want to ensure, of course, that the PC or laptop you're connecting to your respirator pie with his only seem network. So they not only seem that work, they can talk to each other. So make sure that whatever device you're trying to remotely access your pie with is only seem network for the ssh demonstration. So the command we're gonna type in his ssh Onda we put in the pie user Onda. Then we enter the I P address that we meet a note off So in my case, it was 10 not 0.0 dot 106 Onda top Enter. It would give you a prompt to validate that you're connecting on what the key fingerprint is. So it's type and yes, and then you have to type in your password. So this would be the password that you initially reset when we did our configuration settings. If you didn't reset it, it would be raspberry. But go ahead and into your password here on did No. We're actually connected to our respirator pie so we can take a look at the file system. This is the file system that's only pie. And now that we're connected by SS age, we can actually run commands on the pie and control rpai. Just a Ziff. We will physically connected via the keyboard that's connected to the USB slot of the respirator pie. So it allows us the administratively control the pie and work with it on in a very, very powerful way, using landmarks on the commanding. So that essentially, is the ssh connection from our Mac. We can copy files, delete files, start and stop processes, and so on. Install software on DWI have full rein to do whatever we need to do for Eddie. Command line. This is, of course, because the pie user has privileges to be able to run and execute commands on your respirator pie. Now, let's take a look from windows. If we're on a Windows machine and we're trying to connect via Ssh door raspberry pi, how do we accomplish this? Well, what we can do is weaken done. Lowered a client called Party on its freely available if you open up a browser and you Google party. Okay, the first link here from party dot or you can download this party. Ssh. Client on day. It is very easy and straightforward to set up. So I'm gonna click on here on day. I'm going to click on the installer file, and I'm running a 64 bit version of windows if you're running a 32 but you can click on the 32 bit correspondingly. So once this is downloaded, we can double click be installer file and we'll be able to install party here. The installer comes up, we're just gonna hit next. You can leave that path as the fault If you want to add a short that you're dust up. You can go ahead and select that and click on install so you would get a prompt to allow the insulation on and and you're done. So that's it. It's fairly straightforward. And and now we can proceed to fire a party. And here we need to enter the i p address of our respirator pie. So I'm gonna enter 10 that 0.0 dot 16 which is my i p address. You enter yours accordingly. Ah, it make sure that as as each is checked on Port 22 click on open. Um, of course, it will give you ah, security alert for the very first time for you to accept the fingerprint to get Go ahead and click on. Yes, Morgan, as you want to put in pi as your user. And of course, your password is gonna be the password that you would have set. So I'm gonna take that in here. Know this as you're typing in the password, he actually don't see the prompts moving. And that's just how the party client is. But when you don't entering the password hit, enter and voila! Now we're connected to a respirator, Polly, So I can execute my commands here. I can do a pwd. Ah, I can do an ls on dykan. See the files that are on there and so on. So from windows able to remotely access my raspberry pi via ssh! Now a modicum online and I can execute instructions on my raspberry pi. 13. VNC (Virtual Network Computing): another way that we can connect remotely toe our raspberry pi as fire v NC or virtual network computing. Essentially, we're going to use a V NC client to connect to a pie and where we will be able to see the screen of our Asprey pie. In fact, it does stop and be able to interact with that fire a visual, gooey graphical user interface. So of course, the first prerequisite is to ensure that we have allowed the DNC connection toe happen. So remember, if we go to our preferences and to the respirator by configuration under the interfaces, we need to click enable on V NC on Did that will enable the V N C civil that comes installed on our raspberry pi. And this needs to be unable before we're able to connect remotely via B and C. So just ensure that that's checked Onda. Now we can proceed to set up our VI nce client. So the client we're going to use is vi nce viewer from real V NC. So if you open a browser on did just google FIANC? Viewer Okay, Onda, you'll see this link coming up for Rio v Insee, Andi This is the page where you can download deviancy viewer on. Of course, this is a client that allows you to connect toe Avi NC server. So, as you can see, there is an option for any type of operating system. Were there running a Mac windows? Linux looks even on Android, and so on IOS, you can get a corresponding the NC client from Real DNC. Andi. It works pretty well. In fact, this of uses for quite a while and it seamless and easy and have had no issues. So go ahead and click on download VI nce viewer. I already have it installed and run through the appropriate installation process for Windows. It's a couple of clicks and, of course, the Mac. You just drag and drop it to your applications folder, and you should have your VI nce viewer installed. Okay, so once it's downloaded and installed, let's go ahead and fire or vi nce viewer Onda wish our first going to create a new connection. So if you click on file new connection, you'd want to enter the I p address of your raspberry pi. So in my case, 10 001 of six you could give it a friendly name. Let's just see here Raspberry pi so you'll know You know what you're connecting to instead oven I p address. In case you have many different machines that you're connecting to, you can leave all the other settings. Aziz, the default click on OK, and you should see the machine here. Just go ahead and double click on the machine and you will have to provide credentials. So for the user name, we are going to enter pie. The password is going to be the password that you set you can click on remember password so that you don't have to type it in every time. However, if you're using a machine that perhaps others may be using, you may not want to remember the password and me want to enter it every time. But I'm just gonna click on remember, password. Click on. OK, Andi, There you go. So now we are actually connected to a respirator pie by the DNC client. I can see the raspberry pi screen. I can click on the user interface and it's as if I am physically president on my raspberry pi. But this allows me the flexibility they use any laptop or any PC and connect remotely to my pie to get a more full screen viewing. If you have over the top here, you'll see these icons so I can click on the full screen and also they re size. And as you can see now, it's sticking up my entire screen. So very good use experience. I can, you know, fire up the terminal like an work on software on my recipe and distribution here on day. It is as if I had collected a monitor tomorrow spray pine and I am looking at the monitor, but now I'm able to control it, fire my PC or laptop, keep forward and see the monitor on my screen. So pretty cool, very handy, and I use this quite a lot. 14. SFTP (Secure (SSH) File Transfer Protocol): another way to remotely connect to our esprit pies via S FTP or secure file transfer protocol on FTP. As its name implies, it's just a protocol that allows you to transfer files between one computer and another computer in this case, your PC or laptop, where your FTP client is installed to the respirator party. So in order to do that, we need to install an FTP client. Onda Falls, Ill. A. Is a very, very popular free FTP client that we're going to download to get the job done. If you Google found someone, you would get to the files alone being Jean open. This link in the resource is for the lecture, but you can get to the foul Zillow home page and you can click on download the files of a client. So again, there is a version of the client for all different platforms. When those Lennox Mac s Oh, just go ahead, click and download the files of a client on Once that's installed, we will be able tow connect to our raspberry pi. Okay, so once fossil a husband and stole, we're gonna go ahead and open it up and what we need to do. First of all is quick on file and we're going to go to site manager here from here. We're gonna create a establish a connection to a new site And let's name this raspberry pi kink on the for the host we can enter the I p address of ah raspberry pi so you can enter your value here accordingly. Onda for the protocol we going to do s ftp for the protocol You count Yuk unjust set that normal for the user type in pie And of course the password is the password that you would have set for the account You can just leave that blank Go ahead and click on connect At first you would get the prompt quick on Always trust this host on added to the Kachin Click on OK Onda As you can see here we have now connected to our whom pie ful there on our respirator pines So that's pretty cool Eso you can drill into here and here you're seeing This is the whom pied the documents folder again You can go to the downloads folder Ah, As you can see, there's no files on there but the cool thing about FTP as you can transfer files from one system to the next. So here I am on my mark, and here is just a icon file. So if I double click on this file, I'm actually going to copy it. I just remotely copy that to the Downloads folder on my respirator pie on to prove that it's there. Let's go ahead and bring up our V and C viewer so we can see specifically what's going on and on a respirator pie. I'm going to go into the file viewer here, and I'm going to go into downloads and there's a file that we copied from or ftp client. So if I double click on it here, it should open up. All right, so that was a father we copied across and similarly weaken transfer files from the raspberry pi back onto our PC or laptop fouls. Alor so really, really cool. And the powerful feature, um, using an FTP client to remotely connect to our respirator pie 15. SCP (Secure Copy): the mechanism for us to remotely connect toe are Asprey pie to copy and transfer files is the SCP command or secure copy. This is more of a Lennox based command line utility that allows us to copy file securely from one the next machine to another The looks machine. Andi, we're going to demonstrate how we can accomplish this. It's very, very handy and extremely powerful. So no one are esprit pie in our Dominus full, though we just have, ah, one file on their PNG file and what we're gonna do know is copy a file from my Mac to my respirator pie using a cp. So here I have a criminal that's fire it up. And right now, I, um, in my temp folder in my Dominus folder and I have a raspy in dash logo dot ping file. So it's just ah, image of the recipe in local. And I want a copy best to the down moods folder that's on my raspberry pi. So to do that, I type in S C p on the I type in the name of the file that I want a copy across the network to my raspberry pi then I type in the user that I'm copying this on behalf of. So that user hostile already existent respirator by and also that user has toe have write permissions to the full there, that's on the raspberry pi that we want to copy the files to. So I'm gonna put pie at and then the i p address of my respirator pine on. After that, I am now going to put in the full their location. So after the i p address, I put a colon onda. Then I'm gonna put in the location so it's gonna be any home pi folder and then Donald's okay, So that essentially let me just make this a wider that essentially, is the command again. SCP the file that I want a copy securely the user at the I P address off the respirator by and then colon be fooled their toe wear when a copy that file to so a top on enter and I should get prompted for a password Here I can enter in the password that I have from my pie user. I miss type that hear how entered again. Okay, there we go. So as you can see the fire was copy that says it's 100% done. And now let's go back over to our raspberry pi and check out to see if the file is there. And lo and behold, there it is in the elements full there. Let's go ahead and click on it and there is the rascal and local. So as you can see, I was ableto across the network, used SCP on my Mac and copy that file from my operating system on my Mac, across the network to my respirator pie. So this is very, very powerful. And similarly, you can copy a file back from the raspberry pi to my math, provided that permissions are set up correctly and again. This is a very powerful feature for connecting remotely to your raspberry pi. 16. RDP (Remote Desktop Protocol connection - Windows): the last week that I want to show how we can connect remotely to raspberry pi is using remote desktop connection. So that's from Windows. We will be able to use Windows to actually connect to Lennox. So if you think about it on any Windows operating system, there is a remote desktop connection. Client that's available on will be using that to connect to our raspy and distribution on a respirator pie. So let's go ahead and open up Remote desktop connection. So here I am, running Windows 10. So I'm gonna fire that up up and here for the connection itself. The first thing you'll be prompted to do is enter the computer name that you want to connect to so you can use the host name if you have it. But let's just use the I P address. That was a sign toe a respirator pine. So I'm gonna type in here. My 10 00106 Onda. Once that's set up for RTP, I cook on Connect on. Of course. Remember that your windows machine again has to be on the seam network as your respirator Pires connected to for this to work so Once you click, connect there, Click on Yes, for that prompt that you got in there, and now you'll be presented with the prompt for a user name and password to connect. So for the user name, of course, it's pie, and the passport is the password that you had set up. So go ahead and enter that and click on OK, and they have it from remote Best up your no able to see your raspberry pi screen, So here I could interact with my pie. And again, it's as if I were, you know, working on a monitor that's directly attached to my pie. I'm seeing the user interface for my raspberry pi, and I can remotely work on it from a Windows computer. So again very handy. Useful utility and the remote desktop connection tool is free. So nothing you have to pay their to install. And this is very convenient. And this is yet another way for us to connect remotely Tar raspberry pi toe. Allow us to be more productive 17. Introduction to the Terminal: when it comes took working with Lennox and raspberry pi in general, nor the tool is important or is as indispensable as the terminal. It is one of the most powerful features of a Linux based operating system and allows us to control every single aspect of our raspberry pi. For newbies or those that are unfamiliar with Lennox, the terminal can seem daunting at first. But once you give it a chance and learn a few basic commands, you will really begin to see how extremely productive it can make you on your system. I have compiled a list of commands that I frequently use and that have helped me quite a lot, and now we will cover these in more detail. 18. Understanding User Modes in Linux: Let's go ahead and open up the terminal. So from our recipe in desk up at the top left, you'll see the criminal icon. Just go ahead and click on it, and that should fire part terminal. And before we get into the discussion of commands, there is one concept out like the cover, and that is the notion of user moods. So in Lenox, there basically to user modes that you can work with one is a user mood that has basic access and privileges, and the other is a mood. Would administrator access? Or he could think of it as super user or root access. So by default we are logged into the raspberry pi as the pie user. So if you notice in our terminal, we will see the user pie at raspberry pi, and that tells us that now we would be executing commands as Thebe Pie user. They're sitting commands that we may run that require advanced privileges. As an example, we can get to the rest reply configuration by typing in raspy bash config. But if you notice here, if I try to run that command, it tells me that this must be run as a root user, meaning you need advanced privileges to run this. Ah, the pie user by itself doesn't have that particular access that's needed to run that command. So in order to execute that command, I need to type in pseudo before I run the common and you're frequently see this, whereas we're running through some of the examples. But pseudo tells Lennox that I would like to run this command as a super user as a user with advanced privileges. So if I type in pseudo her raspy config and hit enter, then it actually allows me to run that command. Andi. Now I see the configuration interface, but essentially, to open it up, I had to type in pseudo before the command to run it as a super user. Another thing that you can do is if you don't want to type and pseudo every time you can type pseudo s, you and this essentially switches you to divert user on how you know that you and the routines Air motors. If you check at the prompt, you're going to see route here as the user that executing commands as Onda after a spray pie on this really indicates that at this point in time, anything that your run would be runners, the root user with advanced privileges. So from here, I can just type in the raspy config command, as we saw earlier on it will be able to execute that command without me having to type pseudo in here. So that's another way that you could have run commands with super user or advance privileges. You have to be careful about this, though, because the pseudo there is in place for us so that we don't meet mistakes, and you could think of it as intentionally. You want to type in pseudo before a command if you're trying to do something that could affect your operating system. So it's best to leave the user running as the pie user and the type and pseudo before the commands that you want to execute in advance privileges. Mood just as a safety mechanism so that you are indicating you you're going to intentionally Rana command with advance access that's needed. So that's just a little tip. But on a tip about users on the next operating system, 19. Useful General Terminal Commands for the Raspberry Pi: Now we're going to address some general commands, and the's are commands. That's just help us to be more productive, and we can use thes very frequently rt terminal on the perform a variety of functions. So without further ado, let's get started. So the 1st 1 is clear. C l E E r. And essentially, this just clears our screen. So if we had a screen with a lot of command to previously typed, and we just want to blow everything away and start over clear would reset all of that clearly screen and bring the cursor back up to the top. Next is date. Okay, so data's pretty handy type in data, and you get the date being displayed to you so quick and convenient Way to find the date. The next command. We want addresses. Find Hardaway Locate a file there many different ways to do this and Lennox grew up is potentially the most robust way, but it is very detailed, and you have to put a lot of options. But an easy way to locate a file is using Find on Do you want to put in? Next argument would be where you are starting from on the file system to look for a file, Then you're gonna in Dash name and then type in the name of the file. So I am just going to do here Raspy Asterix. So basically, quote, I'm telling the system here is find starting from the root folder, a file that starts with raspy and anything can come after. And the dash name argument says, Look for a foul with a name that has raspy and star Andi It's going to do that for me. So I'm gonna hit Enter here. And as you can see, it went through my entire file system on it returned to me, though the name raspy preceding the name of of any file that was on my system. So if I'm looking for something that's extremely specific and I know the exact name of the file, I can just put find and that animal file on, it would return that file for me. So very, very handy feature there. Next, let's look at quickly how we can create a file on Edit it in gooey editor that is offered by the terminal, and that's called Nano. So let's say we want to create a file on gonna do Nano The name of our file. Let's see its test that text on it's going to open up this gooey editor for us on then. Here, you can type in the text of your file when I type something in here. Okay. On once I'm done editing noticed there some shortcut keys that are displayed below here that would allow you to save on exit and so on. So I'm going to hit here control X as going toe. Ask me, do I want to save these changes so I can just hit the y key? Okay, Onda file named to write, test our text. I just hit Enter, and it's gonna see if that file for me to view that file I'm gonna type in ls Okay. And as you can see, we're going to talk about l s a little bit later. But that final that Rick waited tests that text, you'll see it show up here on it will see if to our file system. So that is how we're able to quickly create a file with a gooey inter fees that's provided by the terminal and score manana. If I want to edit that file again. I just do Nano and the name of the file on. As you can see, it comes back up so I can change it modified and then save my changes. Appropriately. The next command is the raw speak and Fichman Andi. This allows us to at it configuration settings for our respirator pie. In order to run it, though, we need super user privileges. So it's suitable raspy dash config that we have to type in, and this allows us to change a lot of of settings on a respirator pie. If you remember from earlier videos, we were able to do this from the raspberry pi that stop itself and let me quickly show you when you click on the respiratory icon, go down to preferences and respirator pie configuration. This brings up more of a graphical interface to edit. Some of these seem settings on the raspy convict a man and it's ah, more user friendly. But essentially it does the same thing. However, in the raspy config application, there are some additional settings that you've been tweak so so in here we could do things like if you want to change the password. Okay for the user, it's asking me to enter the new password. So I am going to do that now. Okay. All right. On it tells me that he possible to successfully change and I hit. Enter on, but that's awakened. Changed the password on my system. Next, you can change some options. Like host name, for instance, ing name off. My raspberry pi is just respite by and that's what set up was default. But we can change this and tweak this if we need to. Only want expose a different host name on our network for the respirator party. I am just gonna leave this as is for now. And then there are some other options on here, Like the localization options which we already covered. Advanced options. We're gonna go in here. As you can see, you can expand the file system you can set if the audio comes through the h d m i. Or if it comes through the headphone jack and so on. Those are some settings and configurations you can tweak and so on. So very handy. The rest speak and fig application just by typing in pseudo raspy config were able to get to that application. Another useful command that we can do is to restart a reboot are esprit pine. So if we just type in reboot and hit enter, I'm not going to do it actually is just gonna really recycle our respirator pie and start everything over. If we want to shut down our Asprey pie, he type and shut down K. And you can put in a parameter dash each now and hit Enter. And that's gonna shut our pie down completely right now. So I'm not gonna do that. But that's what that command does. There's also some flexibility would be shut down. Commanders You can specify when you want depart to shut down. So let's say I want it to shut down at 1 30 in the morning. 1:30 a.m. I can just type in shutdown space dash each 01 cool and 30 onda hit. Enter on that 1:30 a.m. That's going I'm gonna hit Enter here. It's going to schedule that so at 1 30 my pie will shut down automatically on its own. So those are some basic general commands that are very handy on Hopefully they would make you a little bit more productive on your pie on, but those are some commands that are get to know. 20. File and Directory Commands: So now we're going to look at file and directory commands. Thes are useful commands to allow us to manipulate files and navigate the directory structure on our Lennox operating system. So they're very handy. Onda help us to be very productive and just working with files in general. So the first command is pwd all right. And PWD stands for print working directory, and it just shows us where we are specifically the path to where we're currently located in the directory structures. As you can see when you first open up a terminal at slash home slash pi and typically that's the default. That's the pie folder where you have all the files that are associated with the pi user. So PWD returns that path for me just to show you, I'm gonna open up here from Found Manager And here is the root directory that c slash where we start everything from and we are in whom someone a double click there and pie. And as you can see, these are the files that are in my slash home slash pi directory. So let's go back here to the terminal on in order to beauty files that are in my current directory can just type on LS enter. And as you can see, it shows me that stop Donald and someone. These are the seam files or directories that are in my current home pie directory. I can also type in an LS Species dash health, and this gives me more additional information about those directories and files so I can see the read write permissions on that particular directory. Who owns the owner and the group that that belongs to, and so on. Andi. Some more information about when it was last modified and soon, So ls species bash. L allows me to see vertical list on the more details about the particular directories and subdirectories and files that are in that current directory. Now let's talk about navigating the directory tree. So if I want to, let's say go into my Donald's folder. I can type in CD space downloads Onda CD Stands for Change Directory on that allows me, as you can see now, I am in my Donald's folder so I can type in analysis, and these are the four files that are in my Donald's folder and again we can verify that just gonna double clicking here. And these are the files that I have in their current me. So seedy allows us to do that, to navigate back up the tree. I can do a CD space doctor, and that takes me back up one level. So as you can see, if I go back now, I'm in my home pie directory. Back up one level where I was before. Andi, as you can see here, typing in a pita beauty back up to my home directory. So that's a CD doctor Common to get to my pie home directory. I can quickly, from anywhere type in CD space till they and that would land me back to my whom pie directory. So let's say from since I was in downloads Onda in the air, it is Attempt directory. I was in my temp directory, and as you can see, you know, I'm in whom pie downloads temp. If I type in CDs, peace till they on the till they key is the key. That's to the left of the number one key on a keyboard typically brush shift and that key you get heartily, and now that should land me back to my slash june slash pi folder. So I'm gonna go back into my downloads folder. Andi. Now, let's create a new directory. So the create new directory, I do em que de ir make directory. That's what that command is short for. On. I'm going to call that directory. Lee underscore test. Okay. Uh, if I do it ls here you can see that my lead test directory was created. Andi, let's say I want to know. Move a file that test a text file that's on near into my Lee underscore test directory. I can do a M V for Move on by type in the name of the father that I want to move first and then I type in the directory that I want to move it into. So here I am, moving the test file into that directory, and if I type enter, I'm going to do an ls again. As you can see, that test our text file is not there anymore. On it should have been copied into Lee underscore test. So if I go to a change directory into Leon, the score test on die doing ls a Z can see my test our text files in there. So that's how we were able to quickly move. You could think of move as a copy paste and then a delete, so it's gonna just physically move the file from one location to another. Next, let's show how we create a file. So I just moved the file until the test to quickly create a file weaken, do the touch command. It's like a type in touch and then the name of the file so that C temp docked text and that would quickly create a blank, empty file for me. And that's doing ls. And as you can see, we have that temp, that text file, and we test our text file inside my directory so touches a quick and easy way just to create a file and empty file on our file system. If I want to delete that file in order to delete the file, I do RM for remove. So I'm gonna put remove and then let's do temp dot text, okay, and that should delete the file. And if I do an LS dashi Oh, um, as you can see, the test file is the only file No, that's in my subdirectory and temp husband removed or deleted game. So RM is used to remove files while I'm in here. Also going to remove that other test that text files on remove test our text. It's gonna delete it and know if I do an LS. There's nothing in the directory someone and never get back up. Okay, City space. Start that, as you can see him in my Downloads folder now. And if I do, unless I can see here the files that are currently in directions that are in my Donald's folder. What if I want to delete this Lee on the score test directory? So to do that, I can use the R M de IR Remove directory command, and I'm gonna put inlay underscore test Onda. When I do that and now I take a list of what's in there. I can see that Miley test directory is empty. One caveat. Here, though. They removed directory command but only remove or delete on directory if it's empty. If there are files that are within subdirectories that are within a current directory, Rmd IR would not remove it. So as an example of the temple there that I have here has one file in it. So if I would try to remove that if I do ah, remove directory temp. You notice I get Thea the error message of directory not empty. So in order to remove that directory on any subdirectories off files, I need to do a reclusive delete. So to do that, I can do an RM space dash R f. That means those arguments are Teoh remove reclusive Lee and to force this and I'm going to put any temp directory. Okay? And what that will do is even though their files or sub folders with any time directory, they will still be deleted. So now, if I do an ls on I look in here, there is no more temp directory. Okay, So those are be sick file and directory commands to allow you to navigate the directory structure to copy files to delete files to create files and so on. Hopefully you'll find them handy. And these are the command lying instructions pertaining the files and directories that I use the most on. Typically, you probably might as well, and I hope you find those tips to be helpful and useful 21. Networking Commands: Now we're going to talk about some networking commands, just a few networking commands that I use quite a lot on. Hopefully you find them useful and they're good tips, too. Give you information about the network that you're connected to and perform network related functions. So the 1st 1 is I f config. And as you can see here it returns. Tow us information about our network and friends. And since we are connected via WiFi or this I am if you know you're connected via Ethernet cable, you will see the information about the I P address that you're assigned. So, as you can see here it's 10.0 dot 0.1 of six is my i p address. And again, if I hover over my connection here, I can see that 10 001 of six. Andi, it gives you some additional information about packets and salon. Just details about your wireless connection or your Internet connection. If you're connected via the Internet. Ah, hardware. So as you can see here, my e t h zero, there aren't any packets, so errors or bites that were transferred. So that means I'm not using my Ethernet port currently on the network. But if you were, you'd see some details. There are about the i p address your assigned them. So So I have config very handy command line utility to get information about your network. Another variant of this is I w config. So I w config will specifically return information about the wireless network that you're connected to. So here, as you can see, the S s i d of the network that I'm connected to is called the gin makers. That gives you some information about the frequency and so on. Onda the signal strength. Andi, what the access point is and so on. So that gives you the i w config gives you more details about your wireless putting into the wireless network. Another Hunde utility is Ping. So for those folks were familiar with networking, Ping allows us to check to see if a computer is up and running on our network. So typically you can type in ping and the I P address you wanna check for. So in my case, I'm just gonna do ah ping on a particular I p address. This is actually a network attached storage on my network. So as you can see, I'm getting a response coming back from my thing. So I knew it's up and running. It's a very quick and easy we to see if another device is up and running on the network and I just compress control. See here, and that allows me to stop that process. If I know the host name off, a particular device on my network can also do a ping on and that whose name? King Andi In the case of my respirator, pied in the host name is Raspberry Pi. I didn't change it. That's typically did the fault. So it's actually checking on my network, doing a DNS, resolving it on and showing, Of course, that's 1 27 011 is home. That's a look back address. So it's actually just seeing that it can communicate with my pie, which is what I'm running. But if there is any other host names on your network, you can do a ping, and that will check to see the availability of that particular device is up and running so very handy utility for checking the availability of devices on your network. The last command that I want to demonstrate is Thebes. W get command on its ah, commanded I use frequently all the time. I thought it would be a good tip trick for you to familiarize yourself with on. Essentially, it just allows us to download a file from the Internet Friday command night. Sometimes when you're installing packages and other stuff from the command line so easy we have pulling something down from the terminal. So let's go ahead. I'm going to open up here my file manager and going to down moods. And as you can see, I have a couple of images here in my downloads folder. But let's get another image to download from the Internet. So going to open up a burrows, they're here, the chromium broza on Raskin and going to go to images that google dot com. And let's sit here for raspberry pi. That's an example. Onda Ah, let's see this first imaged here of the hand, the holding respirator prime. When a click on that, let's say we want to download that image. If I view the image, it should show me. This is how I can get to the image where it's stored from the actually this family raspy pride out or website. So I'm going to copy this URL and let's go back to the terminal. And to get that file I'm going to type in as you see where any downloads folder, if I do ls those every two fouls that are in there. But if I do a w get and I pieced in that girl King, that is for that image of a person holding the respirator pie on top. On Enter. As you can see, it went out to the Internet. It downloaded that image, and now that image, which is called Home Dash it's a long name should be in my documents folder. So if I do an LS there, I see it. So that was downloaded. Onda. If I go back to my file system, here it is. So here's the image. Let me double click on it on. There it is. So that's how I was able to retrieve that file from the Internet. Using that you get from a network in perspective, this is a very handy, easy to use command that would allow you to retrieve content from the Internet and download it to your raspberry pi 22. System Commads: Now we're going to get into some system information commands and these air commands that are handy just to show us or tell us what's going on with our operating system and to give us some information. And these are just a few there, quite a lot that's out there. But again, these are just a few that that I use regularly. That would be good tips for you to be a lot more productive and hope you get information quickly and conveniently about your operating system. So the first is understanding memory usage. So if I type in cut space slash Prock slash member info Que Onda here, it gives me a list of. But see, you know, here's my total memory, my memory that's free buffers and so on. Just a quick snapshot of how I'm doing with memory on my raspberry pi level commanders D EFS piece stash each and that shows me ah, high level around disc utilization. So, as you can see, if you remember in my particular scenario, I used a 16 gigabyte SD card on here. As you can see, it's showing that 15 gigs here on my Dev Root folder I've used about 4.2. Gig on I still have about 9.9 gig available. So again the DF species dash each command gives us some high level information about how our disk is being used and is and how much space we have available. Another variant of this is DF species Slush Andi. This gives us a high level off how much space is being used on. As you can see, it's about 30% off my SD card that's being used, so just quickly gives you a snapshot of what the size of your system is and how much is being used. The F Space slash. If you want to get information about packages that are installed on your raspberry pi, you can use the DP Keagy command and here I'm going to type in dash dash, get selections Onda. As you can see here, is a lot of information about packages that are installed on my rest Rape I onda. We will get into the details and specifics of what packages and how those are managed and how you can do it. Software installation and a raspberry pi will address that in another lecture, but for now, if you want to quickly get information on what packages that are installed you used on DP TG command. Now, as you can see, that was quite a list that was returned to me. And it may not be necessarily useful, but what is useful is if I want to search for a specific package. So to do that, I can type in the DP Keagy stash, stash, get selections. And here I'm going to do a pipe grip. Andi, let's see. I want to see python. Okay. Any search for any packages that I have on my system? That protein, the pipe on Onda. If I for us enter here, I can see here are pipe on related packages. So this gives me details about those part time you needed packages. So again, this is ah, handy tool. If you want to check if something is installed and you don't know Oh, you want to know if it's available? Use that DP Keagy. Come on. The last sort of system information command that I found myself using quite a lot is host name Space Dash I that quickly gives me my I P address again. I can get that i p address just by hovering over here, I can see it's a 10 001 or six, but whose name Space Dash I quickly gives me that from the command line. Sometimes that's what I want. I'm running a come on and I want to get it quickly. That's what I use as well as if you remember the I have config that we spoke about earlier but networking a man also, you can get the I P address there. I guess. What this illustrates. There are multiple. Well, he's off doing stuff from the command line on looks. It's just a matter of those particular commands that you feel comfortable with quite a lot of options and a lot off flexibility, and it's very powerful. So those are some of the mean system commands that I wanted to address. 23. Keyboard Shortcuts: last, but not least when we're working with the terminal something that I have to cover shortcuts . We want to be able to quickly navigate around the terminal. And here are some cool tips and tricks for shortcut keys that allow you to be really productive. So back here we were having our last discussion around system commands the up and down arrow. So if I used the up arrow Aiken cycle through all of the commands up and down that I typed in before, So of course, that's good. If I type something out and I'm gonna get back, I don't have to type it over again. So from the terminal, I just hit the up arrow. And as you can see, it keeps a running history of everything that I've done in the particular session, so up and down here and going back up while I was going to cycle through. So that's a very, very handy tip. Another one is much doing. Ls you may have noticed that sometimes I start typing and quickly the rest of the word is is typed out. So as an example here, I'm going to let's say I'm going to delete that home products image. If I type in RM space and I press h I can hit the tab key here. And as you can see it, auto completes for me, it's That's pretty cool, right? So I don't have to type of the entire name. It auto completes the rest of the name for me on now I can hit Enter Onda. I'll be able to delete that image. How it does this is it checks to see what other files inside here? My full there It starts with an H and then in this case, it only hit on one. So that one final shorter. But let me show you this. Let's try to I'm going toe copy Here. That's to a copy. Hatreds. And when a type each hit tub it filled it out from I'm gonna type each again hit top. All right. But now, instead of imaged upping, I'm gonna put image to dark pink King. So if I do ls you'll notice Let's do this so we can probably see it a little clearer. I have two images in there. No, what would happen? You think if I typed in the r. M and H and a hit job. Oh, think about it for a second before we actually executed. And I'll let you take a guess as to what happened. Okay, so let's go ahead and hit job. Now what? Lennox does it mellitus? Is that from the h o M e all the way until image that that is common to both file names. But at this point, it doesn't know if you want to use the two dot ping extension or if it did that ping file you're referring to so as much as possible, it tries to make a guess and find out as to what's in name in this case, everything is he seem up until the two. So it, of course, auto completes that for us and waits here and now I can put in my two. If I hit top again, it's gonna complete it on. I just deleted that file. So now if I do a list, you can see the file is going so that tub is very handy, and it quickly allows you to navigate on auto complete so you don't have to type out entire names. Off files on direct reasons were so another command is controlled, See, or that sort of stops are running process. So let's see him going to Ping another device on my network. Okay, So as you can see, this being is running my devices up. This is continually running, but I want to stop it. Well, how do I do that? So if I press control, see? Okay, that stops the current running process. Andi sort of escapes and and man's move back of the prompt. So if something is ongoing and you want to stop it, press control, see? And that's a quick, handy shortcut that can stop a running process. Another shortcut is bang bang. Really double exclamation. So, double exclamation. Actually, just reruns quickly. Your last command. So the last command were running Was the ping some just having ahead control. See, as you can see, it stopped there. Let's say, typed on ls. And it showed me that if I just put in Bang Bang, OK, it just runs the L s command. So notice it shows you the command that it was it's currently executing. And then it runs it. So again, that could help you to be productive. Okay, so that is just a quick list of shortcuts that I use all the time, and it really helps me to be productive of the terminals of those are some tips and tricks for working with the terminal, and I hope these would help you and that you find them informative. Onda could make you more productive as well. 24. Understanding the APT Ecosystem: when it comes to installing software, especially on Lenox. And in the case of Raspberry pi, which is a debian based distribution. Eventually we have a convenient tool that makes managing software easy. It's called the A P T package system, A P T. Stands for advanced package tool. It is essentially a management system for DP KG packages, as seen with the extension ass trick that d be. It was designed to not only manage packages and updates, but to solve the mean dependency issues when installing certain packages. In the early days of Lennox went trying to compile something from Source, one would always be subject to the situation called dependency hell, where it was difficult to find and manage dependencies that were needed for projects. A P T makes this process super easy for us and monitors everything behind the scenes. We will get to see it in action in a little while when installing software, there is one command we should always run first, that is Sudo Apt cache get update. This updates all our A P T dash get package index files so that our system is up to date. Essentially, if software or package opiates are available running this command gets them for us. Another command you may see is suitable. Apt dash get upgrade. This is used to install updates. When it is run, all packages will be upgraded. It's a good command to run to ensure that your system is up to date. If we are trying to install a specific software or package, we run suitable up get in store and then the package name that we want to install to remove the package. We would use pseudo up. Get remove on the package name. Sometimes when we want to completely remove a package and all of its associated configuration files, essentially performing a clean on install, we can run sudo Apt bash get footage and the name of the package. Some things when we are installing or un insulin packages, we run into an issue where we have broken dependencies. To fix this, we can run suitable up to get dash F in store. Andi, this will fix the broken dependencies for us. Finally, downloading packages results in a lot of space being used up over time, filling up our disk to clean things out and free up space from downloads, we can run Sudo Apt Dash, get clean. This should be run periodically to clean up our system. Know that we have described the A p T equal system in general, let's delve into some practical examples off how it was used time to see some of us in action. 25. Installing Software using APT: to them and shit. The process of installing software using a P T. Let's install the party client for Lennox. If you remember, Party is an ssh client that can be used on Windows computers to connect to Lennox machines . Although in Lenox and raspberry pi, of course, the terminal is very robust and can perform any ssh function. I'm dressed installing the particle and software to illustrate how the A P T package tool can be used for software installations in general. Before we do this, let us update our existing packages. We can run pseudo upped bash, get update, and this may take a while. If this is the first time you're running this command, or maybe you haven't run it in a while. But this will update our package lists and get all the available package of leads for us. I recently ran this command and my system is up to date, so it didn't take very long at all. But depending on you know, the state off your system, it may take a while to get all those updates pulled down and update your repositories. So before we begin the party install just to show that party doesn't exist on our system. If I click the Raspberry Pi icon and I go down to Internet, this is a list of the Internet tools that are available on my system. As you can see in a party, isn't here. We have the browser and so on on deviancy viewer. So now I'm going to run the command to install body. So it is Sudo apt get install. And this is typically these intellectual use when we want to install any type of packages using a PT on what would follow is the name of the package you want to install. So I'm just gonna type in a party here, and this is going to go out and retrieve all those dependencies for us and begin the install. The install has been completed. It ran fairly quickly on No, let's go check to see if, but it was installed. So if you again, if you click on the raspberry Pi icon and you go down to Internet, what we should see here is the party ssh client. So it now shows up we have in store. Let's using a PT. I'm going to go ahead and click on it, Andi, When it opens up, this is the particle. And so from the previous videos I had some instructions and how you could connect by a sausage to any I p address or any lyrics based machine on your network on can use body on the next CNN respirator cry, and it works. Okay, so now that we have installed party on, we have been stole the software using a PT how do we delete software? So in order to do that, I can type in sudo apt dash, get remove. And I went, Of course, here is where you would put in the name of the package that you want to remove. Some just gonna put in party here. And this ah is going to run. It asks for a confirmation of Do you want to continue to actually remove the party application? So I'm gonna just type and why it enter on that This is gonna run Onda uninstall essentially the party application. So that has been completed on Let's check it out. Let's see if it has been removed from our menu. So again, I'm gonna click on the raspberry pi icon, go to Internet on As you can see it, it doesn't show up anymore. So it was actually removed, so we can't access it. It's gone. Typically, there's another command that we can run, which would actually clean up and remove some of the dependencies and so on. That may have lingered in our system, so that command is the courage command. So I'm gonna go ahead and run that now, see, type in subtle, apt cache. Get on, then I'm gonna put in purge party, okay? And this is going to go out again. It asks for a confirmation. As you can see, it shows a list of packages that were installed on that are no longer required again over time. If you keep installing and uninstalling stuff, eventually you're gonna have a lot of packages that you may not be using. And, of course, the sticks up species on our our system. So I'm just gonna type and why here it. Enter Andi. Once that's done, it should be all cleared up. The other command that I want to talk about as related to fixing broken dependencies and weaken type in Sudo Apt Artal removed and this actually goes out and does seem dependencies that are no longer required that are lingering around on the system. But as you can see there, some dependencies from other software that have been stalled that I haven't gotten rid of. So you just get the confirmation after you did the suitable apt to remove. And it's happened, Why here? And it's gonna go out and clean up my system and actually free up some disk space there. So there we see a progress bar that's running through. It's running through fairly quickly. Of course, the time that it takes will depend on how much of those unused packages that are being cleaned up. So it's almost completed here on I'm done cane. So finally, there's another command that you can also run that cleans up on new space and Sudo Apt Dash get clean again. That will clean up any unused space and keep our our system in a good state on. It's something that we want toe probably run periodically just to make sure that anything that's not being used has been taken off our system and we have the marks available space. So this concludes our lesson on installing software. We will be using some of these commands quite a lot in this course to install software later on. So hopefully you can see the power of the A P T system and how it makes installing, uninstalling and managing dependencies. Four Software on the raspberry pi a breeze. 26. Creating a One Line Web Server with SimpleHTTPServer: Now we're going to take a look at How do we install a Web server on a respirator pie? A Web server is a pretty handy application that allows us to serve up webpages. And we can in fact, set up our Web server on expose our esprit pie to the Internet and half its soup up in our own personal website or don't mean so. That's pretty cool. Onda. Let's delve into how we can and starts a Web server on our respirator pipe. So first we'll be looking at a quick Web server, which actually can be up and running in just one line, executed at the terminal on It's actually the simple http server, and it's executed using python. Before we do that, let's make a folder for our Web server. And again, this can be anywhere on our file system. So I'm going to open up. Let's open up a file manager here. Ondimba here, we're going to go to the that City Downloads folder and let's make a new folder in here called Web Server. So we're going to create any folder and they're going to call it Web Server on inside this folder. This is will be sort of the whom part or the root of our Web server. And the cool thing about simple http server is it can have your home there, actually virtually anywhere on your system. Once you navigate to these specific spot that you want to start up that Web server from so in here, let's go to our terminal on we can navigate. We're gonna do a CD till day and again that's going to get us, of course, to our slash home slash pry directory. And then we can go Entry downloads directory. And here, as you can see, that Web server directory crude created. So I'm going to go into that Web server directory and let's create on index dot html file. And this is sort of just the mean file that's gonna show up by default when we load our Web server URL in the browser. So I'm just gonna do we now know in next dot each demo and in here I'm just gonna put this is our really cool web page, right? Something very simple. You can put any text that you want in here. I'm gonna head control X to exit. I'm going to type and why? To save on. Enter Onda If you look here now in our Web server full that we'll have that in next out each team on file. So to get our observer running, we simply first navigate to the directory that we want to be our root directory or where we want our files access from and we're going to run this command by phone dash M and simple each TTP server Notice Thea upper case here, you have to make sure that a case matches because Lennox is, of course, key sensitive. So go ahead. And once you into that command, you can hit enter on what it does is actually fires up a Web server an http server on Port 8000 using this whom pie down moods Web server directory as the root directory. So now I'm going to open up a browser And once my chromium broza fires up here, I can do local host and just put in 8000 and if I hit enter, our beach comes up. So that's really cool. You can navigate to anywhere on your file system. Onda execute the command to start up the simple http Server on Do you have a Web server? You can also access this anywhere on your network by using your i p address. So again here my I p addresses 10th 001 17. So if I do 10 001 17 and remember, I have to put my port as 1000. It brings up the Web page. So any device that's connected to your network can fire up on access your Web content on Port 8000 from your simple http Surfer. Very cool Onda. Very quick way to get your Web civil up and running. One thing I also like to mention is if you look at the terminal as your simply http servers running, you'll notice that when requests are mean, you'll see the logs being spit out here on the terminal screen. So notice if I refresh my page here, you'll actually see that get request. Onda would be 200 status code being returned that showing up because currently in this session or in this particular terminal tab, the silver is running if I want to stop it. I just took control C and that stops my silver from running and now, if I tried toe, refresh this page as you'll see, these site would be down. So there you have it. That's how you can quickly start up your simple http server on stop it. 27. Installing the Apache Web Server: Now we're going to look at installing a more robust Web server. In fact, the Apache Web server that we're going to install powers most of the Web applications that are on the Internet today. So first, let's open up a terminal and we're going to run the following command for the installation . Sudo Apt Dash, get install a patchy to space dash Y, and I will put a list of these commands in the resource is for the lecturer. But go ahead and take this command in. And if we hit, enter. Now. If the installation process is in progress to install the Apache Web server on, of course, it's going out to pull down all the dependencies and libraries and so on. The E P T package installation system is doing this for us. So let's give it a few seconds on Duh. Then we will check out Ah, Apache Web civil. Okay, so now the installation is complete. Let's go ahead and fire up our browser on try to hit our Web server. So I'm gonna open ah chromium top here and I'm just going to enter in here. Local host essentially just local host Onda. What would come up is the actual Apache to de beautiful peed show. As you see here, this means that our Apache server is up and running. So we're good to go. So there are a few things that I'd like to cover pertaining to the Apache, a Web server. Let's go ahead and open up our file manager, Andi The root folder that Apache uses to save up the Web content is thieve var www html folder. So to get there, if we go to our file system and we go too far www each demo This is where the content is loaded up by the fault. So just gonna bear that in mind And of course, we can get to their we can navigate from our file system When a CD slash far, Let me w w html On in here we see that index dot html file. So that's the home folder where the files are saved up from another point about this folder is bite fold. It is owned by the root user. So in order to write to this full there, you need right As the root user, you can change the permissions for the pie user to write to this folder, but that's just a site. Move to bear in mind that divide up the HTML by the Folds is owned by the root user and belongs to the root group. Also in orderto access your Web server. Instead of using local host, you can put in your I P address. So again, the I'd be address that I was assigned was 10 001 17. So from any device that's connected to your network, you can enter your 10 001 17 on do you will get that Apache for Peach. Let's go ahead and create eat, actually in new page on Let's try to serve it up from a viral double of the HTML folder. So I'm going to switch back to the terminal and we'll use the leaf bod to create our HTML Pete someone ago sudo least bad. And I'm going to let's call the file Hello, that each demo okay. And this opens up leaf part for us, and I'm just going to type in. This is our custom html file. Okay, we are displaying this content on our Apache server tank and we could put in HTM Elaine breaking there were just gonna save this file and concludes it off on. Of course, if you do an ls here, you should see your hello dot each emo and we can bring that up in a browser. So at the end of our 10 001 17 it's actually bringing up the indexed on each timo page by default. But I was gonna put a slash onda we're going to put in our hello that html on and there it is. So there's a custom page or new page that we created were serving it up on Apache Server. And also, you can access this from your local host, and if you do the hello that each Gemmill, he seemed beach will come up. But of course, if you're trying to get to this from any other device that's connected to your network, just use the I p address of your respirator Pie on put in the PG one to access on your content will be served up from the Apache Super 28. Installing the PHP Application Server: no let Apache is installed, we're gonna proceed to install a PHP application. Several PHP is a very popular Web scripting language. On, Of course, a lot of websites out on the Internet are written in PHP. It's very robust, and you can write extremely complex Web applications using PHP. It's fairly common. So let's go ahead and install PH. B and get that working with our Apache Web server. So I'm gonna go back here to the terminal, and we're going to execute the following command to install PHP again. The list of these commands will be given as resource is for the lecture, So feel free to follow along or you can directly copy in peace. Take commands from there to make things simpler to execute them. So now, in store PHP, it is pseudo apt Bash, get install PHP on. We put a space there. Lib Apache two Nash marred dash PHP space dash Y Okay. What this command is going to do is again we're using the A P T packaging system. It's going to go ahead and get the latest illusion off PHP that is compatible with Apache. Two for Mitt, version of respirator by that we have on. It's going to pull down all the relevant dependencies and libraries and install PHP for us . So just gonna hit Enter here, Onda. The process is going to run for a bit. Getting the packages that we need on it is installing PHP. As you can see here, the disillusion of PHP for the particular distribution is PHP seven. It may be different depending on the version of recipe in that you're running. If you're watching this video at a leisure time, it may be a little version of PHP, but for the current vision that I have PHP seven, his deep elitist is sure that I am pulling down. So let's give this a few seconds to run on, and we'll pause the video on resume when the installation has been completed. Okay, Sinaloa PHP in store, husband completed. Let's go ahead and restart Apache for the changes to take effect. So to restart Apache retyping pseudo of patchy CTL restart and that would have restarted Apache for us. We get a little message here, but three time being can feel free to ignore that. But that should have successfully restarted a patching. Andi, now to actually test out our PHP applications. It Well, let's create a PHP file. Let's make sure Here we are devoured. Dub, Dub, Dub. Each Gemma fooled. If you're not there, you can navigate to there. And now we're going to do a suitable leaf pad and we're going to create a file call in for dark peach peace again. This command is going to open up the leaf part editor and the creator in Fort PHP file for us. So I'm just gonna open that up here on day. We are going to type in the less than sign Andi the question mark PHP Andi in PHP scripting . That's how you indicate a scripting block where because that follows is to be interpreted as speech be, and we're gonna call the PHP in full function. OK, but a space the question mark and close bracket on Essentially what this is doing is this is getting the information about our PHP application. Serve on this is gonna display it for us so we could see this Getting control s on. We can close this off if you notice here. You'll see the info dot PHP Andi, I'm going to bring that up in a browser. So again, this is the I. P. Address of our server. 10 001 17. You can plug in the i p. Address for yours on gonna put in that in food art PHP page Onda. Here you have it. So if your PHP was installed successfully, you should get a page that summer to this. It would tell you what the illusion off PHP you have running is on. This tells a lot about the different attributes of the peach. Be install information about which particular packages libraries air installed and so on. So very vory easy to set PHP up. Get your PHP applications over up and running. Andi, once the info dot PHP Pete is showing up. You should be good to go. You have a robust Apache Web server running in conjunction with a PHP application server on your raspberry pi. Hope you enjoyed this tip on trick 29. Introduction to GPIO pins: Now we're going to dive into more detail on one of the features that makes raspberry pi very interesting, on which in fact, allows it to interact with the physical world that is a topic of GP I opens GP Iot, or general purpose input. Output pins can be used as a mechanism for the pie to interact with the real brewed in amazing ways. In one mode of operation, the's pins can be used as inputs to take readings and can be connected to switches, sensors or other devices or computers. The GP I opens can be used as opens to turn on and led, for example, or send control signals to motors, servos or any other device. The ability of a raspberry pi to connect to a network means that any devices that are attached to it can be controlled from anywhere on. Those devices can send data back to the pie. Connectivity and control of physical devices over the Internet is a powerful and exciting opportunity on the raspberry pi is ideal for this. This connective ity off things and devices is often referred to as the Internet of things on the raspberry pi platform is excellent for prototyping Internet of things projects. Now let's take a closer look at the GP. I open Leo. Here we will examine the load for the raspberry party. Three. There are 40 pins altogether, been one on the raspberry Pi board is referenced Bipin one under diagram. Then we have been to been three four and so on. Why you see two different numbers listed is because when you are interacting with GP, I opens programmatically in code. As is the case with Python, you can use the pin numbers, which is referred to US board mood. Or you can use the Broadcom GP Io numbers, which is BCM mood. We will see this in action later on when we dive into some court with our circuit examples . GP IO typically operates at 3.3 volts for all inputs and outputs. At the top of the connector, however, there are 3.3 bold and five bolt power supplies. 13.3 volts pin on the left and to fivefold D C. Po opens to the right. In addition to the 13.3 bold pin at the top, there's also another 3.3 bulls pin lower down as you notice. There are also several ground pins. These are shown in black on the pin, Leo to Bagram. Anything that has a number next to it can act as a GP. I open those, however, that have another name after them. Also suit another special purpose. These pins can be controlled a programmatically using a programming language such as Python to take readings and measurements or send outputs to connected para froze. We will actually see this in action a little later on, for example, physical pins three and five or G. P. I. Your two and three also served the dual purpose of serial data on serial clock lines for the ice Quidsi Inter fees. Also physical pins 1921 on 23 or GPS, you 10 g P a. Or nine and G P A. Or 11 are the most sea or master out Sliven Missile master enslave out on the serial clock . Mine's for the S B. I in Davies, although GP I opens can be used as digital inputs or outputs. One thing to note is that unlike Arduino, the raspberry pi does not have any analog pens in order to process. Analog readings on external analog to digital converter must be used. Now let me give you some tips for reducing the risk of damage to your esprit pie, especially when working with GP I opens. It should be noted that, unlike our Denham, the raspberry pi does not have a lot of built in fuse. Protection on is very fragile when it comes to working with external electron ICS. A good rule of thumb is to make sure your pie is powered off on not plugged in. When wiring up circuits on double, check your wiring before you boot up. Also, do not put more than 3.3 bulls on any GP. I hope in this could potentially damage the pens on. Shorten the lifespan of your frost berry pie. It's also good practice. Do not draw more than three million amps of current per output. More current can be drawn, but again, this could shorten the lifespan of your raspberry pi. A very important point is to not poke at the GPO connector and with a screwdriver or metal object when the pie is powered on. Believe me, I have done this myself by mistake and yes, it actually ruined the Bluetooth on Dwight Fi capabilities on my raspberry pi three. So again, you have to be very careful and not short any of the G p a up in connections when the pies part on. Also, you should not powder pie with more than five bolts, sometimes the A C adapters that are sold to power the raspberry PiS, maybe of a cheap quality or maybe defective on if you supply the pie with more than five old. So if the signal is not regulated, you can in fact diamond your raspberry pi. The best advice I have here is ensure that you have a reliable power supply for your raspberry pi. On that, it gives a clean study signal off five volts. Those power supplies that come bundled with the raspberry pi kits are typically good ones that you can use. But if you are buying a power supply separately, just ensure that you check the readings and reviews on it and ensure that it is suited for the raspberry pi. Also, in working with the 3.3 volts supply pins, you should not draw more than a total of 50 millions from these pins. This excessive current draw again could permanently damage the raspberry pi on. Also, when working with the five old supply pens, you should not draw more than a total of 250 millions again. Drawing in large amount of current could damage your raspberry pi. So be careful and working with those pins. So now that we have an introduction into GP, I opens and what we are and how they allow us to interact with the physical and a real world with our raspberry pi, it's time to get a little more hands on and C g p A opens in action. 30. Standard Components Needed: Now we're going to get into working with GP I opens and seeing really how raspberry pi could be into feast with external peripherals and sensors. And this is what really makes raspberry pi pretty interesting and where you can make some cool, fun and exciting projects. But before we get going, let's talk a little bit about the standard raspberry pi components that you will need for the next series of many projects where we will be working with GP I opens. The components are the standards set of equipment that we have seen before, so you will need a respirator by three or any illusion of raspberry pi that you may have on SD card, which was flashed with the raspy in us. And if you had followed along in the previous lectures, we would have seen how to accomplish this. A USB keyboard and mouse e monitor or alternatively, if you have set up connecting remotely to your Asprey buy, you can do that. NHE and my cable if you're connecting to a monitor or alternatively, on each dia might of E G adapter. If you're using a VG monitor on the finally a fight, bold power supply. So these are the standard set of components that you would need when you're Wittman Raspberry Pi and will be using them with the GP, I open projects as we go along. 31. Downloading Code and Resources for the Course from Github: Let's go ahead and download the project. Resource is for the course Onda. This has been pleased upon. Get Hub. I will put a link to this in the resource is for the lecture. But when we have booted up our raspberry pi, let's go ahead and open up a chromium tab and we're going to go to the following You are so it's get hub dot com slash mia some slush pie bash ultimate guy. And as I mentioned, I will put a link to this in the resource is for the Dr When you get to get her page for the course, where and this well, put all the files off that unassociated with the projects and the cold and so on. Go ahead and click on the clue, or don't know the button to the right here and you wanna click on download zip. So this is going to download all the files for the course for us, and that ultimately saves to your dominance folder. So if you click on File Explorer and let's go to downloads in here, you should see these Apollo for the files that we don't noted, so you can go ahead and right click on didn't say extract here on, and you'll see all the folders that contain the files for the various projects. 32. Powering an LED: an office project will be connecting on, led to our raspberry pi will essentially be demonstrating how the led can be powered from one of the power pins on the respirator part. And if you remember from our GP I openly out discussion The respirator pie has a couple of pins that can be used as power pins. 23.3 full pins and also to five opens will be using the 3.3 volts pins. One note of safety and caution is that always power off or insure your esprit pie is powered off before connecting any secretary and peripherals With GP I opens. This is a good safety precaution as if you touch a GPL open. You can short them out or you can connect to pins by accident on DPA permanently damage their esprit pie. Believe me, that has happened to me before and you don't want to make that mistake. So please ensure that your parents powered off. Connect your circuit double check it, then par per pie. Onder that is the Sief we toe work with Secretary. So what are we going to need for our project? First of all, of course, the raspberry pi Andy associated peripherals. Also, a bread board is handy and working with external peripherals and just making quick connections. So always have a bread board handy too quickly. Wire up your components. We need a couple of wires. These are female to meal connecting wires, and they're pretty convenient in that one. End can quickly connect to a pin on the raspberry pi, and the other end can be plugged into the bread board. So thes make connecting components there respirator by very easy and a breeze. There are links provided to these in the parts lists for the course, so please feel free to check those links for online retailers that you'll be able to purchase these females a meal connecting wires from you also need a resistor, and here I have a 3 30 ohm resistor. You can also use a to 20 ohm resistor, but you need some sort of resistance for your everything in order to limit the current flow to the led so it doesn't burn out or doesn't damage your raspberry pi. Next, of course, you also need on led on any type of led will work, so just get a led of your choosing more color. And that's all we should need for our first project. Let's take a look at our circuit diagram. This is extremely simple Onda, very basic on just a couple of connections that we need here. So, essentially, here's our respirator pie and that this is the number one pin number 234 and so on. That's the convention that we're using. So from the number one pin, we are going to our 3 30 ohm resistor, and the other end of that resistor is connected to the A node or the positive pin on our led. The negative pinot of our led. Or the cathode is connected to the ground pin or one of the ground pins on the raspberry pi , and in this case, it's depend number six. So that's our circuit diagram. Fairly straightforward on. Now we're gonna look and see how we wire this up. Now let's go ahead and wire up our circuit. So the first connection we're going to make us to the 3.3 bold pin on our raspberry pi. And if you orient the raspberry pi with the USB slots at the base pin, one is the pin at the top left. So at the top of our Pirated left, that should be our pin one, which is our 3.3 volts pin. So I'm gonna take one of my wires on the connected to that pin. The other end goes to the bread board. So you can please that anywhere, Any bread board next up, we'll connect our resistor. So I'm gonna take the resistor. And remember, on the bread board, we want to make sure that it resistor is connected and he seemed role as our wire. Someone's gonna go ahead and make that connection. No, The other end of the resistor can go any. Where else? On the bread board. Next up. Let's connect our led Andi. Remember, Foran led. It has a lump in on a short pin. The longer pin here at the top is the an ode or the positive been and the shorter pin below is the cathode or the negative Been when you're connecting an led polarity? Murderers and in this case, the positive pin or the animal has to be connected to the end of our resistor. So just ensure that it's connected along the seem rope as the end of the resistor. And in the other end of our led or the Catherwood goes back to ground, and that is the pin six on a respirator pie in this case, So I'm just going to. But that connection and name, remember, it's any seem roof as the cathode and the other end was to pin six, which is the third pin down on the right on a respirator. By so right 123 I'll make that connection there, and that should be it. So that's a connection for our circuit. It's no complete, and we can proceed to boot up our aspect by and see if our led lights. So now that our raspberry pi has been booted up, if you'll notice our led is lit so the 3.3 volt pin is powering. Our led current is coming out of the 3.3 bullpen into our resistor into the annals of are led out of the Catholic and background on that's completing the circuit and power in our led. So now rld is being lit on power from or 3.3 bullpen. It just illustrates that these power pins can be used to power external peripherals and components connected to our respirator pie. Hope you liked the simple example on. We'll move on to now. In the next phase, we're going to programmatically control our led 33. Wiring Change to Blink an LED: in this project, we're going to start to take a look at how we can programmatically communicate with our GP . I opens toe control, external peripherals and sensors, and this is where it gets really interesting. We're going to start very simple on initially. We're just going to blink an led. The components you need are the seem, actually from the previous project on powering up in Led. So it's Justin led 3 30 ohm resistor on to connecting wires. There is, however, a small wiring change for the circuit, so let's take a look at the circuit diagram. So first pin 11 is going to be connected to our 32 day ohm resistor, and the other end of the resistor goes to the hallowed of our led the cathode. When he short up in on the led, is connected to ground on. That is grounded Vier pin six on our raspberry pi. So the only change that you have to make from the previous circuit as just to connect the end of the resistor, which goes to the animal connect that to pin 11 on a respirator pipe. That's the only wearing change will need to make. Let's check that out now. So let's go ahead and make that wiring change that we need for our blinking led circuit. The only thing that we need to do is remove our pin one connected to the animals off are led. So I'm gonna go ahead and remove that and we need to connect that to pin 11 on our Asprey pie. And Penny level is the sixth pin down on your left so we could come out here. One, 23 for 56 Go ahead and put that in. All right, let's give it a double check. One, 23456 That looks correct. So it looks like we've made that wearing change, and that's all we need to do for our blinking led circuit. 34. Demo the circuit: so in here, we're going to open up the blink. Underscore led folder. Andi In here. We'll see the pipe on file for the scripts that were going to run to bring our led so you can right click on the blink on the score led file, and you can open that up in the Tony Brighton I d. That way we can see the python code and let's go ahead and run this code for our project so we can go and click on the Green Arrow here to run current script and let's see what happens. So there we go. Our led is blinking, so that's pretty cool. In this simple example, we are programmatically controlling our led from a Python script on. That's how we can use Python to interface with our GP, I opens Andi interact with external peripherals and sensors, and that is very powerful 35. Blink LED Code Review: Let's do a quick court review of our pipe on program that links are led at the top. We are going to import the R P I G P I or library, and that's is a library that was written that allows us to interact with the GP. I opens programmatically next. We're going to import a time library and time allows us to sleep and have about one second pause between blinks. Moving on. We have ah GP A without set warnings false. And that's simply to suppress any warning messages that might come up that we don't need to see. We set our led pin as 11 on DA. That was theano that that's connected to the annual of the led. Remember from our wiring Bagram and how we were at a power circuit. We said the more of GP Iota GP I owed outboard on. Remember, I had mentioned that you can set it to BCM aboard board uses the physical location of the pins for the numbering. So since we set pin 11 as the led Penn were using that GPO dartboard notation, we set our led Penn as an output by doing GPL out Onda we initially turn our led pin high, so that turns a really deep in on next we go onto our while. True. So while true, basically this loops forever on and on and on. We initially set our led Penn high telling it on. Then we sleep for one second or pause for one second by calling time that sleep That way, Ideology stays on for one second. Then we turn our led off by doing GP io. That output led Penn GPO that low that turns it off. And then finally, here we sleep again for another second. So this causes are led to turn on still on for one second turn off, stay off for one second and then it repeats on for one second awful one second and disk as love as this program is running or led will think just a note here. Essentially, the top portion of our program here is just initializing our led Penn, sudden as output on in the Wild Loop is where we blink, are led very simple, straightforward program and illustrates the power of python to interact with in control. Our teepee opens 36. Button Press Introduction and components that are needed: Now you'll start looking at how GP Opens can be used to read signals from external peripherals that are connected to them. In the world of the Internet of things, it is important to take readings from sensors, analyze those readings and perform actions as an example. If you're sensor is a light sensor or ofoto resistor when it gets to a certain level of darkness. Once this is detected by the raspberry pi, a command can be issued over your network to turn on lights in a room or your home again. We will start simple and will simply show how we can detect when a button is pressed. Let's look at what components we need for our project. First, we'll need the raspberry pi on, of course, the's standard components that are associated with it. A bread board, a push button switch and to piers of female to meal connecting wires. These are all the components that will need for this mini project 37. Button Press Wiring: Let's take a look at these sick at Bagram for our project to detect a button press. It's a fairly straightforward and simple circuit. First, on our bread board, we insert a push button switch. One end of the button is connected to ground, and in this case, we're using pin number 14 on your esprit pie. The other end of the button is connected to pin 16 on the raspberry pi. That's it. Very simple. Only two connections, and that's all we need for our project. That's precedes a wire up thesis kit that will use to detect a button press. So first, this is a push button switch on and the particle of switch that I have there, actually, four connections. Andi on this side. If you'll notice these two pins can be connected. These actually, when the switch is engaged and pushed down, a connection is made between bees, too, pins on on the opposite side. A connection is made between these two pins here, so essentially there are. If you think about it, two different circuits can be connected from the seam push button switch, so we will only be using one end of the switch So the first thing that we need to do is insert the push button switch on the bread board on. Probably what would be best is to insert it across the gap here on our bread board. So that's firmly push that in place. Okay, here we go. Next up, let's connect the ground connection so we'll use ah, female to meal connecting wire Onda. We'll connect that first to one connection on the switch. And remember, we have to go along the seam, ruin our bread board so we make that connection there. The other end of the ground wire goes to pin 14 on our esprit pion pin 14 as the seventh pin down on the right. So again, here's our esprit pie oriented with the USB slots at the bottom at the top left that's been 12 and so on. So let's come seven down on your right. 1234 567 And let's make that connection and that is our ground connection of the wire will be connected to our switch. So again that's been sure. It's a lonely seem ro say when a verify that that's the case, push it in on the bread board on. It's going to go to pin 16 on ah, raspberry pi and been 16 is the pin that is the eighth pinned down on your right, and that's just right under our ground pin. Okay, so I didn't make that connection and that is it. Very simple, straightforward. And now our wiring is done. 38. Button Press Demo: now that we have booted up our esprit pie, that's open up the code that will need to execute for our project. So I'm going to open up a file explorer here. Andi, you can navigate toe where you downloaded. The resource is for the class. So if you had followed allowing my guide, it would have been a new whom Pie Donald's folder on There's the Main folder, where we unzipped all our project resources. You can go into the button press folder, and in there there would be a python file button. Underscore Press. That's right. Click on Open that up in the funny part on I D. E. So this is a code that we are going to run and let's go ahead and click on the Green Arrow to run the program. So now it's running on. I'll go ahead and press the button on and what you notice you'll see what's printed out in the shell is button pressed every time you pressed the button, so I'll go ahead and do it again, all right today ago. What's happening now is that we are accepting input from our button on, and when we detect that the button has been pressed. That's when we would display the button pressed message on the screen. It's a very simple example, but it's very powerful and we'll continue to build on. This illustrates how we can take readings from an external peripheral connected to the GP I opens of our raspberry pi on were able to detect if something has changed in our environment. 39. Button Press Code Review: next to a cool review to examine the python code that we executed to detect when our button was being pressed. At the beginning, we first import the R P I G P I O library and we've seen this before. This allows us to interact with our GP. I opens programmatically and take readings and so on. Next we imported time library and again we've seen time before. Time allows us to sleep for sitting periods if we want to introduce some pooling or waiting in our program next with the finally variable quote button pin. And we said that equal to 16. And remember when we were wearing a par circuit pin, 16 was connected to our button and the other pin on the button was connected the ground. So that is why we set it at the value of 16. Next we do GP io that set mode GP iota board on. Remember, we're using the board mood because our numbers are being referenced by physical location, and that's why were able to set button been equal to 16. Next comes a line, of course, that we haven't seen before, but essentially we're doing a GP io that set up we're seeing here set up the button pin as an input. So we have. The second argument in that function is gp ioo dot in and here we are enabling the pull up resistor. So pull up down is equal the GP I or that p d up. Andi. That's essentially the pull up resistor that we are enabling. Now the pins on the raspberry pi have pull up and pull down resistors. Onda pullup resistor actually pulls up the value of that pin. If you were to take a reading too high, if it were pull down resistor. If you were to take a reading on that pen, it would be look so by default. It will be high and in our circuit when we close the contact on our button. Current flows from our pin 16 through a button to ground and that internal resistance or that pull up resistance limits the amount of current that flows through our but none through a circuit in general, and that prevents the raspberry pi from being damaged. Onda a large amount of current a short from that happening so we could have added an external resistor in our circuit, but just to simplify the components we used here and this program the internal pullup resistor to simplify things. So it's very handy. Andi. It's a good tip for you to use in your projects next in the mean meat of the program after we have done our initialization in. Ah, while true Loop again, while True simply runs indefinitely and loops over and over again once there's power applied to the respirator pie. And, of course, your program is running. So first we take their reading of that button pin, so we set a variable input state is equal. The GP. I would've input button pin, and basically that's going to retrieve if that pin is high or low. And if the input status false, that means that the button was pressed in its the false state. If we were to read it, that value would be true or high, because we have pulled up that pen to high using our internal pullup resistor. But once the button is pressed, it's that values going to be low as current is going to be flowing through a pin and connected to ground, and that's why it add value would be false. Now, Now that verifies that in fact, our button was pressed and we do a print but impressed. And that shows up here in our shell. We do a time that sleep for about 1/3 of a second, and then we continue on. Now. The reason why we do a time not sleep is that in electron ICS, there is a concept called the bouncing on. What happens is when you press a switch because of physical contact is involved, it actually makes contact three or four times in a less than half of a second, and that is called the bouncing. So, in order to eliminate a false reading, we simply wheat for about 1/3 of a second. And if any denouncing happened, that would have passed. And then we continue on reading the state of our button to determine if it's pressed. So that is our program. It's very short about out. Quite a lot is going on in here on. Hopefully you understand the code that's involved, and you can incorporate buttons now in your respirator pie projects 40. Button Press LED Intro: We're going to gradually build in complexity now and show how weaken both take a reading from an external component connected to a GP. I open on the raspberry pi and then subsequently send an output to control another component. Basically, we're combining the input and output capabilities that GP I opens afford us and using them . In a simple example, we will be detecting the state of a button on when the button is pressed on engaged, we will light on led once the button is not being pressed or as released, our led will turn off. It is a simple example but demonstrates some important concepts. Let's look at what components we need for our project. First, of course, we need a respirator pie and the Associated Peripherals. Next, a bread board you push button switch on led. Any color led that you may have will work. I'm using a green led, in this example, a 3 30 ohm resistor. But alternatively, if you have a to 20 or more a higher value, that should also work. You don't want to get too high. Once you reach one, K or led will be very dim. So ideally, a 3 31 Resistors. What we're looking for for this project also to connect everything together. Here we have four meal to female connecting wires. So those are all the components will need for our project. 41. Button Press LED Wiring: Let's take a look at these sick it diagram for our project. We will be using a button to control and led. Let's start with the button. One pin on the button is connected the ground, and we will be using pin 14 on the raspberry pi. The other end of the button will be connected to pin 16 on the raspberry pi that is right after the pen 14 on the right hand side. Next for our led, the shorter pin or the cathode will be grounded. Onda. We will be using pin nine on the raspberry pi. The unload or the longer pin is connected to a 3 31 resistor, and the other end of that resistor is going to be connected to pin 11 on a raspberry pi. So we'll have four connections that will need to be mead toe a respirator pie in this project that completes the discussion for the sick. It diagram for our project. Let's proceed, tow wire up. I was sick. It for our project first will connect the push button switched bread board right, so let's connect that over the gap. Okay, once it's for me in place one end of the switch goes to ground, so we'll make sure and first connect one of the pens. And sure, it's a lonely seem rule. This is grounded fire Pin 14 on the Raspberry Pi soap in 14 is the seven pin down on the right from the respirator pie. So again, remember, ensure your raspberry pi is powered off when you were making any connections. So let's go to the right. 1234567 Okay, so you make that connection to pin 14 only raspberry pi. The other end LeVar switch has to go to pin 16 on the respirator pie. So go ahead and make that connection. Now it's again. Make sure it's lined up a lonely seem rule as our button and now the pin 16 as right under our grounded connection on the right, so that completes the wiring for our Putin. Next up, let's get our led. So again, remember, for the led there is a longer pendant, a short Ben in this case, the long pin on the bottom here is our unload, and the short a penalty top is the cathode. So just remember, Polarity matters when you're connecting an led. So be sure to connect those properly. So I'm just gonna insert my led any bread board from the cat food of our led. We're going to pin nine on the respirator party. So just made that connection. Now here is that cathode and we go again. Go along the seam route and Penny Lane on the raspberry pi. Is he 50 pinned down under left. So we count 123 for five Me that connection. Then we have to connect our resistor. So here's my 3 30 Whom resistor. We connect that to the I know Then along the same line, other and weaken, please Anywhere else on the bread born and from that line we have to go to pin 11 on the raspberry pi. So make sure we line it up and pin 11 is right under our ground connection under left. Once you have double checked everything and make sure that you're sick it is wired up correctly. We can proceed now to boot up our raspberry party 42. Button Press LED Demo: Now that our raspberry pi is booted up, let's proceed toe openly. Python program that we're going to execute to render code for our project. I'm gonna open up a file explorer here, and I'm going to navigate to the folder where I downloaded. The resource is for the class. So in here we can open the button press led folder. Andi, you should see a price phone file button press led. I'm going to open that in the python I d onda. Once that loads up, let's go ahead and run that script so you can click on the green Arrow here and we can take a look here at the show. So now I'm going to press the button for our circuit on notice. What happens there's are led its lighting. So when you press the button, okay, are led comes on. And as I read, remove my hand from the button, The led goes off. Okay, so it's simple, simple demonstration here, but really, there's ah, a couple of important concepts that we're understanding here. We're learning how to take that input from the button to determine the state of the button . And once we have that we're then actually affecting the output to the led. So very interesting again. It's a simple example, but it illustrates some powerful concepts in the next lecture will do a code review, so you will get to see how this software interacts programmatically with our GP opens. 43. Button Press LED Code Review: Let's do a cool review for our button press led circuit. So at the beginning, we first import the GPO library. We've seen that before, which allows us to programmatically interact with the GP. I opens. Then we imported Time Library, which allows us to sleep. Onda have pauses in our program. We do GPS that set warnings false Andre, Of course, that does suppresses any opens to the shell that we know necessarily care about. Then we set the led pinto be equal to 11 since it's connected to that 11 physical pin on the raspberry pi and our button been equal to 16 again that was connected to pin 16 on the respirator pie. For the mode we do GPL that sat more gp io dartboard, since we're referencing the pins by their physical location. And then we set up our led Penn as an output by doing the GP io that set up calling that function passing in the led pin and the GPL out on. Initially, we turn our led off, so gp ioo dot output toe allergy pen Onda. We set that gp ioo dot low that would turn our led off initially because our button obviously isn't being pressed. Next, we enable the pullup resistor on our button pin, and we have discussed this before on how it works and why an external resistor connected to a button is not necessary. And we can just leverage the interno pullup resistors that are provided to us on a respirator by. So that's what we're doing in this line of code. Next we get to the meat of our program, the wild troop again, which this loops indefinitely. As long as our program is executed here, we're going to take a different approach. I wanted to introduce a different trick instead of simply pulling. So GP Io affords us a wait for EJ function. Essentially, what this does is it holds the execution of the program, and it waits for the particular pin our button pin to fall on. Remember when our button is pressed, the value of that button Ben goes from hi toe loop or true, the falls on day. That would be a falling edge, which is detected, and once that's a case we print the button pressed down to the shell Onda we turn our led on, so we do a GP iota output telling our lady to go high and we pass in the GPO that high argument. Then we call the wait for EJ function for it to rise again. So passing in the button been argument. And of course, the condition is gp ioo dot rising. And what that means is again our program wits around for that value to go from low to high or from false to true. And of course, if that happens, that means that we have released our finger from the button on once. That's the case We set our led Penn toe low one turn it off. So just wanted to introduce the different mechanism for determining when our witness pressed on. Of course, when we determined that that is, in fact a case, you would lighter led or turn it off respectively, instead of pooling. So here. This is a different trick for determining when an event happens on a pin, and it can be used in any of your raspberry pi project. So just wanted to provide you a different tip and trick on alternative for working with event detection. Let's quickly take a look at the documentation for this week for EJ function. So if we open up a chromium tab and go to Google and weaken, do a search for GPL Wheat for EJ. And once that comes up this first lengthy source forge links, you can go ahead and click on it on. This is the documentation for the GPU. Specifically, the inputs on the GPS, your library. Andi here. If we scroll down, there's a section that discusses interrupts an edge detection. And here's the wheat for EJ function. So from the documentation you can see here, the wheat for EJ fight on function takes the channel that it's waiting on. And this was the button pin on. Also, the depending on If you're waiting for a rising edge of falling edge, or perhaps both, that's his second argument. You pass in. So this function is designed to block execution of your program until an edge is detected again. Just another way to pool. Instead of having me constantly checking the state of the button, this is just a quick way to have the GPS. Your library itself wait for an event, a happen, and then you can react it accordingly. So I just wanted to show how you can have checked the python documentation for the G P A or library on da What that exactly that wit for EJ function does. 44. Introduction to PIR Sensors: a P I R or passive infrared sensor is a very interesting component. It can be used in a lot of Internet of things and automation projects. Here is how it works. API IR sensor measures infrared light emitted from objects that generate heat and therefore infrared radiation. In its field of view, it does not detect their radiation itself, but actually the change that occurs when a target enters its field. The change in the amount of infrared radiation, which happens when an object crosses its field of view, results in a change in the voltage that is generated from its signal pin. The P A R sensor has three pins here on the right VCC, or power, which is typically connected to five volts, a grown up in which is connected to ground On any middle. Here is a signal pin or an out pin. In a normal state, the signal Pinar puts a low signal. When motion is detected, however, it outputs a high signal on its output pin. By looking for this change from low to high. That is how we can tell that motion occurred. We will be connecting this P ir sensor to our raspberry pi on using it to detect motion. This has a lot of applications and can be used in a security project, such as if motion is detected on alarm, concerned lights can be turned on or a text message can be sent. 45. PIR Sensor Components Needed: Let's take a look at the components that we will need for our P IR sensor project. First, you need a rest. Break pine on. Of course, all the associated peripherals. Next, we'll need a P ir sensor. Onda finally three female to female connecting wires. These are a little different from the meals of female connecting wires we have used previously. These are female to female warriors, and if you'll notice one end can be plugged into we GP. I open on the respirator by on the other end can also be plugged into one of the spins for the P I. R. Sensor. So these are very handy. And if you use female to female wires, you shouldn't need a bread board for this particular circuit. Those are the components that we need. 46. PIR Sensor Wiring: Let's take a look at the CICA Dag room for the P i r Sense of project. Yeah, just three connections that I needed from the P i. R Sensor to the raspberry pi. The convention that I have used on this circuit diagram is the pin to the left on the PR sensor is the ground pin. The middle pin is thes signal pin, and the pin on the right is the VCC pin. This is the typical standard configuration for PR sensors, but for the Pierre sensor that you're using, you'll just want to double check the labeling on the pins to ensure that they correspond to the ground signal and vcc pins on and make collections accordingly. So the first connection from the ground up in on the PR sensor goes to pin six on the raspberry pi, the middle pin or the signal pin is connected to pin seven on the raspberry pi On Finally, the VCC pen or the power pin for the Pierre sensor is connected to one of the five old power pins on the raspberry pi, which is pin, too. That is all the connections that we will need for a PR sensor project that's proceeds a wire power circuit. So here's NPR sensor. When I turn it around three pins that are exposed, the people on the left here is the vcc pin. Then we have the signal pin in the middle and the ground up in on the right. So let's please connect the VCC pin going to take one of my female to female connecting wires that goes to been to on the respirator by which is the five volt power pin the middle been, which is all signal pin. Connect that on the P I. R. Sensor. That signal pin goes to pin seven on the raspberry pi and pin seven ISI fourth pinned down on the left. Finally, I will grow up in. I'll connect that on the PR sensor, and the ground pin on the raspberry pi we're using is pin six, so that's 1/3 pinned down on the right. So those are the connections. Everything looks good. We're done with the wiring. Let's proceed now to boot up our respirator by 47. PIR Sensor Demo: know that our raspberry pi has booted up. Let's proceed toe open the script that we need to execute for R P I R Sensor Project. So I'm gonna open a file explorer here and we can navigate to where we downloaded. The resource is for the class. Andi in here. We're going to go into the P I R Sensor folder and there should be a p I r underscore sensor python file. So we're going toe right Click here on open in the by phone i d. And now that we have opened up the code, we can go ahead and click on the Green Arrow to execute the current script. I'm just going to orient my p i R sensors so that it faces toward me and in a forward direction. So I'm just using the bread board here for support. Remember, we didn't need the bread board tow wire this up, but I'm just using it there for support purposes. So once the p I R sensors are ended correctly, let's go ahead and click on the Green Arrow to execute our python script On your notice, I'm going to move my hand and what you'll see is once motion is detected Our script this, please. A print out to the shell and amusing a number that is incriminated here so that we can actually see that movement corresponds to the particular motion detected being printed out . So now I'm going to move my hand And as you notice the numbers and comment and I'm gonna keep my hands still, remember a PR sense of the text change in movement. Someone try to keep my hands still. I'm going to move it. Oh, and there you see it goes again, again. I'm going to try to keep my hand. That's still a possible Still, the number settle down and it stopped at 1 45 I'm gonna move and you'll see it picked it up again. So ah, P ir sensor is working. It's detecting the change in motion using infrared signals. And in the next lecture, we're going to dive into the court to see how we programmatically determined that motion has, in fact, occurred with our PR sensor 48. PIR Sensor Code Review: Let's do a court review for our PR sensor project so you can understand how the Python code is used to take readings from the P A R sensor. It's a very simple program for study. Beginning we import the GPO library. We have seen this before. Then we import the Time Library, which, of course, allows us to introduce the lease in our program. We set a variable B I Arpin equal to seven because if you remember, the signal pin on the p I R sensor was connected to pin seven on the raspberry pi. We do GP ioo dot set mood to gp io Dartboard Since we are referencing the pins by their physical location next up we set the P i R pin as an input by doing GP iota set up the I Arpin passing in the gp ioo dot in argument. The next variable is a reference variable. So we set a variable count equal to zero on. The only reason why I did this was so that when we looked in the shell, you could have seen the count incriminated as thebe ir sensor detected motion. This made it easy to see when a change that we introduced, such as motion caused the P i R sensors to trigger in the show in our wild true loop. Of course, this loops indefinitely. Once the program is running, we first take a reading of the state of the P i R pin. So there's a variable input underscore State onda we assigned to that variable the value of the gp ioo dot input p i r a pin the sticks are reading of the B I Arpin on stores Thesis subsequent value in the input underscore state variable. If that input underscore state value was true, that means that motion was detected Essentially the Pierre signal pin is low, Andi, it jumps too high. If there's output from the motion sensor when that is the case we print motion detected on Dhere we're converting our count variable to a string and concoct in eating it entered the motion detected string. That's how we able to see motion detected one than two and three and so on. And this next line we increment the counter variable So this is a shortened notation for county equals accomplice one on we keep implementing every time we take motion. We introduced a small sleep here of about 1/3 of a second between readings on Ben. This loops all over again. So that, essentially, is our program that interacts with the p i. R. Sensor on. It allows us to take readings, and we're pulling here to detective State of when that signal pin changes from low to high to detect motion. 49. PIR Sensor Alarm Intro: in this project will be making a P IR sensor alarm. Essentially, when motion is detected, we will sound an alarm on a prize. A buzzer. This is a simple project but can be extended to just about anything. The possibilities are endless. You can turn on lights, send text messages, capture an image from a camera and so on. We will discuss the nuts and bolts of this basic security alarm. Let's take a look at the components that we need for this project. First, a raspberry pi and its associated peripherals. A bread board api ir sensor. We also need a pies, a buzzer, and this will be the alarm for a circuit, a three Boutiette womb resistor, and we'll also need some connecting wires. What would make things convenient would be three female to female connecting wires on. We'll also need a couple of meal to female connecting wires. These are all the components that we'll need for this project. 50. PIR Sensor Alarm Wiring: Let's take a look of the circuit. Bagram for be IR sensor alarm project. We're going to start first with AP IR Sensor. And again, there are three connections that come from the PR center on that connected to the rest rape I First the ground been NDP IR sensor is connected to pin six on the respirator by be signal pin, while the middle pin on the P I R sensor is connected to pin seven on your ass spray pie and the VCC pin for par pin on the P I. R sensor is connected to one of the five bolt pins on the raspberry pi, which is pin two will be using in this case for our price. A buzzer. The negative spin off our buzzer is connected to ground Andi that has been nine on the raspberry pi. The positive pen is connected to eat 3 30 room resistor, and the other end of that resistor is connected to pin 11 on the raspberry pi. So those are the connections altogether. Five connections to the respirator pie. Fairly simple. Andi, Let's proceed now to see how we wire all of this up. Let's go ahead and wire up our circuit. The first gonna connect api ir sensor on. Remember, if you flip your p ir sensor over, we have the VCC pin, a signal pin and the ground pin, so let's was connect the VCC pin. I want to use a female, the female connecting wire here so we'll connect the VCC connection first, and that's going to go to pin to on the raspberry pi and pin to remember with the raspberry pi oriented with the USB slots. At the bottom is the first pin on the right at the top. So that's our up in two. Next up, we're going toe wire the signal pin, which is the middle pin on r P a r sensor. Our signal pin goes to pin seven on the raspberry pi in pin seven is 1/4 Been down on the left, so I will make that connection Now. The other connection for our sensor is the ground connection. So I'm putting in a female the female pin here and the grown that we're going to use would be pin six on the respirator pie, and that is the there have been down on the right, so go ahead and make that connection now. All right. So those are all the connections to the rest Spray pie from our P ir sensor. Lets no proceed. Tow wire up our pies. A boozer. Now, if you have a Peiser buzzer if you notice at the top, you'll see there is a positive sort of marking more indication. And that indicates, of course, the positive pin of your prize. A buzzer. So you want to be mindful of that positive plus sign? So when you're orienting it on your bread board that you connect the correct wire to that positive pin. So what I would advise is with the bread board, you wanna gently push in your pies a buzzer, leave it so that you can see the pens or they are at least exposed a little bit that will make it easy and ensure that you lying things up correctly. So when it is connected and everything is in place than we can push the pies a buzzer in all the way. So for now, let's was connect up our positive connection. So from our circuit diagram, we're gonna insert the 3 31 resistor, so I'm just gonna make sure that that lines up King and the other end of the resistor can go to any. Where else? In the bread board On the other end. From that resistor goes to been 11 on the raspberry pi. So I'm going to get a meal to female connecting wire here. I'm gonna line it up in the seam role here as our resistor, and we're gonna go to Penny 11 on the raspberry pi, which is the six been down on the left. So I'm just gonna make that connection here. Okay, so that is in place. And last but not least, we're going to connect the negative penalty buzzer that it ground on the restaurant by and we're gonna use been nine any respite by? So let's first insert this into the bread board. On the other end is goes stupid. Nine on raspberry pi. Benign is the fifth been down on your left under aspirin by that is sort of sandwiched in between the other pens. Okay, so those are all the connections, and what we'll do now is everything is in place. We can simply push in our price of other you know, a circuit Onda. We should be good to go. Now we can proceed to boot up our respirator pie 51. PIR Sensor Alarm Demo: Now that our esprit pie has booted back up, let's proceed to open up the program that we will need to execute to test out O r P I r sensor alarm circuit. So I'm gonna go ahead and open up a file explorer here and you can navigate to the place where you downloaded the resource is for the class. Andi opened the P i R sensor alarm folder and in the air they should be a p i r on the score sensor on the school alarm that pie pie can file. And we're gonna open this up if you right click in the python i d. And this is a program that we will execute. So now, before we execute our program, we just want to make sure that our P ir sensor is angled outwards that we we move our hand towards the direction of the sensor or somebody part. There's ah path that it will be able to detect the obstruction. So just on Italy, p i r sensors somewhere are we facing outward Onda? Once that is good to go, we will go ahead and execute our script. So now let's go ahead and execute the script by clicking on the Green Arrow. And now we're going to try to perform some motion, as you can hear when it detects motion. Our buzzer sounds So I move my hand again on as moving a body part they go RPR sensor is working on gonna be sort of still him gonna move my hand directly across the path of the sensor on There you have it. My hand is many center now, and I'm going to try to move it ever so slightly opened their detected it so poor PR senses working on again. It's using the change and infrared waves to detect motion on Once motion is detected, it is activating your buzzer. So here it goes off again. In the next lecture, we will delve into the python code so you will understand how the software interacts with the peripherals to make r p I r. Sensor alarm circuit work. This is just there it goes again. This is just the beginning. You can make this project as complex as you want to. Andi. You can add on perhaps a camera to take an image when motion is detected, or send a text message to you with an image. The sky's the limit, but hopefully this gives you the basic foundations of how to make a P ir sensor alarm project with your raspberry pi. 52. PIR Sensor Alarm Code Review: Now let's delve into the code so we can see how the p I r sensor alarm circuit works. So starting at the beginning, we've seen this before. We import the GP Io librarian that allows us to interact programmatically with the GP opens . Then we import the time library Andi that allows us of forced to sleep on did introduce the lease in our program. Next, we have tp ioo dot set warnings false. And again, this just suppresses any warning messages that we need not be concerned about then, with a clear a couple of variables. So first we have the p i Arpin, and that's equal to seven. And if you remember, the P I. R pin was connected to pin seven on the raspberry pi. Then we have the buzzer pin equals 11. Andi, Then we do the GP io that set Moto GP Are that bored again because we're referencing the pins by their physical locations. Next up, we set up some of those GP opens. So first the Pierre pin, we set that up as an input. We set the buzzer pinup as an output by setting GPL out because we'll actually be sending an output signal to the buzzer for it to make a sound. And initially we do GPO dot output buzzer pin, sending a low signal to our buzzer pin. And in that way it will be off initially when our program first starts. Next up, we define a couple of functions, and we haven't seen these thus far in our programs. So now we are gradually building in complexity. And the purpose of this is because I wanted to illustrate a different way of handling interrupts using our osprey pie and python. So if the first function is going to sound our alarms, the name of the function is sound alarm. It takes one argument, which is our P i r pin Ondimba python. When we define a function, we used the D E F G word, and that's simply seeing that we're defining of function at the end of the function name. We have a colon, and what follows next is theatrical body or content of bad particular function. So within the function, the first thing we're gonna do is print sound alarm, so that's going to show up in our shelves and then we're going to do a GP iota output setting our buzzer pin toe high and that is going to turn are about their own. And that's when you heard that audible sound coming from the buzzer. We keep this going for about two seconds, so it should be called time dot sleep passing in the number two. And after we're done, we want to turn off the alarm. So we call the turn off alarm function passing in our PR. A pin on that conveniently jumps into the next piece of code. So the next function that we have in our program is turn off alarm again. It takes PR pin as an argument, and within here, essentially, we turn off the buzzer so we do a GPO dot output buzzer pin gp io got Lou on. That essentially sends a low signal to the positive print of our buzzer on It's going to turn our bazaar so you're no longer going to hear the buzzer making a sound. So those are two functions now. The mean important piece of this program actually is the very last line of code what this is. It's ah, way that we can introduce interrupt handling in our program in a more efficient we and that we don't need to pool constantly to determine if the PR sense up in is high. So we do this by using event detection. So the GPL library affords US disability GPU that had event detect on. Basically, here is where we specify the particular pin that we're want to detect an event on whether the value of that pin is rising or falling, or both, meaning the change that happens on if you recall for the PR sensor, the signal pain goes from low to high when motion is detected. So by indicating gp ioo dot rising, here's our second argument. We're seeing any time our signal pin no r p i r pin the texts a change from low to high, which, when motion batters when motion occurs. We want to execute this particular callback function on different argument to this add event, detect function is called back equal, and we pass in the name of the function that we want to call, which is sound alarm. So, essentially, what's going to happen here once we have added that event toe Arpin Anytime the pin goes from low to high or in other words, it rising GPO that rising, that particular scenario happens, and the pain goes from low to high. This sound alarm function is going to be called, so we jump into the sound alarm function and we execute this piece of code, which prints out sound alarm to the shell turns or was their own for two seconds and then turns it off. And then our program continues, and it simply listens for when the motion is detected. Another point that I wanted to highlight is that this piece of code here runs in its own separate thread. So Peyton has the ability to have multi threaded programming. So if you had had other parts of this program, what would happen, actually is once an event was detected that the signal rose from low to high. This piece of code or the sound alarm function would be called in a separate thread to your mean thread Andi. That's pretty interesting as faras. How interrupts our handle that it allows a lot of efficiency and you can do other things in your program without happen to wheat or block or pool, and you can write more efficient programs that utilize resources and memory and a more efficient way. So hope you enjoyed this. It was just illustrate how we conduce, interrupt handling on how we can detect a change, whether it be rising or falling or both scenario from any of our GP opens and then use this subsequent information to take action. 53. Working with Cameras and Images Introduction: Now we're going to take a look at how we can work with images using a respirator pie. When we think of the respirator pie using sensors to interact with an extract information about the real World GP I opens Come to mind. However, images on video are also an important source of input. By using a webcam or the Raspberry pi camera module, we are able to sense our external environment by capturing images and video. And we can use machine learning on computer vision techniques to identify the content of these images as an example in a security system. If your pee IR sensor detects motion. If on images captured, we can sound an alarm. If we determine a picture of a person has captured as opposed to a pet or an animal that sets off the sensor, we will be looking at how to work with standard webcams on the respirator pie camera module to see how you can interact with these devices via programs on incorporate them in your respirator pie projects 54. Connecting your USB Web Cam: USB webcams have become very common and fairly inexpensive. Now we'll be taking a look at how to connect these devices to the respirator by and hope to interact with them. Programmatically Here I have two USB webcams. The one on the left is the C 9 20 model, which is a 10 80 p HD Webcam on the one on the right is the model C 3 10 on is a 7 20 p webcam. Both are from Logitech, and these are extremely popular models that are on the market. They're also very affordable. Either will work for the next series of LETRAS, and any USB webcam, for that matter in general, will work to connect a web. Come to the raspberry pi is extremely simple. These are USB webcams, so you just simply take the USB connector that goes from the webcam on did inserted into an available USB slot on your raspberry pi. That is, all you need to do is to connect the camera to the raspberry pi 55. Installing and Configuring Motion to setup a Web Cam Server: Now that we have connected our USB webcam andare raspberry pi has booted up The first software we will be working with is called Motion on Motion allows you to quickly and painlessly set up a webcam server. So I'm going to walk you through how to install motion Onda Configure it to set up a Web timesaver. Let's go ahead and open up a terminal. Onda No, we're going to type in here pseudo upped. Get in store motion. So we're using the A P T pocket system on did. It's gonna go out on bond, Get the packages and dependencies for us when you get to prompt you type and why and hit. Enter Andi. Now we are retrieving the packages for the motion software on this is ah, Webcam server that week and quickly set up. So let's give this a minute to run. And once it has completed, we need to do some configuration of a few files before we get it up and running. So now that is complete. The first thing that we should do is check to see if the webcam that we've connected toe a USB socket is showing up. So we can type in L s U S B andi what you'll notice on here. In my particular case, I'm using the C 9 20 Webcam. So you should see the Web cam showing up here in the list of USB devices that are connected on DA. Depending on whatever type of webcam you're using, you should see that brand showing up in the list there or something similar. So that's just a quick verification to ensure that at least the system is seeing the webcam connected to your USB slot. So the first thing that we need to do is we have toe added emotion that can file, and I will put a Siri's off instructions as a resource for the video. And that way you can copy in peace to commands so you could feel free to just follow along . Or you can tap the commands with me as I go. So we're going to do a pseudo no no onda slash at sea slash motion slash motion that conflict A and that's editing the emotion con file on and the first configuration changes. We want to change the demon from off to on now in Nano. How weaken search your finds. It's not very intuitive, actually, Instead of we would typically be familiar with control off to find something in a file. And now I know it's controlled w where it's so if you type in control w you'll get a search prompt showing up on We want to type in the wood demon on. We can go ahead and hit enter and there we would have located that configuration. So what we want to do is change this from off to on the other change that we need to make is we need to change the stream local host from Aunt Off so we can hit the control w again and weaken type and stream local host. And that would get us directly to where that setting is in our configuration file. And we want to change this from on to off. The last setting we need to change in this file is thes web control. Local host on. We want to change that off so that if we do a control w and we're searching for this time, Web control underscore local host Onda. It takes us to that setting and we're going to just change this from on to off. So those are the three changes we need to make it this far. When we're done, we can hit control X to exit. It would ask us to see the modified buffer, so I'm just gonna type and why? And again, it gives you the confirmation to write the changes to the file motion. Not confident. Just hit. Enter. And we would have saved our changes. So that was the first file that we needed to change. Next up, we need to edit the emotion file. So we're gonna do a pseudo no no at slash at sea slash default slash motion. Okay. And we need to just change one setting in here. He start motion demon equal No one. A change that yes, to just make that change in the file. Here, change this to yes, on we. When we're done, we hit control X. Why? To see if and that would see that change. So now that those two configuration changes have been made, the only thing we need to do is start up our motion service. So to start up the motion service, we do sudo service motion start. Okay? And that would start our service up. Andi, before we bring it up. I just want to show you how to shut it down. So it's very intuitive. Obviously, pseudo service motion start is going to start it up. And suitable service motion stop is going to stop that motion service. So I'll go ahead and start it back up on. Now that our services running, we should be able to hit our Webcam server in a browser. So I'm just gonna open up a Crimean top here on now. We can proceed to test out our web server. 56. Demo of the Motion Web Cam Server: So now to test out our motion server, we simply need to enter our I P address on Go to Port 80 81 for the page to show up. So to get our I p address, we just simply hover over our WiFi connection or Ethernet connection. On we can see the I. P address and Mikey's here it's 10 001 of seven. Someone enter 10 001 of seven, and at the end, the port is 80 81. So why didn't enter that? But in your I p address on there you go. So there you have it. Now you can see in real time the Web com is streaming through a browser, and you can hit this from any computer that is connected to your network. Simply plug in the I. P address and Port 80 81 you should be able to see your Webcams ever streaming. If you expose your respirator by to the Internet, you can also access. You're welcome, sir, when that's a good way to have what comes over running where you can see somewhere in your home or some place that you want to monitor so very cool, and it's quick and easy. Andi, Since we're on the raspberry pi itself, you can also access this web cam by typing in local host 80 81. So when you do that again, the motion webcam server comes up. But again, if you want to access this from another device on your network, just used the I P address that was a scientist, a raspberry pi. So hope you like this school and simple, easy, convenient Web server. The only thing about this is that you cannot interact with it programmatically. It's just sort of ah, you install the service and you started up on, and once that has started up, you enter the I P address in the browser with Port 80 81. And that's basically the limitation off the motion service. It's quick and dirty, easy to set up, but not a whole lot of flexibility for interacting with your USB webcam programmatically with the motion option, just to show you that when you stop the motion surface that the Web come super actually stops working and you won't get anything showing up on your port. 80 81. Let's fire up that pseudo service motion Stop command, and once that's executed and run, it's now has stopped. So if you go to the local host 80 81 you try to bring that up, it says that the site can be reached. So the services down so that that just shows that you can start and stop the surface from the terminal. And when you started up, you're gonna get a chewing right now. This was the last frame that was recorded. That's what they're showing up here. But if you try to refresh it, these services currently down, so just wanted to show how that works. And of course, if you started back up and you go back to your browser and you refresh now there it goes again, so it's back on. 57. Preparing your System and installing fswebcam: Now we're going to install another utility that allows us to interact with our USB webcam on did, in this case, the name of the packages called FS Web can and the difference between motion on Fs Webcam. Is that what fs webcam? We can in fact invoke the webcam taking video or a picture from the terminal? Because of that, we're able to write a script on that. We can execute the script to be able to record on. That makes it a little more flexible, whereas what motion? He simply start up the emotion service and you get the or Web com server in a browser and he can't really interact with it a whole lot. So this gives you a little more flexibility. So the first thing that we'll need to do is if you had installed motion, we want to uninstall it and remove it just so that there are no conflicts. So we're going to run a pseudo up dash, get we move motion, okay, and that's going to go out and remove motion for us. We just hit. Why? To confirm that we want to continue and this will go through on on on in store some of those packages associated with motion to clean things up. That's to a pseudo up get pooch motion, and that is going to clean any configuration files or any other packages that are no longer needed It Why on gonna let this run next before we install efforts? Webcam. Let's make sure that our system is up to date. So we execute subtle, apt get update. And again, I will put a list of these instructions as a resource for the lecture so you can follow along or copy and paste to make things simple into the terminal. So let us let this run on. We'll pause the video and resume when the update has completed. Okay, so the update has competed. Let's actually upgrade all our packages to do the installs. So gonna rela sudo apt That's get dissed Bash, upgrade, And this is going to run at me. Take a little while again, it will show you a list of packages that we're going to operate on. The reason where we're doing this is you just want to make sure that everything is up to date on All the dependencies are fixed on in place before we install efforts. Web come so we don't run into any issues that may be difficult to troubleshoot. So just when a hit, why? And this is gonna upgrade and download all the updates for us, and it may take a while, so I'm just going toe pause the video and we'll pick it up again once the upgrade has competed. Okay, so now that the upgrade process has been completed, that's first create a folder where we're going to store all the images that we will be taking with our webcam. So I'm gonna open up a file explorer here, And if we go to the Donald's folder in here, we're gonna make a photos folder. So let's do it this violet terminal so you'll get some practice with the terminal. We're gonna do ah m key de ir for make directory till day slash down moods and we're gonna put in here photos, and that's going to make that folder for us. Onda we can changed about directory download, seedy space still day slash donald slash photos on now we are in that directory. As you can see, we don't have anything in there. Eso that is the fourth whose directory that we just created. And now let's proceed to in store fs webcam so we can proceed the type and sudo apt get install Fs Webcam and this is gonna go out and get that software, forests and all the packages and so on and install it and it's done. 58. Using fswebcam: so now that it has been installed, it's very easy to use. So let's go ahead and taken images. NFS webcam. So we type in F s Webcam and let's put the name of the image. I'm just going to see image that Depay and hit Enter and our webcam would have taken a food to. And if you notice, here is the image that Jay Peak father was created. Let's go ahead and open it up and there you go. So it took an image. Onda. We were able to use the FS Webcam software to control our USB webcam and take a photo. So that's that's pretty cool. And what is nice about this is of course, you can script this, and that's where it gets pretty interesting. So by writing a bash script, you're able to interact with your webcam and take photos Anytime you want. You can think about if there is ah, sensor connected to your esprit pie. Like a PR sensor of motion is detected. You can fire off a script to take an image and capture what was seen, so that's an example of how this can be used. Let's go ahead and the specified a resolution of the image that we want to take. So efforts Web come allows us to do that. So if we type in F s Webcam on, let's see, we want to change the resolution from the default we just do a dash our for resolution on gonna type in here 12 e t. By 7 20 Let's see, that is what we want for the resolution of our image on them Will anemic image too cheap. So this is going to capture another image for us. Onda here with specifying the resolution. And we're giving it the name image to the J Pegs. I'm going to just go ahead and hit. Enter here, okay? And you should see that image to dodge a big show up. It's going to go ahead and double click on it on and Harry go. So just getting a some glare there off of my glasses. So about image that we just took Now, one thing you'll notice is if you look at the image itself, there is a banner that appears below the image by default on. Of course, we mean one to remove that manner in order to do this we can type in. That's do the FS webcam. And again we're going to specify the resolution Dash are And we're gonna do a 12 80 by 7 20 But now, before we put the name of the image that's put in the dash Dash known Dash banner option on Let's call this one image three That cheap. Okay, So once we do that in this particular case, where specifying that we don't want that by Ananta appear I'm just gonna hit Enter Onda. That's double check how that one came out on def. You notice down there we don't have a better. So there's no batter that's showing up at the bottom, so that allows us to have that flexibility. If we don't wanna be bothered to show up, we just put in the dash dash, no better option 59. Using a script to take images with fswebcam: So now, as I mentioned, what about if he wanted to create a script that runs to take a an image from our web gun? What we can do that I have created one for you, Onda, if you'd navigate toe where you download any resource is for the class, I'm going to go into the full there. Here. There should be a cameras folder on in there. There should be a webcam folder. There's a script in here. Call Webcam. That s H Andi. The first thing that we need to do before we run this is to ensure that it is executed ble by anyone. So if you right click on the file and you go to properties on the permissions want to make sure that this is selected as execute by anyone on, but that would allow anyone to run this script. You would run into any permissions issues. So if you do that, you just go ahead and click OK on. Alternatively, what you could have done is you could have also executed that from the command line. So the easiest thing to do is we can copy this path to the web. Come. That s H folder. Someone highlight this control E control. See? Gonna go to my terminal on. I can put in, see each ahmadi change mood and we could do a plus X. That is a shortened notation to see that we want to defile to be executed Herbal we can at it pieced That's gonna PC path to a file. And if we do, ah slash in a tub, it's going toe toe compete for us on again. This is just another way of making the file execute herbal. But you can do it very quickly from the five Explorer. Or you can do it from the terminal. Either way accomplishes the same thing. So once that's done, we can execute that file. So if I do a CD space and I'm gonna just pieced that path there, all right? And if I do win unless I can see the webcam but a siege files so I can do a dot, slash type and w on hit the tab key and it's gonna have to compete for me. So if I do that when they hit, enter Isaac can see a file was created for us in the download slash photos full there. So let's go back to that full there in the air. You should see a file. I was created, and I will go into descriptive and seconds. You can actually see what's going on, but it created it. Took an image on it. Did date timestamp for us. Onda. Let's go ahead and open that up. Okay, All right, so that was the image that it took. And again we were ableto run that Fermi script. Andi, that's pretty cool. So that means, as I mentioned, you can have your respirator pie connected to some sort of sensor. And when motion happens or temperature changes or anything any sort of event that you want to detect, you can execute a script that would take an image from the camera connected to the USB slot of your raspberry pi, so that's pretty cool. 60. Fswebcam script code review: Let's take a quick look at the script that we actually run someone a navigate back up to the cameras, Fuller and in their webcam. So I'm gonna open this in a text editor. Okay, on here is the script that we just run. So again, we're running a bash script on and we foods create a variable date on This is, ah, the date format that we're going to use. We then make the directory whom by? Down with photos. Now, if you remember, we meet this before. What is going to do is if that food was directory already exists is simply going to not do anything or not overrated. But if it's missing, is going to create that for us. And then we're executing the FS Webcam Command. We're specifying the resolution seeing that it's no banner. And here is where we specify where we want to see the photo one. The name of the file is that dynamically generated date that's calculated. So every time you run this again, it's going to create a new file with a new date time stamp. So that's pretty cool that we could run the command from a script on Like I said, this opens the door for us. There's a lot of potential to have an external sensor detects something and have a web. Come take a picture as a subsequent action. So just to show that another one is going to be created, So I'm just going to hit the up arrow here on that. That should we run our script? Okay, so once that's done, if you go to the folder, what he fells are at downloads, photos, folder. As you can see, another one was created. I'm just gonna double click on that. Hey, you go. All right, so that's pretty cool. Fs Webcam gives us a little more flexibility than motion and working with a USB camera on next, we're going to dive into the raspberry Pi pi camera module and see how we have a lot more flexibility. Working with programmatically Onda were able to do a lot more stuff 61. Introduction to the Pi Camera Module and how to connect it to the Raspberry Pi: the Raspberry Pi cameraman. You was designed specifically to work with the raspberry pi. There is also a special connector that is used to attach it to the pie. This is situated between the Ethernet and the each jam my ports. It is capable of taking full HD photo on video and can be controlled programmatically. There have been two. It's orations of this module, Version one and version two. I'll be using Vision One for these videos, but diversion to module will also work. Let's take a look at how we connect the camera module to the raspberry pi. So if you take a look at the connector, you'll notice that on one end you can see there are some exports contacts, whereas any other end. It looks like a blue small surface. So when we look at the raspberry pi itself, this here is the camera connector. We want to make sure that this is pushed up or the way, So if I push this down to show you they couldn't get a good angle here, you'll see that it's in in place. They're firmly, and now I need to unlock it or push it up on once it's pushed up. Then I could proceed to insert the camera module. So I'm going to take the camera module and I wanna orient. Make sure that the pins are facing toe. What's the each day? Am I connector so I can insert the module into the raspberry pi slot, and once it's inserted, I want to make sure that it's for me down in, please, on how then proceed to push down the tabs to lock it into place. So here, I'm gonna push it down if you'll notice left and right on Now, module is securely and firmly in police. Once we haven't installed, we can proceed to connect the other components of the raspberry pi, and we will boot up our Asprey pie and in the next lecture will see how we configure our raspberry pi camera module. 62. Getting a Preview using the Pi Camera: Now it's time to take a look at what the respirator pie camera model can really do. And the we're going to go about this is that I created a series of scripts that were going to run. We'll go through them and it gives ah flavor for some of the capabilities of the camera module Onda. Hopefully, these will be helpful, and you can use the's in projects that you may incorporate be raspberry pi camera module. So without further ado, let's get going. A bit of housekeeping rules. Before we get started, make sure that there is a photos folder created in your Home Pie Downloads folder, and if you had followed along with some previous lectures, this was a step that we would have performed. But if you are just starting at this point in the course and you hadn't done any of the previous lectures, you want to navigate to the home by Donald's folder, and you can right click in here and create a new folder and call it photos. The reason that we're doing that is that all of the scripts that were going to run store images or video in this folder so you just want to make sure that it's there. So once that's done, let's navigato where we downloaded The resource is for the course on. We're going to go into the Cameras folder by Cam, and these will be the scripts that will be executing. So the very first script is the preview dot pie, and that simply activates the camera. Andi, that's opened up in the python I e. On. Once this gets open here, we're going to do a quick code review before we execute the script, so we'll get some background as to what's going to happen. So first we import the pie camera library on. This has a lot off teachers on all the functionality that we need to interact programmatically with the pie camera module on. Also, we import the Time library. We've seen this before where we are able to introduce the lease in our program. So initially at the beginning, we first set up the camera on. We do that by setting of year will cameras equal to an instance she ate the pie camera object. So now that we have a reference to that object, we can proceed. Teoh execute the functions that are available to us. So we do a camera that start preview on what this is going to do, it's gonna turn on the camera on display, a preview off video of whatever the raspberry pi cameras seeing and we are going to sleep for. This is 500 seconds. That's quite a long while. So let's change this. I'm just gonna put 10 seconds, so that's gonna keep that preview up for 10 seconds, and then we call camera dot stop review, and that's just going to stop it now. One point that I wanted to note is that when we're executing these scripts, you will not see it on my main screen because the output is sent to the each day. My port when, wherever doing a preview so you'll see the main screen where we're running the script, and I will include what was seen on the HTM aiport in a separate portion of the video. So hopefully that explains that clarification. When you're running this, you can't access the preview via V NC client, So that's just f y I. So now we're going to execute the script on we're just gonna click on the green arrow here on day as it's running as you'll see, the camera's gonna turn on and it's streaming in real time as the court is being executed. It's going to do this for 10 seconds. Andi. When it's done, it's going to shut off. So that essentially has how the start preview and stop preview methods of the pie calmer object work on. It just allows us to get a preview of what the camera seeing so very handy and very cool, and this can be used in your program to bring up a display of what your camera scene. 63. Capturing a Still Picture of Image with the Pi Camera: Now we're going to take a look at How do we Teak is still picture with a raspy by camera model. So there is a still underscore picture python file. Just gonna open that up in the part of 90. And when it comes up here, this is the cool. It's very short. Essentially at the beginning, of course. Import the pie camera library. We import the time. My worry on here, we have instance sheeted up. I camera object, sieving it to a camera variable. We don't do camera dot Start previewing again. These are all the steps that we have seen in the previous examples. We do asleep for five seconds on, then we capture. So the reason why we do asleep is just to make sure that once the script is running in five seconds, you'll see the light. Come on. That way you can position yourself however you want to picture to be taken on. Then we capture an image by calling camera that capture and we against pacified the path to where we want to store that them. And so we're gonna store to the home by downloads, photos solder on. We're just going to name an image dot g Peg. And then when we're done, we do camera dot stop on the score preview, and that's gonna turn off the camera. So that is essentially a script. So let's go ahead and run that. Now some going to click on the Green arrow here to top and remember, it's going to take it in five seconds. So here we go. All right, So that script ran on our photo should have been taken. That's no navigate to the folder to see where that image is and how it saved. So I'm gonna go up here to the photos folder, and it's called Image That J. Peg and I'm gonna open that up. Onda here it was right. So that was the image. I was taken there with our script. So again, programmatically were able to use python to take an image with our camera on again. You can see how you can incorporate this into your respirator pie projects 64. Capturing a Series of Photos with the Pi Camera: Now we're gonna take a look at How can we take a Siri's off pictures? And how can we do that? Programmatically And this may be like, for instance, if you want a time lapse video or you want to stoeger the taking of pictures over set periods, this is where this will be handy. So if you go to the Siri's underscore pictures that pie file, let's go ahead and open that up in our python i d. E. On. We'll do a quick code review before we executed, just so that you would understand what's happening. So the first few lines of court we have seen this before. But here's where it gets interesting. We do a four I and range five and in Python. This is how you do a for loop basically, so your loop starts, Andi. It increments every time at the end of the loop. So for here and Python, of course, when there's an indent that the notes the bounds of the scope of our four loop. So for the first, when we get until a loop were going to sleep for five seconds, then we're going to capture an image. This is the exact same line. Of course, we have seen in the previous example of how we capture an image specifying where we want the image to be stored, but not what we're doing here. We want the name of the image that we're storing to increment. So first, when we start off, I is going to be zero and you're going to see images. Zero dodgy peg. Then when we come back up, I increments Onda. We wait the five seconds and the new image is going to be images one dodgy peg and then it's gonna increment. 234 and so on. So that is what will happen on day. We'll have a Siri's off five images that will be created. So let's go ahead and run this and we'll take a look at our results in the downloads photos folder. So I'm gonna go ahead and click on the Green Arrow here, so we're gonna take a series of photos on as we're doing it. I'm just gonna do some goofy poses trying to stay still here as this is going on. OK, so we're all done on. Let's go ahead on and take a look at those images in our Donald's folder. So down moods, photos on here, you can see our image. Zero image. 1234 Let's check out zero on. I was goofing off a little bit as we're going through those photos so that you can see different snapshots in time. Here. My eyes were partially closed. So that's the image one, then here we have our image to I Okay, I was caught by surprise. There. Then we have image three. Okay, all thumbs up. Everything looking good so far and then image for All right, so there you go. So image for so this is really handy and that we can create sort of a time lapse effect on . We can programmatically determine when we want our photos to be taken. So hopefully you get the gist of this and see how it can be applied and taking start good photos in any sort of respirator by project 65. Recording Video with the Raspberry Pi Camera Module: next up, we're going to look at the record video python script. So we're just gonna open that in the python? I d. When it comes up, we're gonna take a quick code review. Essentially, what we're doing here is we are going to record video on. We're going to see if that actually toe video file that we can meet a playback. So this is really hand the in the keys where you want to record a certain period of video programmatically perhaps based on an event. So let's say you have detected motion from a sensor and you want to record video off whatever triggered the sensor. You could turn on your fight camera module. You can record that video and you can see what a file and you can review that leader on. So this is where this functionality would be useful. So I'm taking a look at the cord. Of course. We first import e bicameral library on then the time library. Andi. After that, we first and stand she it the pike camera object on, receive it in the camera, bearable. Then we do a start preview. Onda, we call the start underscore recording method And here's where we specify a path to where we want to store that video that's being recorded on We're here. We're going to start in the downloads photos on day. We're going to name the file video dot h 264 We're gonna sleep for 10 seconds. And what others? It's actually going to record 10 seconds off video for us. Then we are going to stop their recording and stop preview, which basically shuts down the camera. So that's what we're going to do. So now let's go ahead and take a look at what happens when we execute this script. So let's go ahead and click on the Green Arrow here to run the script on when we're running , the video is going to start recording by camera Module turned on. Remember, we're gonna see Vore record 10 seconds of video, and we're going to see that video in the Downloads photos folder and we call the video that age to 64. So that's where that's going to be saved. Now that the video has finished recording, let's go ahead, please. That video back someone who just stopped the script here from executing Andi to play this back. We're actually going to use the WiMax player, which is a player that is installed on raspberry pi should come preloaded once you have operated your system. So let's go ahead and open up a terminal session here on re going to type in Wow, Amex Clear. And now we specified the path to where we received our video file. So I'm gonna just do until they slash downloads. Remember, that gets us to the slash home slash pry folder downloads. We're going to go into photos on the name of it is video on. If you just type in V and tablets gonna want to compete for us. That's the name of the file on I'm going to hit. Enter on. As you can see, it plays back. The recording that we did was pretty quickly just went through actually think was paying twice the speed. So that was the video that received that video file on. But if you go to the it's navigate, bark up here to the photos folder here, you'll see that video dot each 264 That's a video file that we created. So this is very handy and you can use your raspberry pi camera module to record video on you can programmatically do so firm python, so that's a very cool, handy feature. 66. Using special effects with the Pi Camera Module: How are we gonna have some fun with our respirator pie Camera, Mario and we're gonna look at a series of effects. These are special effects that you can programmatically do with your camera on DWI. We'll see how in Python we can have some flexibility in the we that we take and process images with the raspberry pi camera module. So if you go into the effects folder, what we want to do, let's open all of these up. But once and that way we could run through them and talk through them in the pipa 90 so you can select left, click, drag and drop and select all those files. And I'm going to right click on open it up in the simple pipa 90. Once these are open, we're gonna execute them one by one. The first script is a just underscore brightness that by and this simply shoes that you can tweak the brightness variable on our camera, object by here setting camera dot brightness equal to 70 on this effects. How bright the images again. This code is the same that we've seen before. It's just that the only thing in this example is we're tweaking that brightness property on our by camera object. So I'm gonna go ahead and run this. It's going to first sleep for five seconds, take and store the image, and we're going to call it Bright Dodge a pig. So let's go ahead and run this Onda. It's going to force a five seconds Image was taken on. Let's go ahead and take a look when they open up another five explorer here on Let's go into downloads photos and there's are bright that Chip Beck file. So notice. If you look at some of the previous images that we have taken and let's just go and click on Image zero, it's a little darker here. We have tweaked the brightness, and you can see it's a little feet it out so you can use that brightness variable, too. Manipulate the brightness of your food to on DSO on, given certain lighting conditions, so that's some flexibility that you are afforded there. An ex script. We're going to run as the just brightness loop. We're going to go from 100 Onda. As we increment that loop, we're gonna add an annotation text to our image. You'll see that This is the way that we can add some text to our image. We're going to see brightness. And then 1234 all the way up to 99 would be enough for a loop on. We're gonna just sleep for 1/10 of a second in between there as we go through camera that brightness, we're gonna set that brightness property 1st 01234 all the way up to 99. So what you're going to see is the photo is gonna be very dark initially, and then it's going to get gradually brighter over time. So let's take a look at this in action. So I'm gonna click on the Green Arrow here to get things going to execute our script. Andi, you should see the image is very dark, and it should be getting brighter and brighter and brighter all the way up to full brightness. Up 99 on. Then I'll script to shed complete. So there you go. Hopefully saw that run. So that's really cool Weekend. We're tweaking the brightness in the loop on. This is just in the street. How you can go from that brightness property from 0 to 99 up 200 to change the brightness off an image that you're taking programmatically with your raspberry pi camera module next up room. Going to look at the a note it but pie script. And in here we are demonstrating. Actually, we have seen we just saw this how we can annotate on image and put some text on it. The only change that we meek from the traditional programs with taken and images that we have camera that annotate underscore text equal to And here we can put in whatever text that we want to write on our image. So I'm just gonna go ahead and run this This is gonna sleep for five seconds and then take the image and it should superimpose that text on it for us. So when I go ahead and click on the Green Arrow Onda, it should take our script run it executed, just took the image on Let's go ahead and check that image out So we save them to image Dr J. Pack that file on going to go in here and that's double click on image that gee peg our currency very goes so at the top. You see, I love raspberry pi. So that's the text. And you can put in any text that you want in their on and it seems it to the image. So that is a very cool and handy feature that we can use if you want to annotate. Maybe party time stamp, for example, when we took an image, a date, time stamp or if we want to start our images on, have some other sort of information written on them that is a useful feature to be ableto Hannity it images. So let's continue on to change resolution. Here you are able to specify the size of the image. So we're doing a camera, that resolution here we're making it 25 92 pixels wide by 1944 pixels high on. We can also tweet the Freedom Ritz here of the camera on how fast that firm it is. We said it to 15. Also, in addition to doing the preview, we are going to see even image at the Marks resolution. So from the video perspective, we're changing the for me to 15 and we're gonna preview that seemly for Emerita the video. That's taken from the camera on then, based on our resolution setting, we're also gonna see even image at Max resolution. In fact, those are the properties that would give you the marks resolution, find a majestic and take with the raspberry Pi camera module, so that would be our code. Let's go and run the script when I click on the Green Arrow so we should see the camera turn on the frame rate. Husband Alter. Remember, we said it to 15. Then we're gonna take that image on. But once that's done, let's check out that marks on the score resolution image that was created for us. I'm going to double click on it here. We're going to open it up. So as you can see, it is very, very large, very high resolution compared to the other images that we took on. That's pretty awesome that you can get that quality of detail of an image from the raspberry Pi camera module. The last one is the effects underscore. Loop on. This simply applies certain effects that images. So let's do a quick court reviewing this. Essentially, we are looping over the camera, that image effects collection that is provided for us and the different types of effects that we can apply to images and for effect and Commodore image effects. We first grab out the food's value in that list, and we set camera that image on the score effect equal to the effect that we extracted from that list that's available to us. Then we annotate text putting the name of the effect of the particular image. We keep that up for five seconds, and then we looked through all the effects. So this is will be interesting because you get a feel for what is available from the rest Reap I camera module on what effects library affords us. So let's go ahead and run this and check it out and see what we get. So I'm just gonna go ahead and click on the Green Arrow here on. As you can see, the first effect is cool em, boss, then, is another cool effect here that showing up this is the sketch one. Then there's pasteurized. As you can see every five seconds, we're going through a different type of effect so you can get some really cool cool affect showing up here. Color swap. We're actually right now. Remember where I know, teaching the image at the top with the name of the effect as we enter it over the image effects collection. So there's quite a few of them that's kind of let this run through his pastel onda saturation. Let's see what else we got so you can be pretty creative and create some cool looking images with the raspberry pi camera module. Onda. It's it's really awesome that the bicameral library allows us to do this, so this is no effect, basically, effect none and is a cartoon one, which is kind of cool that we have there. Here's a negative on, of course it takes out. You know, some of those brighter colors. Here's another affect the noise on Let's see what items are available to us. So there's an oil paint film, and they're quite a few that are available, and you can use thes depending on your application on the types of images that you want to provide for your projects, Onda create some cool looking backgrounds. Cool effects is a blur. He did the feast, too. Let's see what else is therefore So this is kind of cool. So again, in this program, we're just looping through. It has finished. He looked through all the effects that are available to us on board. This is really awesome. Onda. It's amazing that you can do this with the restaurant by camera module. Hope you enjoyed these samples on you can know incorporate them into your own restaurant by projects. 67. Why build an Amazon Echo Clone?: Now it's time to make a really cool project. With our osprey pie, we're going to create an Amazon Echo Clunes. How cool is that? It will would just like an Amazon echo device and will utilise the Alexa Voice Service. We will be making it from scratch with a raspberry pi, and I will show you how to do it step by step. Now you may ask an echo dot Cost about 50 bucks. Right? Onda Raspberry pi three costs about 35 but when you add in a speaker and a microphone, a power adaptor, etcetera, you make it up to 50 bucks or more. Why would you use a raspberry pi toe? Build this when you can get one pre built and ready to go for 50 bucks? Well, because it is fun, you will be learning some beneficial skills, and it is fun toe. Hack up the respirator pie and use it and creative ways. On another note, building an echo clue with your Asprey pi allows a lot of flexibility. Remember the GP? I opens on the raspberry pi. Well, you can create a custom Alexis girl with the Amazon developer account. You'll be creating and can use your respirator pie to control some device in your home connected directly to the GP. I opens or you can control some other device on your home network. The sky is the limit and the possibilities are endless. So without further ado, let's get this show started. We will first discuss what components we will need to set up our Amazon echo kun using a raspberry pi. 68. Alexa Clone Components Needed: Let's talk about the parts that we're going to need for our Amazon echo coun. So first off, we're gonna need our esprit pie, and I'll be using a respirator by three here for this project. Next, we'll need power adapter, and this is ah, five holds power adapter to power a respirator pie. We will also need if you're connecting to monitor and each day my cable. Then to actually hear Alexis speaking on day interact with her, you will need a speaker, and the speaker should have, Ah, 3.5 millimeter Jack that you could connect to the audio Jack Port on the respirator party. A keyboard and mouse would also be handy. Andi, I have a USB keyboard and mouse here that I will use on. Also, you'll need a USB microphone. Any type of USB microphone will do a swell as any type of speaker, but what I have that is convenient is a very tiny USB microphone. This is really handy. All you do is inserted into a USB slot. As you can see, there are a couple of perforations at the top. This is actually a microphone, and it's about six bucks and Amazon. I will put a link to this in the resource is for the project, but definitely a goodbye. And you can use this as a microphone for any other types of projects with a respirator pie . Last but not least, we will need an SD card on this SD card should be flashed with the raspy in Wes. So once that's flushed and ready to go, we will use that as a base to do our install of the software we'll need for our Amazon echo Clunes. So that's all we need on those are all the components that we will be putting together for our Amazon echo coun. 69. Setting up your Amazon Developer Account and Registering your Amazon Echo Clone: one till raspberry pi as wounded up. The first thing we need to do is to ensure that we are connected to the Internet, have over the WiFi icon Onda. Select the appropriate network that you want to connect to and provide the credentials and ensure that you're connected to a network. So once you are connected to a network, whether it be via WiFi or the Ethernet connection, let's go ahead and open a chromium browser. The first thing that we need to do is set up a free Amazon developer account. So to do that, we're gonna go to developer that amazon dot com on once we get to the speech, just bear in mind that the look of this pH may be slightly different from when the video was filmed. The general concept should remain the seam, and especially as we walk through the steps off, setting up the developer account and actually registering the device for our Amazon Echo clone. The screens may chin slightly, but the concept should remain, it seems, if something doesn't look right or it is completely incorrect, please send me a message. Let me know, and I'll be sure to try to keep the instructions as updated as possible. But bear in mind that these screens can change as Amazon continues to make updates to its site. So go ahead and click on signing. And if you do not have an Amazon developer account, you can click on the Create your Amazon developer account. There's a button below, and here you'll be asked to provide your name, email, address and password. Once you have entered that information you can click on, create your developer account. You may be prompted to verify your email address. Onda. Once that's done, your account should be good on Ready to Go. I already have an account created, so I'm just going to click on the sign in button here. So now I'm going to enter my email and my password to log in. Look, look, look insane in. And once we have loved in, I'm going to click on the developer console at the top, and no, the first thing we need to do is click on the Alexa Top but the top. So we click on the Alexa tile, and we're going to click on the get started button under Alexa Voice Service. So click on Get started. This is where you'll see a list of products that have been created by you that used the Alexa Voice service. I have a couple that have been created here, but this screen probably would look empty for you. There would be nothing wrong here. Go ahead and click on the create product button. And here we're going to provide some information about the products or the cocoon that we're going to create. So if it name that's enter by three underscore echo, you can feel free to go ahead and name it anything you want. But you can also go ahead and use the same naming convention that I use the product. I d. We're just gonna keep it. The Seimas A product name for simplicity by three underscore Echo, Please select your product type. This is an Alexa enabled device, so make sure you check that Alexa enabled device Radio button. Will your device use a companion up when check on new for product category? This is computing brief product description. You could put anything that you want in here. I'm just going to type in here. Pi three test device for how users will interact with your product. It's going to be hands free. So check that check box. We do not intent to distribute this commercially. So go ahead and check on no one, not Radio button. And this is not a Children's products to go ahead and check on no and hit next. Now we're going to create a security profile. So go ahead and click on, create new profile and you have to give you a security profile. A name. So we're going to name this by three echo profile. And for the description, Let's keep it the Seimas the profile name. So I'm just gonna copy that and peace that don't yet by three equal profile. You just want to make sure that you make a load of what that profile name is that you are setting up because you'll have to provide that information later on. So what I'm gonna do is I'm just gonna go and open up a text editor so we can make some notes as we go along. So under accessories gonna go to but text editor. And here we can put in our profile name all right, just so that we have it copy and peace later on. And I'm gonna go ahead and click on next. And the information that you see here is very important. So you want to copy this Onda? Make it handy because you'll have to use it later on. So, the security profile I d Let's go ahead and click on Copy Onda. We will piece that in our text editor. Right? If you scroll down, you also see the client I d and declined secret. These are two very important pieces of information that we need toe provide the German. So go ahead and copy the client. I d. We can piece that in our document. Andi, next up, let's copy. Decline in secret on again. We're gonna put that in our document. Okay? And now we have to and some allowed origins. So the first allowed origin that we're gonna set up is local host on Port 50 50. So it should be p local host Cool and 50 15. We're gonna add that and we're also gonna a second origen using the i p address of our respirator pie. So to get the I P address again, you can hover over the top. The icon for the WiFi connection of the top or your Ethernet connection. If you're connected by Ethernet on as you can see here, my I p addresses 10 001 of six. Just make a note of what yours is. So we're gonna add in that I p address 10 001 or six and we're gonna type in cool and 50 50 for the port of the end and click on add for return You URLs we're gonna type. And the 1st 1 would be local. Whose school in 50 50 http colon slash slash mocha host Golan 50 50 slash cold That would be our first allowed retune your URL and the next one will follow a similar pattern. But this time will be our i p address colon 50 50 slash code. Okay, so those are the two allowed origins that we need to enter and B two allowed return murals . So when you enter those, you have to check on the box to agree to the program requirements and click on finish. Okay, so now you would have gotten a confirmation that your product has been created and we can go ahead and click on, OK, and you should see that product showing up in your list. In my case, it's the second product that showing up here. If there are no products that you had previously created, that would be your first product that you'll see in your list. So now that all that administration set up has happened, indeed, develop a console and the next lecture will proceed to install git and the Alexa Pie software that we will need for Amazon echo clothes. 70. Installing Git and the Alexa Pi Software: Now we're gonna proceed to install get, which is the vision control software on that is going to allow us to pull down the Alexa Pie software firm, get hub. So go ahead and open up terminal. And now we're going to first, Let's update our system. So we're gonna do a suitable upped bash. Get update. So again, this is going toe. Go out and update all our repositories for us. Just give this a minute to run on this. Me take a while, depending on the state of the system. But once it's completed, we will run pseudo upped Dash, get in store, get okay. So get typically if you have one of the little visions of raspy and get should be installed . But we just want to make sure that we run this so you can verify that Get is in fact, on your system on it is up to date. So once get is installed, let's do a CD space slash o p. T. We want to navigate to the o. P. T folder. And now we're going to clone the Alexa Pie. Get repository. So we're doing pseudo get clone https Coolum and we're getting this from? Get hub slash Alexa dash Hi slash Mexico pie that get So what we're doing here is we're pulling down the Alexa Pie software from Get hub toe. Allow us to install that on our raspberry pi. Go ahead and hit, enter and precluding that repository and it was pulled down on its completed. So what's that is done? We proceed to run the Alexa Pie installation script so we can type in pseudo dot slash Alexa pie, and then we will do a slash source slash script and set up that s age is the name of the script that we want to execute. So let's go ahead and hit. Enter and this is gonna proceed to install the Alexa by software. For most of these options, you just wanna hit on enter to accept the defaults. So your os here it's prompting for WN going to go ahead and hit Enter devices, respirator. If I just go ahead and hit enter for which option do you prefer? Just go ahead and hit. Enter Andi for Would you late in store airplay support Gordon typing end for no there. Skip that one And we're just going to let this run. Now, this is probably going to take a few minutes, so I will go ahead on deposit. Video on DWI will pick it up again once we have reached the next prompt that will income toe in the installation process. Okay, so our installation process has been running for a while, and now we're at the point where we are prompted to enter the the vice I D. So you just have to enter that. If you remember, it was pie three underscore Echo or you can enter in here. Whatever you had specified was the i d for the device. If you had something that was custom, go ahead and hit on Enter. And for the profile description, let's type in the same by three underscore Echo hit. Enter to the security profile. I d. You'll want to copy that? I d remember that we saved off during the process when we're setting up. So I'll go back to my text document here. And this is the profile id'ing when a copy that on going to piece that in here. Right click pieced. And there it is Hit. Enter. It's going to ask for the client I d. So again, let's go back here and you want to make sure that we copy that and we can piece that in here. And lastly, it's gonna ask for the client secret. So let's get clan secret from our text document. Gonna pee. Sat in, hit, enter right. And now we are done. For the most part, with the actual installation, there is one last step that we have to perform before we can test out our Amazon Echo clone . And we will do that in the next lecture. 71. Alexa Clone Demo: Okay, so now that were installation has been completed. There is one final step that we're going to dive into, and we need to open up a chromium tab, and we need to navigate to the fallen. You are only gonna enter the i p. Address of our raspberry pi. Cool and 50 50. So again, you can get your i p interests by hovering over the icon on the top right here. So, minds is 10 001 of six. And he put a colon 50 50 hit. Enter. And what you will be prompted in here is to sign in to your Amazon account. So just go ahead and provide the password here signing. And here is where you allow your device that you're created access to the Alexa Voice Service. So here it says that the party three echo profile would like access to the Alexa Voice Service. You simply have to click on the allow button. And once you have given that consent, he should get a success message. You can close off your browser and you can go to your terminal and you can press controls see here because that is completed. So we have done our set up. We have given the Alexa Voice service permission to our device. And now let's start up the surface. Sorry. Prompt. We're gonna take men pseudo system CTL start Alexa fine dot Service. Right, So after entering that command, we just hit enter. And now we can proceed to try out Alexa. Alexa? Yes. What is the weather for? The more tomorrow Westlake, you'll see mostly sunny and can expect a high 47 a low of 35. Alexa? Yes? What is Falcon Heavy? Falcon Heavy is a reusable, super heavy lift launch vehicle designed and manufactured by Space X. So that is pretty cool. Our Amazon Echo cologne is working. We are losing the Alexa Voice Service. And as you notice, it's picking up every time I say the word Alexa and this is pretty cool. We can take this even further and create our own custom skills. Andi, have that interact with our raspberry pi and control any peripherals connected gp. I opens programmatically. We can create custom scripts, weaken control other devices on our home network or the network or connected to. So the possibilities are endless, but it's really cool that we're able to get Alexa working on our raspberry pi, so let's go ahead and have a lot more fun. Alexa, What is a raspberry pi? The rest they're implies a series of small single board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science and schools. And in developing countries, that's pretty cool. Alexa. What is 3596 multiplied by 287 3000 six, multiplied by 287 is more 1,000,032,052. That's pretty cool. So there you have it are respirator pie. We're using a USB microphone on Dwyer using a speaker that's connected. Toa are 3.5 millimeter audio jack to create an Amazon echo clue. I hope you like to this project, and it just goes to show the respirator pies really powerful, and there are amazing things that you can do with it. Alexa, who is the richest person in the world, the wealthiest persons Jeff basis. And that's fitting. How do you like that? Gays hope you enjoy this