Raspberry Pi 4 (8GB) Setup for Windows Users

A Raspberry Pi and a laptop computer in the background
Raspberry Pi 4 (8GB version)

This walkthrough will guide you through how to set up a Raspberry Pi 4 using Windows.

DEPRECATION NOTICE: Since April 2022, the Raspberry Pi Operating System has been updated to exclude the default username-password combination of “pi” and “raspberry.” For updated setup instructions, please see my update post: https://unboxing-tomorrow.com/major-login-change-to-raspberry-pi/.

…or check the official Raspberry Pi website.

  • Some users connect a monitor, keyboard, and mouse to their Raspberry Pi.
  • Other users want a “headless” Raspberry Pi that can be operated from a remote desktop computer.

This guide is intended for both situations.  If you have a monitor and input devices to connect to your Raspberry Pi 4, simply ignore any section below intended for headless setup.


Notice of Non-Affiliation and Disclaimer: As of the publication date, we are not affiliated, associated, authorized, endorsed by, compensated by, or in any way officially connected with the Raspberry Pi Foundation, or their owners, subsidiaries or affiliates.

External Links: Links to external web pages have been provided as a convenience and for informational purposes only. Unboxing Tomorrow and Voxidyne Media bear no responsibility for the accuracy, legality or content of the external site or for that of subsequent links. Contact the external site for answers to questions regarding its content.

Note that guides like this eventually become dated and obsolete. This is presented for informational purposes only, and you should back up any data you can’t afford to lose.  For any conflict between the instructions you see here and the official instructions from the Raspberry Pi Foundation, refer to the official source.

Objectives

By the end of this walkthrough, you should be able to access the Raspberry Pi 4 terminal and the graphical desktop regardless of whether you run a headless system or not.  To reach that objective, we will:

  • Understand the materials and software required
  • Prepare your work area
  • Download the Raspberry Pi Operating System (OS) and Imager Tool
  • Write the Raspberry Pi Operating System to a microSD card

For the “headless” Raspberry Pi 4 setup, we will close by:

  • Enabling Secure Shell (SSH) connections to the Raspberry Pi 4
  • Programming your Pi to join your own wireless network
  • Finding the network address of your wireless router and your Raspberry pi
  • Using the PuTTY application to access the Raspberry Pi 4
  • Using the xrdp application to access the Raspberry Pi 4’s graphical desktop
A computer sitting on top of a table

Description automatically generated
Figure 1: A Windows 10 Laptop (Left) Connected Wirelessly to a Raspberry Pi 4 (Right)

Material Requirements

In addition to the Raspberry Pi 4 itself, the items listed below are required unless marked otherwise:

  • Internet connection
  • 1 wireless router (for headless setup: you must have administrator privileges and passwords)
  • 1 microSD card (8 GB to 32 GB capacity recommended) (this procedure WILL erase its content)
  • 1 microSD card reader
  • 1 Windows desktop or laptop
  • 1 USB-C Power Source for the Raspberry Pi (such as a phone charger)
  • (Recommended) Anti-static wristband
  • (Recommended) Anti-static work surface
  • (Optional) Spare HDMI monitor
  • (Optional) Micro HDMI cable (Cable end should match your monitor)
  • (Optional) Spare Keyboard and Mouse

Power Supply Note: According to the official Raspberry Pi 4 Model B Safety and User Guide included with Raspberry Pi 4, your 5-volt USB-C power supply should comply with relevant regulations and be rated for a minimum of 3 amps.

Software Requirements

This walkthrough is based on Windows 10, 64-bit.  If you are using a different OS such as MacOS or Linux, the procedure will be quite different.

  • Windows Remote Desktop (this application is included with Windows 10 by default)
  • Web Browser
  • (Recommended) Administrator rights on your desktop/laptop
  • (Recommended) Notepad++ Text Editor
  • (Recommended) Anti-malware software
  • (Recommended) File unzipping tool to open .zip files

Later, we will install the following software:

  • Windows: Imager.exe
  • Windows: PuTTY (headless setup only)

STEP 1: Get a microSD Card

As with previous Raspberry Pi models, you need to buy a microSD card.  The recommended minimum capacity for the card is 8 GB.

