{"id":1891,"date":"2018-07-09T21:59:32","date_gmt":"2018-07-09T21:59:32","guid":{"rendered":"http:\/\/www.richa1.com\/RichardAlbritton\/?p=1891"},"modified":"2019-10-02T15:10:05","modified_gmt":"2019-10-02T15:10:05","slug":"setting-up-a-pi-zero-w","status":"publish","type":"post","link":"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/","title":{"rendered":"Setting up a Pi Zero W"},"content":{"rendered":"<h3>Intro<\/h3>\n<p>The Raspberry Pi Zero W is super good for a lot of projects and at $10 you can not do better than this mini Linux computer. However, it can be tricky to get things going due to the lack of Ethernet or full sized HDMI or USB port. You can get adapters, but we don&#8217;t need them anyway.<!--more--><\/p>\n<p>This tutorial will walk you through how to make an SD card boot disk and reconfigure it to connect over SSH using a regular micro USB cable just like the one your, non-iPhone, uses.<\/p>\n<h3>What You Need<\/h3>\n<p>1 x Micro SD card 8GB or larger<\/p>\n<p>1 x Micro USB adapter for your computer<\/p>\n<p>1 x Raspberry Pi Zero W<\/p>\n<p>1 x Micro USB data cable<\/p>\n<p>1 x Computer of some sort&#8230; to do all the work on.<\/p>\n<p>1 x Wifi connection<\/p>\n<p><strong>Software:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/etcher.io\/\" target=\"_blank\">Etcher<\/a><\/li>\n<li>An SSH client like\u00a0<a href=\"https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html\" target=\"_blank\">PuTTY<\/a><\/li>\n<\/ul>\n<h3>Make Your Boot Disk<\/h3>\n<p>The Raspberry Pi uses an SD Card for the Hard Drive and even the Operating system runs off of it. We will be using a version of Linux for the OS that is very small and runs quite well for this kind of thing. A 16GB class 10 Micro SD card will work quite well, but you can always use one with more storage if you like.<\/p>\n<p>First you will need to download the Raspbian Lite disk image for free from <a href=\"https:\/\/www.raspberrypi.org\/downloads\/raspbian\/\" target=\"_blank\">Rasperrypi.org<\/a>. This tutorial used Raspbian 4.14 (Stretch) Lite as it was the latest version at the time.<\/p>\n<p>Once downloaded, you will want to use Etcher to create a bootable Micro SD card. For help with this, check out <a href=\"https:\/\/www.raspberrypi.org\/documentation\/installation\/installing-images\/README.md\" target=\"_blank\">this helpful guide<\/a>.<\/p>\n<h3>Set Up the SSH connection<\/h3>\n<p>This is were things can get a bit tricky. The Pi Zero W has WiFi, but we need to connect to it in order to tell it how to connect to our WiFi. You may have noticed that there is no Ethernet or regular sized USB connectors. Well worry not because we don&#8217;t really need them. With just a few steps we can connect the Pi over USB using SSH.<\/p>\n<h4>Make some changes to the SD Card<\/h4>\n<p>Once your SD image is written to the SD card, you will have to make a few changes to the contents.<\/p>\n<ol>\n<li>First remove the SD card from your computer<\/li>\n<li>Now plug your SD card back into the computer<\/li>\n<li>The SD card should show up as a removable boot disk<\/li>\n<li>Open the SD card<\/li>\n<li>Scroll to and open\u00a0<em>config.txt<\/em> using a code editor like Notepad++<\/li>\n<li>Add\u00a0<span style=\"color: #993300;\">dtoverlay=dwc2<\/span> to the bottom of this file.<\/li>\n<\/ol>\n<p>The result should look like this:<\/p>\n<pre class=\"lang:python decode:true \" title=\"config.txt\">    # For more options and information see\r\n# http:\/\/www.raspberrypi.org\/documentation\/configuration\/config-txt.md\r\n# Some settings may impact device functionality. See link above for details\r\n\r\n# uncomment if you get no picture on HDMI for a default \"safe\" mode\r\n#hdmi_safe=1\r\n\r\n# uncomment this if your display has a black border of unused pixels visible\r\n# and your display can output without overscan\r\n#disable_overscan=1\r\n\r\n# uncomment the following to adjust overscan. Use positive numbers if console\r\n# goes off screen, and negative if there is too much border\r\n#overscan_left=16\r\n#overscan_right=16\r\n#overscan_top=16\r\n#overscan_bottom=16\r\n\r\n# uncomment to force a console size. By default it will be display's size minus\r\n# overscan.\r\n#framebuffer_width=1280\r\n#framebuffer_height=720\r\n\r\n# uncomment if hdmi display is not detected and composite is being output\r\n#hdmi_force_hotplug=1\r\n\r\n# uncomment to force a specific HDMI mode (this will force VGA)\r\n#hdmi_group=1\r\n#hdmi_mode=1\r\n\r\n# uncomment to force a HDMI mode rather than DVI. This can make audio work in\r\n# DMT (computer monitor) modes\r\n#hdmi_drive=2\r\n\r\n# uncomment to increase signal to HDMI, if you have interference, blanking, or\r\n# no display\r\n#config_hdmi_boost=4\r\n\r\n# uncomment for composite PAL\r\n#sdtv_mode=2\r\n\r\n#uncomment to overclock the arm. 700 MHz is the default.\r\n#arm_freq=800\r\n\r\n# Uncomment some or all of these to enable the optional hardware interfaces\r\n#dtparam=i2c_arm=on\r\n#dtparam=i2s=on\r\n#dtparam=spi=on\r\n\r\n# Uncomment this to enable the lirc-rpi module\r\n#dtoverlay=lirc-rpi\r\n\r\n# Additional overlays and parameters are documented \/boot\/overlays\/README\r\n\r\n# Enable audio (loads snd_bcm2835)\r\ndtparam=audio=on\r\ndtoverlay=dwc2<\/pre>\n<p>Now we need to open <em>cmdline.txt<\/em> using the same code editor. Be very careful how you edit this one because it is very picky about extra spaces and new lines.<\/p>\n<p>This is what it will look like:<\/p>\n<pre class=\"lang:python decode:true\" title=\"cmdline.txt\">dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=4d3ee428-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=\/usr\/lib\/raspi-config\/init_resize.sh<\/pre>\n<p>We want to add <span style=\"color: #993300;\">modules-load=dwc2,g_ether<\/span> after <span style=\"color: #993300;\">rootwait<\/span> with a single space on either side.<\/p>\n<p>This will end up looking like this:<\/p>\n<pre class=\"lang:python decode:true\" title=\"cmdline.txt\">dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=4d3ee428-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=\/usr\/lib\/raspi-config\/init_resize.sh<\/pre>\n<p>If you have trouble, just replace the text in these files with the final examples of code given.<\/p>\n<p>One last thing is to is create a new file named <span style=\"color: #993300;\">ssh<\/span> in the main directory.<\/p>\n<p>Just make a new file on the SD card and name it <span style=\"color: #993300;\">ssh<\/span> with no extension.<\/p>\n<p><span style=\"color: #993300;\">ssh<\/span> not <span style=\"color: #993300;\">ssh.txt<\/span><\/p>\n<p>This will tell the Pi Zero to enable SSH witch is normally disabled by default.<\/p>\n<p>Now just eject the SD card and place it into your Pi Zero.<\/p>\n<h4>Connecting to the Pi via USB<\/h4>\n<p>With the SD card installed, connect the Pi Zero W to your computer using a micro USB cable.<\/p>\n<p>You will want to plug the small end into the port labelled USB. It may take 2 minutes to install drivers for the\u00a0USB Ethernet device.<\/p>\n<p>Now you can SSH into the Pi using a program <a href=\"https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html\" target=\"_blank\">like PuTTY<\/a>.<\/p>\n<ol>\n<li>Select SSH as the Connection type and use\u00a0<strong>raspberrypi.local<\/strong> as the Host Name.<\/li>\n<li>Click <strong>Open<\/strong>\n<ul>\n<li>The first time you do this it will ask you to generate a key, just click OK or Yes to do so.<\/li>\n<\/ul>\n<\/li>\n<li>For <span style=\"color: #993300;\">login as:<\/span> enter <strong><span style=\"color: #993300;\">pi<\/span><\/strong><\/li>\n<li>the password should be <strong><span style=\"color: #993300;\">raspberry<\/span><\/strong><\/li>\n<\/ol>\n<p><em>Note: If you can not connect, make sure that the Micro USB cable is connected to the port labeled <strong>USB<\/strong> and not <strong>PWR<\/strong>. Also ensure that the other end of the USB cable is plugged into a USB port on your computer and NOT connected to a USB Hub. If you continue having trouble with a Windows computer, try installing <a href=\"https:\/\/support.apple.com\/kb\/DL999?locale=en_US\" target=\"_blank\">Bonjour Print Services<\/a>.<\/em><\/p>\n<h3>Let&#8217;s Get\u00a0Some Internet<\/h3>\n<p>Before we can start installing stuff, we need to get the Pi onto the internet.<\/p>\n<p>From the SSH window that you just opened, run the following command:<\/p>\n<pre class=\"lang:default decode:true\">sudo nano \/etc\/wpa_supplicant\/wpa_supplicant.conf<\/pre>\n<p>This will open the network configuration file so we can add our WiFi user name and password.<\/p>\n<p>Add the following to the end of the file:<\/p>\n<pre class=\"lang:default decode:true\" title=\"wpa_supplicant.conf\">network={\r\n    ssid=\"HomeOneSSID\"\r\n    psk=\"passwordOne\"\r\n    priority=1\r\n    id_str=\"homeOne\"\r\n}\r\n\r\nnetwork={\r\n    ssid=\"HomeTwoSSID\"\r\n    psk=\"passwordTwo\"\r\n    priority=2\r\n    id_str=\"homeTwo\"\r\n}<\/pre>\n<p>Replace the quoted text with relevant information then save and close the file.<\/p>\n<p>Run\u00a0<strong><span style=\"color: #993300;\">sudo reboot<\/span><\/strong> to restart the Pi and connect to the internet.<\/p>\n<p>You will have to restart your SSH connection and login to the Pi like before.<\/p>\n<p>Now\u00a0run the command\u00a0<strong><span style=\"color: #993300;\">ping google.com<\/span><\/strong> in your reopened SSH window.<\/p>\n<p>If all goes well you should get some Data that looks like this:<\/p>\n<pre class=\"lang:default decode:true \">pi@raspberrypi:~ $ ping google.com\r\nPING google.com(sea15s08-in-x0e.1e100.net (2607:f8b0:400a:804::200e)) 56 data by tes\r\n64 bytes from sea09s17-in-x0e.1e100.net (2607:f8b0:400a:804::200e): icmp_seq=1 t tl=54 time=13.4 ms\r\n64 bytes from sea09s17-in-x0e.1e100.net (2607:f8b0:400a:804::200e): icmp_seq=2 t tl=54 time=14.1 ms\r\n64 bytes from sea09s17-in-x0e.1e100.net (2607:f8b0:400a:804::200e): icmp_seq=3 t tl=54 time=13.4 ms\r\n64 bytes from sea09s17-in-x0e.1e100.net (2607:f8b0:400a:804::200e): icmp_seq=4 t tl=54 time=17.4 ms<\/pre>\n<p>This means that\u00a0the Pi is connected to the internet now and we can start installing stuff. If you do not have connectivity, check the <span style=\"color: #993300;\"><em>wpa_supplicant.conf<\/em><\/span> settings and ensure that they are correct. Then check your WiFi for network issues.<\/p>\n<h3>Time For Some Updates<\/h3>\n<p>As always let us start by doing some updating on the Pi. All of this will be done through the SSH window that we are now using to remotely connect to the Pi. It is easy to just copy the commands from this tutorial and right click your mouse in the SSH window to past it there and press the Enter key. Otherwise I hope you are good at typing&#8230;<\/p>\n<p>First let us run these two commands:<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get update\r\nsudo apt-get upgrade<\/pre>\n<p>This will take a few moments depending on how fast your network is. Once the first is finished, press the Enter key to run the next command. You will have to type Yes at the beginning of this one, then go get some coffee or a snack.<\/p>\n<p>Now you are all set to do all kinds of fun stuff with your new $10 computer.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1891\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1891\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Intro The Raspberry Pi Zero W is super good for a lot of projects and at $10 you can not do better than this mini Linux computer. However, it can be tricky to get things going due to the lack of Ethernet or full sized HDMI or USB port. You can get adapters, but we &hellip; <a href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Setting up a Pi Zero W<\/span><\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1891\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1891\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-a-pi-zero-w\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":1922,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[164,79],"tags":[15],"jetpack_featured_media_url":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-content\/uploads\/2018\/07\/33209069075_99e08d84ec_b.jpg","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5AhH6-uv","_links":{"self":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1891"}],"collection":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/comments?post=1891"}],"version-history":[{"count":3,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1891\/revisions"}],"predecessor-version":[{"id":1924,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1891\/revisions\/1924"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/media\/1922"}],"wp:attachment":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/media?parent=1891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/categories?post=1891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/tags?post=1891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}