# Public Lab Research note

This is part of a series on basic-microscope.

# Prepare an SD card for a Raspberry Pi camera from scratch

by warren with bmela , kgradow1 , partsandcrafts , wmacfarl | | 670 views | 3 comments |

In a perfect world, our Raspberry Pi Zero W would hook up to the camera, connect to the wifi, and the seamlessly know to send streaming image data to http://raspberrypi.local. It'd be almost as easy as plugging in a webcam (something we're aiming for here)!

Update: You can now download ready-to-use camera software on our Pi Builder page

This activity covers the background steps (as documented by @partsandcrafts) that lead to having a ready-made SD card image, as mentioned in this activity. If you use the prepared image in that activity, you can skip all the steps in this activity -- they're already done! This just shows how we did it.

If you just plug in your Pi and go to that website, nothing will happen. Before we get started, though, we'll need to do the following things:

1. Install the operating system on the Raspberry Pi
2. Give the Raspberry Pi access to the network
3. Enable the camera on the Raspberry Pi
4. Install RPICam Interface, which sends streaming image data to http://raspberrypi.local (which we will access to view the pictures)

Look at this diagram to see how it'll work:

In a workshop or classroom setting, microscope users can be given a pre-flashed SD card with the appropriate software installed and will only need to edit a single configuration file to provide their wifi credentials.

This is admittedly a somewhat daunting task for many casual computer-users, but it can be explained in a step-by-step manner pretty easily (and could possibly be made easier by having a piece of software prompt the user for their credentials and generate the file automatically).

For now, you'll need to edit the file directly to give the Pi access to your wifi network.

Once the wifi credentials are set up and the Raspberry Pi is booted, users can open up a web browser on any computer on the same network, visit http://raspberrypi.local and see something like this:

If you are doing this from scratch, you will need to install an operating system on your Pi, set up wifi/networking, enable the camera, and install RPi Cam Web Interface -- https://elinux.org/RPi-Cam-Web-Interface -- the software we use for streaming images.

Note: the Public Lab Kits Initiative plans to offer pre-flashed SD cards soon.

### Steps

1. Installing an Operating System.

First you want to download a copy of the Raspberry PI operating system -- Raspbian. You can get that from the Raspberry Pi website -- https://www.raspberrypi.org/downloads/raspbian/

For this setup we can use Raspbian Stretch Lite (which is smaller and has no desktop software and saves more room on the SD card for pictures and videos.

Download the .iso file, write it to a microSD card using a tool like etcher -- https://etcher.io/

2. Set up Networking

After the image is burned to the SD card we will need to make two changes to it before putting it in the Raspberry Pi and booting it up. We need to set up our wifi credentials so that the Pi can connect to your local network, and we need to enable SSH -- a tool that will allows us to log in to the Pi remotely from another computer so we can finish the set up.

To do both of these things I followed this tutorial -- https://core-electronics.com.au/tutorials/raspberry-pi-zerow-headless-wifi-setup.html -- but found that the wpa_supplicant.conf file they provided did not work for me.

The file I have been using looks like this, but the process is otherwise the same:


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

update_config=1

network={

ssid=“SSID_NAME”

}


3. Enable Camera

To enable the camera and set up the software you will need to connect to your Raspberry Pi over ssh. As described in the tutorial linked to above. Once logged in you will type the command:

sudo raspi-config

The option for enabling the camera is in the "interfacing options." You want to select it and enable the camera, then reboot.

4. Install Streaming Software

The software we use to stream images from the camera is called RPi Web Cam Interface. It can be found here -- https://elinux.org/RPi-Cam-Web-Interface -- along with instructions for how to install it. I used all default options in my install process.

Once it's set up you should be able to go to http://raspberrypi.local/html/ and see what your camera sees.

Help out by offering feedback!

### People who did this (1)

Title Author Updated Likes
Set up Cam interface on RPi zero w with Pi Cam 2 11 months ago

I have problem with this. I cannot get my raspberry pi to connect to my wifi router. I have tried different thing in wpa_supplicant file that I found in different tutorials. https://www.youtube.com/watch?v=LlCr09B2HZI There it says to add these lines only: network={

ssid=“name”

key_mgmt=WPA2-AES

} Why there is no first line in that video that you can see in what this page says to put in there? Why there is no key_mgmt line in what this page says to put in there? There seems to be many different things you can put in there but nothing works for me.

I changed key_mgmt line to WPA2-AES because that is encryption what my router uses. I did check it from settings page of my router when it is connected to my laptop by Ethernet cable. From that page I did check if my raspberry is connected to router and it is not.

In this tutorial there is lot more lines in wpa_supplicant file. https://www.youtube.com/watch?v=lJdLpJoov1g

Is this a question? Click here to post it to the Questions page.

Reply to this comment...

I managed to connect with usb. Now I will try to get camera to work and calibrate my spectrometer. I followed this: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget#if-you-are-using-windows-as-the-host-machine

Reply to this comment...

Glad to hear it. I've noted that not all WiFi networks work, and sometimes trying on a different one (like the one I broadcast from my phone) works to get past configuration issues.

Reply to this comment...