Card recommendation: In my case, I plan to do video processing on the Raspberry Pi 4, so I will be using a high-endurance microSD card.  But this is not required.

(Recommended) Prepare an Anti-Static Work Area

Digital electronics are vulnerable to electrostatic discharges (ESD) from your body and surrounding objects. 

To help maximize the life and reliability of your Raspberry Pi 4, you should not touch it unless you are grounded with a reliable ESD wrist strap from a reputable manufacturer.  The strap should be connected to a safe, reliable earth ground connection.  This will bleed away your body’s electrostatic charge through a large-valued resistor. 

In my case, the work bench is also made of a static dissipative material, which is also connected to earth ground.

Download Raspberry Pi OS and the Imager.exe

If your Raspberry Pi shipped to you in a blank state with no microSD, then you need to use Windows software to write the Raspberry operating system to the microSD card…

Visit the official Raspberry Pi Foundation website (https://www.raspberrypi.org/downloads/).

Figure 2: Options for the Raspberry Pi Imager Tool

Select the Raspberry Pi Imager that best matches your operating system.  In this example, it is the Windows option in Figure 2 above.

Next, select “Raspberry Pi OS (previously called Raspbian)” and follow the links to download the Raspberry Pi OS image.   As of June 2020, the image file is a .zip file that is 1 GB compressed, and 3.6 GB when uncompressed.

Figure 3: Raspberry Pi Operating System (32-bit) Option

Above, I am downloading the May 2020 version of Raspberry Pi OS (32-bit) with recommended software.  There are also simplified versions available, as well as a 64-bit version that is current in beta. 

(Recommended) Scan All Files

As with anything else you get from the internet, scan everything with your favorite anti-malware tool before you put them to use.  I recommend this as a general practice.

Mount the microSD Card

If you haven’t already done so, connect the microSD card to your personal computer.  Many computers need a card reader to do this.

Take special note of the microSD card’s drive letter or its path.  If you don’t, you might accidently overwrite some other connected device in the next step.

Now is also a good time to remove any other devices (smartphones, cameras, etc.) so you cannot misidentify them as the microSD card we will erase.

Format (Erase) the microSD card

Verify the drive letter of the microSD card.  In the next step, the contents of this microSD will be erased.  This cannot be undone.

In Windows 10, use the File Explorer to right-click the drive. Then navigate to “Format.”

Figure 4: Windows 10 is Ready to Format (Erase) the microSD Card Mapped to G:

Set the following:

  • File System = FAT32 (Default)
  • Allocation unit size = 32 kilobytes
  • Quick Format = unchecked

Once again, verify that you have selected the correct microSD device you wish to erase. 

Click “Close” to abort or click “Start” to erase.

When the formatting is complete.  Close any notification window and then close the formatter.

Write the Raspberry Pi Image to the microSD Card

Unzip the operating system file.

Then run the imager.exe program.

A close up of a sign

Description automatically generated
Figure 5: The Imager Program for Window (Left) and the Zipped Operating System Image (Right)
Figure 6: Raspberry Pi Imager Application Installer

Follow the Imager setup wizard instruction until it completes the installation.

When installation has finished, run the Imager application.

Figure 7: The Raspberry Pi Imager Application for Windows 10

Click “CHOOSE OS.”

We have already downloaded the .img file, so select it by navigating down to “Use custom.”

Figure 8: Select the Raspberry Pi OS Image Here

Now select “CHOOSE SD.”

Figure 9: List of Writable Generic SD Cards

The application will scan for storage devices that look like valid targets.

Select the microSD card that you erased in the previous step.

Figure 10: Ready to Write

Now that the Operating System and SD Card are selected, click “WRITE” to overwrite the microSD card.

Figure 11: Writing in Progress

When the writer finishes…

  • If you have a monitor and input devices for your Pi: congratulations!  You have completed the setup.  Eject the microSD card, and then insert in the microSD card slot on the Raspberry Pi.  Your Pi is now ready for your monitor and input devices.
  • If you are doing headless setup: keep your microSD card plugged into your Windows computer for now.

(Headless Pi Only) Verify the microSD Card is Readable

In my case, Windows 10 was a little weird about the drive, and threw an error when I tried to view the microSD contents.  To fix this error, eject the microSD or unplug by force if you have to.  Then re-insert the microSD card.  It should be visible now.

(Headless Pi Only) Configure the microSD for Remote Access

To make your Raspberry Pi usable without a monitor, you will need to create two new files on the microSD that we just prepared.

Navigate to the root directory of the microSD card.  This is directory containing files like config.txt.

Figure 12: Viewing the Root Directory of the microSD Card

Create File “ssh” on the microSD Card

Open a plaintext editor like Notepad++.  Create a blank text file called “ssh” and then save it to the microSD card’s root directory.  The ssh filename should be in all-lowercase letters.  The filename must not have an extension (like .txt or anything else).

Create File: “wpa_supplicant.conf” on the microSD Card

Now its time to create the file that will tell your Pi how to connect to your wireless network.

Here, you need to use specialized plain text editor like Notepad++. The ordinary version of Notepad include with Windows will probably cause problems later.

Figure 13: A Partially-Completed wpa_supplicant.conf file.

In Notepad++, type the following text:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>
network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}

