ecotec
Posts: 64
Joined: Mon Jul 01, 2013 1:10 pm
Location: Norfolk

How I set-up a pi zero with VNC without a monitor

Wed Jan 11, 2017 6:20 pm

Hi All,

After setting up a few pi zero's to run headless VNC, here's the process I follow that may be helpful if you are trying to do similar. I'm no expert but this works for me :)

Hardware
sd card reader
pi zero+psu
wifi dongle
pc/laptop

Software
Raspian image - https://www.raspberrypi.org/downloads/raspbian/
Etcher - https://etcher.io/
SD card formatter - https://www.sdcard.org/downloads/formatter_4/

1. Prep
download raspian jessie with pixel and save to your desktop (or similar location)
download sd card formatter
download etcher

Check your sd card has nothing important saved to it, then format with the SD formater tool. Ensure you pick the correct drive letter to avoid accidental data loss.

2 - Write the image
Open etcher, it should find your SD card, then locate the raspian image (no need to unzip - etcher will do this for you) and follow the steps to write the image. I find etcher much easier than DD or win32disk imager. Wait for it to write and confirm the write was successful.

3. Edit the SD Card
remove and re-mount the sd card in your pc/laptop.

=Update===========
Thanks to @mattmiller (see post 2) here's a quicker way to add your wifi credientials to the SD image
Make a master wpa_supplicant.conf file on your main computer once with your WiFi settings in it

Then all you have to do is copy it to the boot partition on your SD card and on 1st boot of your Pi - it will move it to /etc/wpa_supplicant/wpa_supplicant.conf and use it

Saves re-building it each time
==================
Open the SD card and find: etc/wpa_supplicant/wpa_supplicant.conf

If on linux - open the terminal (shortcut is ctr, shift and t)
type:

Code: Select all

sudo nano
then drag the file
"etc/wpa_supplicant/wpa_supplicant.conf"
to the terminal window, enter your password when prompted and the nano txt editor will open.
Then add this to the end of the file (edit the name and password with your wifi network details):

Code: Select all

network={
  ssid="my network name"
  psk="my network password"
  proto=RSN
  key_mgmt=WPA-PSK
  pairwise=CCMP
  auth_alg=OPEN
}
Then,
ctr + X
y to save changes
then type:

Code: Select all

exit
in the terminal window to close.

then "As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually. For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card."

create a new blank document on the "boot" partition as detailed above.

4. Eject the sd card

5. Then over to the zero, insert the SD card, wifi dongle, power and watch it boot. Give it 30 seconds or so.

6. Then back to pc to find the IP of your pi on the local network.
Open up router config screen (mine is found @http://192.168.1.1/ - yours might be different) look for the pi in the list of connected wifi devices and note down ip address.
like: 192.168.1.105

open terminal (if your on windows download "putty" - thanks to @mattmiller post 2)

Code: Select all

ssh pi@192.168.1.105
accept the connection type
username - pi
password - raspberry

then type:

Code: Select all

sudo raspi-config
Image
then I usually:
expand the file system to use all the space on the SD card
change user password to something unique
enable camera if required
Interfacing option, enable VNC
Image

Exit and it will ask you to reboot, accept and wait for the zero to reboot.

Then to connect over VNC, open your VNC viewer, I use VNC viewer for google chrome by realVNC (search in extensions for: "realVNC")

Then the desktop should open, enter your username "pi" and password "raspberry" unless you changed it in the previous step, then enter that instead!

Then update the system by:

Code: Select all

sudo apt-get update

Code: Select all

sudo apt-get upgrade -y
Addition, you might need expand desktop size when viewed under VNC, I followed these instructions:
https://support.realvnc.com/Knowledgeba ... spberry-pi
with these settings:

Code: Select all

hdmi_force_hotplug=1
hdmi_group=2 
hdmi_mode=16 
which outputs to - 1024x768@60Hz


Hope that helps!
Last edited by ecotec on Thu Jan 12, 2017 7:32 pm, edited 4 times in total.
b raspbian running get-iplayer and mini dlna server
b+ running volumio
pi 2 - dietpi - pihole, ssh and a few other bits

mattmiller
Posts: 2247
Joined: Thu Feb 05, 2015 11:25 pm

Re: How I set-up a pi zero with VNC without a monitor

Wed Jan 11, 2017 6:32 pm

To save you some typing effort in future

Make a master wpa_supplicant.conf file on your main computer once with your WiFi settings in it

Then all you have to do is copy it to the boot partition on your SD card and on 1st boot of your Pi - it will move it to /etc/wpa_supplicant/wpa_supplicant.conf and use it

Saves re-building it each time

(and also lets you do all this on a Windows machine which won't let you edit /etc/wpa_supplicant/wpa_supplicant.conf directly)
And one more thing for Windows users - download a program called Putty and use that to connect to your PiZero as Window doesn't have an ssh command built in

ecotec
Posts: 64
Joined: Mon Jul 01, 2013 1:10 pm
Location: Norfolk

Re: How I set-up a pi zero with VNC without a monitor

Wed Jan 11, 2017 6:40 pm

@mattmiller

Thanks for your post that's really helpful and much faster - I will add a note to the original post,

Cheers
b raspbian running get-iplayer and mini dlna server
b+ running volumio
pi 2 - dietpi - pihole, ssh and a few other bits

User avatar
sconemad
Posts: 233
Joined: Thu Apr 28, 2016 1:47 pm
Location: Cambridge, UK
Contact: Website

Re: How I set-up a pi zero with VNC without a monitor

Wed Jan 11, 2017 9:40 pm

Hi ecotec,

That's a really great guide!
I've another suggestion to save some more typing:

In the recent version of raspi-config, there is a new menu under Advanced options > Resolution that allows you to select the screen resolution, so you don't have to go and manually edit /boot/config.txt.

(you might also note that the VNC option has moved from Advanced Options to Interfacing Options).

Hope this helps!

Return to “Beginners”