The New Method to Setup Raspberry Pi Zero (2021 Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys in this video we're going to show you the new way to set up your raspberry pi zero wh we're going to show you how to set it up without using any peripheral devices such as a keyboard or mouse this is typically referred to as a headless setup so we got raspberry pi going on i'm over caffeinated what could possibly go wrong let's get started okay so the first thing we're going to want to do is download raspberry pi imager from the raspberry pi website and this software lets us flash the operating system to our micro sd storage card okay so we need to get the raspberry pi operating system onto our sd card so the software that we want to use is called raspberry pi imager and we're going to get that from raspberrypi.org so let's take a look over there and then we're going to click on software basically what you're going to see here is if we go to all download options so these are the actual raspberry pi operating systems and we're going to want that but we also need a way to get the os onto the sd card we need a flasher and so we're going to use raspberry pi imager and this is going to bundle everything together so let's go ahead and download raspberry pi imager for our system i'm going to download for mac os okay so now we should have raspberry pi imager looks like we do i'm gonna load it up if you like this video go ahead and click that like button so we can get it out to a wider audience thank you okay so this is going to let us flash the operating system to our sd card we need to connect our sd card to our computer right here i have an eight gigabyte micro sd card so there's different ways to do that you can use one of these guys this is a sd card to usb connection or you can use a converter here this is sd to sorry micro sd to sd and my computer has an sd reader so i'll go ahead and use this but use what makes sense for your setup so i'm going to go ahead and insert the micro sd into the sd chip converter here and i'm going to throw the sd into my computer here quick note here if your micro sd card is over 32 gigabytes then you may need to format it to the fat32 file system type and that's pretty easy to do both microsoft and mac have native formatting solutions that you can use to do that but if your sd card is smaller than that you shouldn't need to worry about that now that we have our sd connected to our computer let's just double check that it is showing up as a listed drive so we're going to do new finder on mac so this is our sd card it's called boot and so that's fine it's connected it's recognized by the computer so let's go through the steps here using imager we're going to first do choose os um we're gonna do the out of the box raspberry pi uh recommended 32-bit so we're gonna choose our storage here we want my eight gigabyte micro sd card be very cautious here because this will overwrite any connected drive so if i were to click this which is my one terabyte samsung drive i would overwrite everything on my drive so be very careful here so we're going to select the eight gigabyte and then we're just going to go ahead and select right okay looks like we're all set that probably took about four minutes so we're gonna come back over to finder here okay it looks like it ejected the drive proactively for us so because we're going to do a headless setup here we're actually going to want to modify the operating system so let's actually put it back into the computer so that we can add some files to the drive okay and it's going to show up again as boot and we can just click on it and now we can see these files here so that's what we'd expect so to enable a headless setup we need to do two things we need to turn on ssh by default because by default it's disabled and then we also want to supply our wi-fi credentials so that when it boots up it immediately can connect to our wi-fi and become available locally on our network so the way you do that is by adding two files into this boot directory here so what i want you to do is download those files from the description of this video they're pre-formatted and and then we're going to edit the files and put them in here so let's start off with downloading the ssh file okay so because this is a headless setup we want to add a flag to the operating system that says immediately enable ssh so that we can connect to it so the way we do this is by adding a special file into the boot directory the ssh file is super simple it's literally just a file that has no content and its mere presence in the directory is going to signal to raspberry pi to enable ssh so let's go ahead and download that file okay so i'm just going to go ahead and click this link i just stood up the file on google cloud storage so folks can download it so what we should do is the file is called ssh and we're going to download it directly to our boot drive here so let's go ahead and click save and then just to make sure that that is working correctly let's pull up our finder again and if we navigate to the boot drive we should see a file called ssh and this is just an empty file so we don't have to do anything with that um but now we want to download the wi-fi file we also want our device to immediately connect to our wi-fi network when it starts up and the way you do this is by adding a file to the boot directory with your wi-fi credentials okay and then we're going to download a file called wpa supplicant which is used to tell raspberry pi what our wi-fi credentials are so it can connect to our wi-fi so for this file let's actually download to a different directory than the boot drive because you can't edit files on the boot drive so i'm going to download to my desktop and then i what i'm going to do is i'm going to find the file on my desktop so let's see here they modify today all right so i'm going to open this i'm going to right click it and open it in my favorite text editor and again what this is doing is it's supplying our wi-fi credentials so ssid is your network name that's the same value that shows up here so for me it's going to be yoda hyphen 7 so i'm just going to type that in here oh go to iphone 7. and then psk is going to be your password raspberry pi 0 cannot connect to a 5g network out of the box it has to connect to a 2.4 g network so a lot of routers these days are dual band so make sure that your network is 2.4 gigahertz in some cases once you connect to the 2.4 gigahertz you can then update the firmware on the raspberry pi and then it can connect to a 5g network um that's not true for all devices though so make sure you're connecting to a 2.4 gigahertz network or it will not work so actually i'm going to use my 2.4 g network so let's do yoda hyphen 7 and then space 2.4 capital g and then i'm going to go ahead and do file save and then i'm going to come back over to my finder here okay so now we're going to drag the file into our boot drive here and okay great so we can see it is on our boot drive let's just open it so we can verify that it has the data that we expect it does so we're looking good here now we can eject our drive and insert it into our raspberry pi so i'm going to go ahead and click eject on the boot drive okay so now that the os is flashed we can go ahead and pull this out and then i will also remove the micro sd card and we're going to insert it into our raspberry pi zero okay so what we're going to do now is just power up the raspberry pi zero so i'm going to take the power cable here and insert it into the far most jack which is reserved for power and we should see a green led begin to blink as the device powers up so now we need to validate that our raspberry pi is in fact connected to our local network so i actually just logged into my router's home page here the admin portal and most routers offer this capability where they will list connected devices just so you can kind of audit that the devices that are connected to your network are the expected devices okay and then when i list the connected devices i see raspberry pi here that is the default host name you can change that if you need i might also see the ip address so this is what i would expect and it's connected to my 2.4 g network because i have a dual band router and as i mentioned it will not connect to 5g so make sure you keep that in mind so another way to validate that it's on the network if you can't find your router login page is to pull open a terminal okay so i'm just going to open a terminal here expand this guy we should build a ping the host name so i'm going to do ping raspberry pi and you can see it is responding to uh ping traffic i i see mp traffic so i'm going to do control c to terminate that um quick caveat if you're on a windows machine a windows 10 machine you're not going to have a linux terminal to do with like the ssh and the ping and and that sort of thing so what you're going to want to do is download the linux subsystem if you're on a windows computer you want to download the linux subsystem and once you do that and have it enabled i think you can use like the windows store to download ubuntu or one of the linux operating systems it's actually a really great feature of windows 10 which is you can run a linux container and that linux container will give you a linux terminal which is similar to the unix terminal that i'm running here on my mac and when you have that ready you can do exactly what we're doing here with ping ssh and that sort of thing okay so we're going to show you a couple other ways to connect remotely to your raspberry pi so first we're going to want to connect over ssh and because we dropped the ssh flag in the boot drive we can go ahead and do that right now so i'm just going to do ssh the default username on raspberry pi is pi and then we need to supply the host name so we're going to do pi at raspberry pi and then it's going to ask us only on the first connection if we want to use the rsa fingerprint we're just going to select yes okay so i have fingerprints from previous connections and it's saying that there's a discrepancy here i'm going to just proceed through that it's prompting me for a password so out of the box the password is raspberry okay and now i'm connected if i do ls just to list um everything so so so raspberry pi os is a debian linux variant so essentially it's just a linux operating system so things will look pretty standard so the next thing we're going to want to do is update the packages on the operating system so i should be able to do apt get update oh okay so it's saying i don't have proper permission so what we can do is we can elevate ourselves to root so the way we do that is sudo su dash okay so now i'm a root user and we want to update the operating system so we're going to do apt get update and now we're just updating that debian operating system and it's good to do this right away when we log in okay and then we can run apt-get upgrade as well okay so apps get upgrade finished running so now we know we have the latest and greatest on the operating system and i'm going to just quickly okay the next thing we want to do is change some of the default settings you know if everyone knows our default username and our default password then we're kind of exposed people can connect to our device i mean they have to be on our network but we still probably want to swap out the default usernames and passwords so the way we can do that is by running razpi hyphen config and that will open up this utility here so what we can do is we can come over to system options and then we can do a hostname and we can change the hostname so i can do so i'll do pi underscore refactored that will be my new host name and then let's see what else here right so if we wanted to add a new network we could do that here i'm not going to do that um if we wanted to change our password we could do that here i guess i will do that okay so i just changed my password now if you wanted to modify your username meaning change it from pi to something else you could do that but you can't do it from this menu here you have to do that from the command line uh adding a new user the same way you would with any linux operating system okay and then unfortunately um not all of those settings will take effect immediately the password change will but the host name won't until we do a reboot so i'm going to do sudo reboot this is going to shut down the pi and restart it obviously the connection drops as well okay so now we can see um the raspberry pi is connected again and it's using the new host name oddly enough the underscore looks like it was taken out um i'm not sure if that's right let's go ahead and ping so i'm going to do ping um pi refactored yeah nothing so let's do let's take the underscore out okay so you can't do an underscore apparently that's fine so the hostname is now pi refactored and now what we can do is ssh pi at pi refactored and then we should be able to connect just fine and this i'm going to use my new password all right and we're logged back in another thing you can do is if you want to save the connection you can do shell new remote connection just select ssh do plus provide the host name in this case it's pi refactored and then uh user and then yeah that's it so the command is ssh pi pi refactored and we can just test it out here and that looks good okay so now we have a saved connection it's kind of like putty so if you're on windows you can download putty and you can save the connection as well and i just want to prove you can do that on mac as well so next if you want a full gui desktop experience with your raspberry pi you can use remote desktop and connect using the vnc protocol okay so to connect over vnc we need to enable that on the raspberry pi so we're going to do raspberry er sorry raz pi can config and then we're going to do interface options and then for vnc would you like the bnc server to be enabled yes so now when we try to connect through the vnc protocol to our raspberry pi device the raspberry pi device has a server listening for inbound traffic okay so to be able to view our uh raspberry pi's actual gui and desktop we're gonna have to use a vnc client okay so i'm gonna download realvnc and just make sure you're getting the viewer software looks like it works on all platforms so should be able to use this for windows as well okay so i'm going to put the address in here which is using the ip address that we found this is a local terminal if i do dig i'm sorry the new the no the new host name is pi refactored all right so i believe this is going to be my ip address let's try this okay [Music] and then we might have to adjust our local max settings so that we can actually control and screen share properly let's not give that one all right so i'm just giving vnc okay and now you can see we're controlling um our actual raspberry pi so let's see here we're gonna set the country to unite set the country to united states language is american english this one we want new york for me use english language keyboard set the country code and uh language properly because there's some weird quirk with uh raspberry pi where if you don't set it properly i think wi-fi can be affected so okay so right here on the left we have the vnc remote desktop connection where i can actually interface with the gui on on the right we have the ssh connection and what i want to show you is how the two correlate so like if i navigate to the desktop and that's the directory being shown here i can create a file right touch test dot txt you can see it shows up on the desktop see these are just two different ways to interface with the operating system there's the gui and then there's the cli the command line utility and then real quick if you're on windows you another option is to use remote desktop it's a native application that should be able to connect to vnc servers okay and then to wrap this all up let's just do one quick little fun project which is to host a website on our raspberry pi so the easiest way to do this in my mind is to choose a server software i like nginx so i'm going to do apt get install nginx it's asking me to elevate to root so i'm going to go ahead and do that and then i'm going to retype that command and i'm going to install nginx so this downloads the nginx server software and it also should stand up a website that we can visit when we hit the ip address of our raspberry pi okay let's just validate that the website is serving up traffic on localhost so we're just going to do curl localhost okay this is the out of the box nginx website so in theory let's open a new local terminal let's grab the ip address of our raspberry pi so i'm going to do oops i changed the hostname to pi refactored so this is my ip address so from here if i do curl on the ip address i get my website so this is making me think if i um open a new incognito window incognito window and go to this ip address boom we're hosting a website from our raspberry pi and just to confirm that that we are in fact hosting that website um i'm gonna go to the html directory so i'm going to install a text editor because i want to be able to edit text i'm going to use vim so app get install vim and i'm going to use vim [Music] and i'm going to remove the h1 element and add a new h1 element okay and i'm going to go ahead and save that now when we go back to our website boom and i just want to make a quick plug for all the other really interesting projects that you can do with raspberry pi you can buy add-ons and extensions and modules that can do all sorts of things gps and robotic arms and things like that so there's a whole lot of things that you can do with raspberry pi and i'd urge you to take a look at some of that as always if you're interested in learning about the latest and greatest around emerging tech ai iot google cloud platform go ahead and subscribe to this channel as i am releasing content around those topics on the regular anyways thank you for listening
Info
Channel: Refactored
Views: 16,226
Rating: undefined out of 5
Keywords: raspberry pi zero w, raspberry pi, raspberry pi zero, raspbian, raspberry pi 3 b+, arduino vs raspberry pi, arduino, arm cpu, small computer, raspberry pi tutorial, raspberrypi.local, how to configure raspberry pi 3, raspberry pi 3 setup on mac, mac os on raspberry pi 3, install raspbian on micro sd card, install raspbian, gpio raspberry pi 3, pi zero, pi zero w, raspberry pi projects, raspberry pi zero setup, zero w, raspberry pi 0, vnc, ssh, remote desktop
Id: yn59qX-Td3E
Channel Id: undefined
Length: 23min 59sec (1439 seconds)
Published: Sun Sep 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.