Complete the country, ssid, and psk fields.  SSID is your wireless access point’s custom name.  PSK is your wireless password.  All these fields are case-sensitive.  To see an example, see Figure 13 above.

In Notepad++, select UTF-8 encoding and the Unix (LF) line format.  You can do this by double-clicking the areas highlighted green in Figure 13 above.

Because I am based in the United States, I have used the line: country=US.  For other locations, consider checking Wikipedia’s ISO 3166-1 country codes in the link below, and then use the 2-letter code that is best for you…

https://en.wikipedia.org/wiki/ISO_3166-1

In the event of any trouble, know that the Raspberry Pi Foundation maintains a wpa_supplicant.conf tutorial at: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md.

Save the text as file “wpa_supplicant.conf” on the root directory of the microSD card.

Figure 14: Files “ssh” and “wpa_supplicant.conf” Successfully Saved to the microSD Card

With ssh and wpa_supplicant.conf, you are ready to check your Wi-Fi.

(Headless Pi Only) Find your Router’s Address

Next, we will need to figure out what IP address of the wireless router (called the gateway here).

Do a Windows search for the command prompt, then launch it…

Figure 15: The Windows 10 Command Prompt (cmd)

Find the IP address of your default gateway (likely your cable modem) by entering “ipconfig.”

Figure 16: The Gateway Address

Memorize or write down the Default Gateway address.  This address will be a sequence of 4 numbers.

Mine happened to be 10.0.0.5, but yours could be anything.

(Headless Pi Only) Put the microSD Card in the Raspberry Pi

Eject the microSD card from your Windows computer.  Insert it into the microSD card slot on your Raspberry Pi 4.  You may also wish to optionally connect the Pi camera if you want to.

Plug the Raspberry Pi 4 into the USB-C power source.  You should see if small red LED illuminate on the Raspberry Pi 4.

Give your Raspberry Pi 4 about 2-5 minutes to boot up and join your wireless network.

(Headless Pi Only) Find Your Pi’s Network Address

Open a web browser.

Take the Default Gateway address you found earlier.

Type in the Default Gateway address into the web browser address bar.  You should enter it exactly as it appeared in the Windows Command Prompt.

Figure 17: List of Connected Devices, As Shown by a Wireless Router

Your web browser should show your wireless routers setup options.  Every router model is unique.  If things don’t look exactly like they do in Figure 17 or Figure 18, that is OK.

Enter your own router’s username and password.  Then look for a list of connected devices.

If you can even see the raspberrypi device on your network, that is a good sign!  It proves your wpa_supplicant.conf editing was accepted!

Figure 18: The IP Address of my Raspberry Pi 4

In Figure 18 above, we can see my Raspberry Pi 4 was assigned address 10.0.0.119 by the wireless router.

(Headless Pi Only) Download and Install PuTTY for Windows

To remotely access the Raspberry Pi, we need the PuTTY application.   According to putty.org,  PuTTY is “an SSH and telnet client, developed originally by Simon Tatham for the Windows platform.”

