Skip to content

PiCamera setupLink


This is a work in progress!

Getting startedLink

To set up the PiCamera you first need to install a fresh OS on your Raspberry Pi Zero W.

Burn a new Raspberry Pi OS Lite imageLink

We recommend the Raspberry Pi Imager tool to burn a new Raspberry Pi OS (32-bit) Lite. You can find it here.

Or you can download an official ZIP here.

Accessing the PiZeroLink

A - Enable SSH remote accessLink

After installing the Raspberry Pi OS, add an empty file ssh in the boot partition to enable SSH access.


As we will later use the Wi-Fi from the PiZero to create an Access Point, we recommend to use the ethernet port to SSH in the PiZero.

B - Use local accessLink

Otherwise, use a screen and keyboard to access the PiZero.

Raspberry Pi OS setupLink

Before installing the software, you have to configure some Raspberry Pi OS settings & change the password.

Change the passwordLink

For security reasons, you have to change the pi user password because the default is known by everyone!

Use the raspi-config tool to do it:

sudo raspi-config


The default password is raspberry!

Edit the timezone & localesLink

Change the timezone to get the right time from the PiZero clock! You may also change the locales to suits your needs.

Create the Wi-Fi Access PointLink

We will now create the AP using command lines following the tutorial from:

You may also be interested in doing this with a graphical interface, and we would highly recommend raspap-webgui.

Install PackagesLink

To install the required packages, enter the following into the console:

sudo apt-get -y install hostapd dnsmasq

Set Static IP AddressLink

Edit the dhcpcd.conf file:

sudo nano /etc/dhcpcd.conf

At the bottom of the file, add:

denyinterfaces wlan0

Save and exit by pressing Ctrl+X and Y when asked.

Next, we need to tell the Raspberry Pi to set a static IP address for the Wi-Fi interface. Open the interfaces file with the following command:

sudo nano /etc/network/interfaces

At the bottom of that file, add the following:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static

Configure HostapdLink

We need to set up hostapd to tell it to broadcast a particular SSID and allow Wi-Fi connections on a certain channel. Edit the hostapd.conf file (this will create a new file, as one likely does not exist yet) with this command:

sudo nano /etc/hostapd/hostapd.conf
Enter the following into that file. Feel fee to change the ssid (Wi-Fi network name) and the wpa_passphrase (password to join the network) to whatever you'd like. You can also change the channel to something in the 1-11 range (if channel 6 is too crowded in your area).

Save and exit by pressing Ctrl+X and Y when asked.

Unfortunately, hostapd does not know where to find this configuration file, so we need to provide its location to the hostapd startup script.

Open /etc/default/hostapd:

sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF="" and replace it with:


Save and exit by pressing Ctrl+X and Y when asked.

Configure DnsmasqLink

Dnsmasq will help us automatically assign IP addresses as new devices connect to our network as well as work as a translation between network names and IP addresses. The .conf file that comes with Dnsmasq has a lot of good information in it, so it might be worthwhile to save it (as a backup) rather than delete it. After saving it, open a new one for editing:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
sudo nano /etc/dnsmasq.conf

In the blank file, paste in the text below.


Test Wi-Fi connectionLink

Restart the Raspberry Pi using the following command:

sudo reboot

After your Pi restarts (no need to log in), you should see romi_hotspot appear as a potential wireless network from your computer.

Connect to it (the network password is raspberry, unless you changed it in the hostapd.conf file). Then try to SSH it with:

ssh pi@

Install Python3 & pipLink

You will need the Python3 interpreter (Python>=3.6) to run the PiCamera server & pip to install the PiCamera package.

sudo apt update && sudo apt upgrade -y
sudo apt install python3 python3-pip

This will update the package manager, upgrade the system libraries & install Python3 & pip.

Install the PiCamera packageLink

Once you have pip you can install the picamera Python3 package:

pip3 install picamera


We do not create an isolated environment in this case since the sole purpose of the PiZero will be to act as a responsive image server.

Camera serve Python codeLink

To capture and serve the images from the PiCamera, we use this Python script:

To upload it to your PiZero, from a terminal:


Now (test) start the server with:



Explain how to execute python3 command at PiZero boot.