Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (2024)

Home Automation Scripts Web Server

March 23, 2017 by rcastera3 Comments

I received my Raspberry Pi Zero Wa couple of weeks ago and finally had the chance to set it up. My goal is to to setup somecameras in my basem*nt and garage.

Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (1)

Prerequisites

Here are links to the products and prices I purchased on Amazon and CanaKit at the time. The prices might vary slightly ifyou purchase them.

Bringing the total cost of this setup to: $69.35 (including shipping). If you’relooking for something with more features, you can purchase indoor wireless IP camera’sonline. Some of them even have 2-way audio which I use to keep tabs on my dogs and general security. For my purposes, and where they’ll be placed, I don’t need that type of functionality. Also, you get the reward of building something yourself with greater control.

Setup

I decided to use the Raspbian Jessie Lite distribution for my setup since it’s a smaller SD card and there won’t be any GUI. You can download it here from the Raspberry Pi website by selecting “Download ZIP”. Alright, here we go:

  1. Connect the SD card to your computer. Note that it must be formatted as FAT32. The one I purchased above was already formatted in FAT32.
  2. Open “Disk Utility”. To do this, click on the magnifying glass in the top-right corner of your computer screen. Type “disk utility” in the search box that opens, then click on the “Disk Utility” Application that comes up and click on “APPLE SD Card Reader Media”.
    Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (2)
  3. Note the “Device:”; it will look something like disk(n) where (n) is a number (for example, disk1). Make sure you take a note of this number. Mine was disk1.
  4. Now, right click on “NO NAME” or “Untitled” on the left and select “Unmount” from the menu. This will unmount the partition so that you can write to the disk.
  5. Now open terminal and run the following command:

    Shell

    1

    sudo dd bs=1m if=(PATH_OF_THE_IMAGE_YOU_DOWNLOADED.img) of=/dev/rdisk(n)

    Remember to replace (n) with the number that you noted before and (PATH_OF_THE_IMAGE_YOU_DOWNLOADED.img) to the path of the Raspbian Jessie Lite image you downloaded. for example: my command was:

    Shell

    1

    sudo dd bs=1m if=2017-03-02-raspbian-jessie-lite.img of=/dev/rdisk1

    The image file will be copied to the SD Card. You won’t get any feedback while it copies, and it can take several minutes. Leave terminal open and let it do its thing.

Headless setup on the Raspberry Pi Zero (W)

Once it’s completed,

  1. Open the boot volume on your Mac (should auto mount after the disk image is finished writing).
  2. Create an ssh file to tell the Pi to enable SSH when it boots up by default:
  3. Next, create a wpa_supplicant.conf file in the boot volume to tell the Pi to connect to your WiFi network on boot:

    Shell

    1

    nano /Volumes/boot/wpa_supplicant.conf

  4. Insert the contents below into this new file:

    Shell

    1

    2

    3

    4

    5

    network={

    ssid="YOUR_SSID"

    psk="YOUR_PASSWORD"

    key_mgmt=WPA-PSK

    }

  5. Eject the SD Card and insert it into your Raspberry Pi.

Connecting the Camera to the Pi

Connecting the camera to the pi is fairly easy. Use the supplied mini cable provided with the camera case.

Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (3)

Insert the Pi into the case

Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (4)

Finished Product

Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (5)

Booting Raspbian Jessie Lite

Ok, now it’s time to insert the power cord and boot up the Pi. For this step, you’re going to find the IP Address of your Pi to SSH into it. Most routers have a network map that displays connected devices. I was easily able to find mine. If you can’t find yours, try using a tool likenmap.

  1. SSH into your Pi:

    Shell

    1

    ssh pi@YOUR_IP_ADDRESS

  2. Once, you’ve logged in, update the OS:

    1

    2

    3

    4

    sudo apt-get update

    sudo apt-get upgrade -y

    sudo apt-get install -y wget

    sudo apt-get dist-upgrade

  3. Now we’re going to configure the OS using the raspi-config tool.

    Shell

    1

    sudo raspi-config

    Below are the options I configured for my Pi:
    1. Set a new password.
    2. Set a hostname (e.g. kitchen-camera).
    4. I configured “Localisation Options” for my locale
    5. For ‘Interfacing Options’, select ‘P1 Camera’, then choose ‘Yes’ to enable the camera interface.

  4. Test it out by running:

    Shell

    1

    raspistill -o photo.jpg

Installing software for the camera

There are a couple of software options for using your Pi as a security camera. I opted for Motion. Adafruit has an excellent tutorial for setting it up with Dropbox. Follow that tutorial and become familiar with the Motion config options.

home automation raspberry pi

Share:

Related Posts

Setting up Raspberry Pi 3 with the 7" Touchscreen Display

December 13, 2016

    3 Comments

  1. David June 9, 2017 at 3:43 amReply

    An excellent write-up Richard. Did everything go well from the start or any teething problems?
    I got my Pi Zero W with a v2.1 camera on a short ribbon connector this week. I’ve run apt-get update and upgrade and believe I’ve been careful about static and ribbon cable positioning but the camera isn’t being detected. This might be nothing you can help me with but just in case I’ve done the following tests…
    Thanks in advance,
    David

    Shell

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    $ vcgencmd otp_dump |grep ^30

    30:009000c1

    $ cat /proc/cpuinfo | grep Revision

    Revision: 9000c1

    $ sudo vcgencmd get_camera

    supported=1 detected=0

    $ raspistill -o test.jpg

    mmal: Cannot read camera info, keeping the defaults for OV5647

    mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)

    mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)

    mmal: Failed to create camera component

    mmal: main: Failed to create camera component

    mmal: Camera is not detected. Please check carefully the camera module is installed correctly

    $ sudo vcgencmd version

    May 30 2017 15:27:20

    Copyright (c) 2012 Broadcom

    version b8cdd5ae76f39d9f353dfa8fb48bf7e33b74903c (clean) (release)

    $ uname -a

    Linux dtcloud 4.9.30+ #1001 Fri May 26 16:03:39 BST 2017 armv6l GNU/Linux

    $ cat /etc/os-release

    PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"

    NAME="Raspbian GNU/Linux"

    VERSION_ID="8"

    VERSION="8 (jessie)"

    ID=raspbian

    ID_LIKE=debian

    HOME_URL="http://www.raspbian.org/"

    SUPPORT_URL="http://www.raspbian.org/RaspbianForums"

    BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

  2. Leprechaun July 22, 2017 at 1:36 pmReply

    I had problems with your wpa_supplicant.conf
    Instead, i used this template that works for my network

    Shell

    1

    2

    3

    4

    5

    6

    7

    8

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

    update_config=1

    country=ES

    network={

    ssid="myssid"

    psk="mypsk"

    key_mgmt=WPA-PSK

    }

  3. victor July 24, 2018 at 7:13 amReply

    Nice to the point tutorial.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Next post »Setting up Raspberry Pi 3 with the 7″ Touchscreen Display
Setting up a headless Raspberry Pi Zero (W) with Camera - Richard Castera (2024)
Top Articles
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 6038

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.