Windows 10 Home Edition (64-bit) doesn’t include PuTTY by default, so download PuTTY from: https://putty.org/ if you don’t have it already.

Figure 19: The PuTTY Website

As of June 2020, the latest PuTTY is in version 0.73 (released on November 29th, 2019).  I will install the MSI Installer for Windows as: putty-64bit-0.73-installer.msi (a 3 megabyte download).

As before, scan your downloaded PuTTY installer with your favorite anti-malware software.

If everything looks good, run the PuTTY installer.

Figure 20: The PuTTY Installer for Windows 64-bit

(Headless Pi Only) Run PuTTY

Now its time to wirelessly access the Raspberry Pi’s command line using PuTTY’s SSH abilities.

Figure 21: The PuTTY Application

Configure the following:

  • Home Name (or IP address) = <YOUR raspberry Pi’s IP address>
  • Port = 22
  • Connection type = SSH

Click “Open” to connect.

Because this our first time connecting to this Pi, you will probably see a security alert…

But do not be alarmed.  Click “YES” to proceed.

Figure 22: Raspberry Pi’s Username and Password Prompt as Seen from PuTTY SSH

Now you should see the message “login as.”  This is a message from the Raspberry Pi 4.

Login to the Raspberry Pi using the default credentials:

  • Login as = pi
  • Password = raspberry

If you linger more than a minute or so without logging in, your Raspberry Pi will probably close the connection.  If that happens, just re-open PuTTY like before, and log in quickly.

Figure 23: Successful Connection to the Raspberry Pi from Windows 10

A successful login will look like Figure 23 above.

At this point, we can use the Raspberry Pi 4 terminal as if we had a monitor and keyboard connected.

(Headless Pi Only) Set Up Remote Desktop

If you want to use the Pi’s Graphical User Interface (GUI) as well, you have one final step: installing remote desktop support using xrdp and tightvncserver.

To start from a clean slate, type into the SSH terminal:

sudo apt-get remove xrdp vnc4server tightvncserver

In my case, none of these were already installed anyway, but now we know we are are starting clean. 

Install tightvnc server…

sudo apt-get install tightvncserver

Respond with the “Y” key (for “yes”) if the installer asks if you want to continue.

Figure 24: Raspberry Pi’s tightvncserver Removal and Installation

Now install xrdp in similar fashion…

sudo apt-get install xrdp

By default, the xrdp service will start up as soon as you have installed it.

(Headless Pi Only) Run Remote Desktop in Windows

Use the Windows search bar to search for the “Remote Desktop” application.

Figure 25: Remote Desktop in Windows

Enter your Raspberry Pi’s IP address.

Click “Connect.”

You will probably see a warning telling you to verify the device you are connecting to.  If nothing else seems unusual, click OK to proceed.

If xrdp is running properly, you will see this screen in Windows Remote Desktop…

Figure 26: Window’s View of xrdp

Enter the Raspberry Pi’s username and password.  If you have not changed it so far, it will still be the default of:

  • Username = pi
  • Password = raspberry
Figure 27: The Raspberry Pi Desktop as Seen in Windows 10 (Using Remote Desktop)

Conclusion

To close, I recommend changing the default passwords shown here to strong, memorable passwords at your earliest convenience.

At this point you are basically done.  But you may wish to update things by typing into the SSH terminal:

sudo apt-get update
sudo apt-get upgrade

Common Errors and Frustrations

Raspberry Pi Reboots Constantly

Endless Rebooting is a common sign of an under-sized 5-volt power supply.  The supply must be able to deliver 3 amps at 5 volts continuously.  This problem will also prevent your Raspberry Pi from being seen on the network.

Headless Pi did not join the wireless network

Assuming your Raspberry Pi isn’t rebooting constantly, you should move your Pi to the same room as the wireless gateway if possible (and within around 5 meters).  This ensures it has a strong signal.

Wireless networks using WPA or WPA2 Personal security seem to be the easiest to work with.  WPA2 Enterprise networks can be the most difficult.  If you have WPA2 Enterprise, you should consult with the official Raspberry Pi forum or the official documentation.

If you Raspberry Pi still won’t connect, it is probably a problem with the file: wpa_supplicant.conf

