Monday, May 25, 2020

Setting up a Raspberry Pi Zero W for Headless Use on Linux





This shouldn't take to long, and it's fairly simple to do. But if you're a novice and don't know about it, it might drive you crazy trying to figure this out.  And that's not the kind of crazy that is good for anyone.

This assumes that you've already figured out how you're going to get your Pi's SD card imaged.  I use BalenaEtcher myself.  There is dd and other methods a person can use.

Once the SD card is imaged you'll need to create an empty file on the Boot Partition called ssh.
Just right click in your file manager to create an empty document called ssh




Now you'll need to right click again to create a document, but you'll want to call it  wpa_supplicant.conf in that file you'll need your wifi network login information. Open that in Pluma or Nano or whatever your default text editor is, and put these lines below in in. Edited of course, with the correct SSID and Password for your Wifi network.  

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SenturyLink"
psk="Passw0rds"
}

Save this file, making sure that it's named correctly and in the \boot partition of the SD card. At this point you can eject the SD card from your PC.

Next you're going to SSH into the Pi from the terminal on you Linux machine.

What I found easiest was to log into my router and get the IP address of connected devices.  It might take a little time, so be patient. 



I have also used an Android App called Fing,  and you can also use nmap. But my router info does the trick for me. Once you have figured out what the IP address is for your Raspberry Pi Zero W, you need to open up a terminal to SSH into it.The Default username is pi and default password is raspberry

yourname@linuxpc:~$ ssh pi@192.168.1.17
pi@192.168.1.17's password:raspberry

If all has gone well, you've now successfully logged into your Pi Zero over Wifi!
For your initial log in you'll get a security warning. Say Yes to it.

Now would be a good time to run raspi-config  now that you've logged into it to change your default password, and expand the file system if needed.
You'll also want to run
Apt Update and  Apt Upgrade 
to get your machine up to date with it's packages.


That's pretty much it. You should have a Raspberry Pi Zero W that you can SSH into.

I've used this method a few times to get my Pi's setup for use with MotionEye. I've modified the original process with my own blog post on how to get Motion Eye installed and going, the original seemed to have a couple of steps out of order. 

I'd like to say that I took most of my information for this blog post from Mitch Allen's post about how to do this via Windows.



Raspberry Pi Zero setup for Motion Eye

First off, I'd like to say thanks to  Calin Crisan for his work on Motion eye. He's posted a few how to's on his Github page...