Remember that wpa_supplicant.conf must be encoded in the Unix (LF) and UTF-8 format.  The Unix (LF) format is not supported by Window’s built-in Notepad application (as far as I know), and you will need a special text editor such as Notepad++ to encode wpa_supplicant.conf properly.

If Wireless Fails, Consider Wired Ethernet

If you have a lot of trouble getting wireless access to work, consider buying an Ethernet cable (as CAT5E, CAT6, or similar).  Use the Ethernet cable to connect your Raspberry Pi’s Ethernet port to your router.  This will help get you around any problems with wpa_supplicant.

Troubleshooting wpa_supplicant.conf

The official guide has some maintained guidance on setting up wpa_supplicant at https://www.raspberrypi.org/documentation/configuration/wireless/headless.md .

Github users have pointed out the double-quotes surrounding the ssid=”” and fields may be improperly encoded (possibly by a text editor, web browser, or other source).  This can result in the double-quotes being the complicated Unicode form: 0xE28096 and 0xE2809D, rather than the standard ASCII format of 0x22 that we want.

If you have persistent problems with getting the Raspberry Pi to join your wireless network, consider downloading a copy of wpa_supplicant.conf from Github or from another Raspberry Pi.  This will help avoid problems with encodings and special characters.

Conclusions

DHCP Lease Time

Previously we saw the Dynamic Host Configuration Protocol (DHCP) lease settings.  Your router’s DHCP server will assigned an IP address for your Raspberry Pi 4 and keep it reserved for several hours, days, or even months.  This time interval is the DHCP lease time.

We can be confident the Pi will always reuse today’s IP address if the Pi is frequently connected to the network.  But if your Pi goes unconnected so long that the DHCP lease time expires, then the next IP address your Pi will receive is unknown, and your attempt to use SSH will probably fail.

To avoid this, consider consulting your wireless router’s manual on how to increase the DHCP lease time.  Alternatively, consider permanently reserving the IP for your Pi.

References

[1]Raspberry Pi Foundation, “Downloads,” Raspberry Pi Foundation, [Online]. Available: https://www.raspberrypi.org/downloads/. [Accessed 6 June 2020].
[2]Raspberry Pi Foundation, “Raspberry Pi OS (previously called Raspbian),” Raspberry Pi Foundation, [Online]. Available: https://www.raspberrypi.org/downloads/raspberry-pi-os/. [Accessed 6 June 2020].
[3]Raspberry Pi Foundation, “Setting up a wireless LAN via the command line – Raspberry Pi Documentation,” Raspberry Pi Foundation, [Online]. Available: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md. [Accessed 7 June 2002].
[4]The Raspberry Pi Foundation, “Setting up a Raspberry Pi headless,” The Raspberry Pi Foundation, [Online]. Available: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md. [Accessed 6 June 2020].
[5]Putty.org, “Download PuTTY – a free SSH and telnet client for Windows,” Putty.org, [Online]. Available: https://putty.org/. [Accessed 7 June 2020].
[6]PuTTY.org, “Download PuTTY: latest release (0.73),” PuTTY.org, [Online]. Available: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html. [Accessed 7 June 2020].
[7]Youtube user: sentdex, “Remote Access with SSH and Remote Desktop – Raspberry Pi and Python tutorials p.3,” 3 Apr. 2017. [Online]. Available: https://www.youtube.com/watch?v=IDqQIDL3LKg. [Accessed 7 June 2020].
[8]The Raspberry Pi Foundation, “Setting up a Raspberry Pi headless,” The Raspberry Pi Foundation, [Online]. Available: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md. [Accessed 7 June 2020].

Important Notice: This article and its contents (the “Information”) belong to Unboxing-tomorrow.com and Voxidyne Media LLC. No license is granted for the use of it other than for information purposes. No license of any intellectual property rights is granted.  The Information is subject to change without notice. The Information supplied is believed to be accurate, but Voxidyne Media LLC assumes no responsibility for its accuracy or completeness, any error in or omission from it or for any use made of it.  Liability for loss or damage resulting from any reliance on the Information or use of it (including liability resulting from negligence or where Voxidyne Media LLC was aware of the possibility of such loss or damage arising) is excluded.