Public Lab Research note


This is part of a series on basic-microscope.

Setting up the Raspberry Pi Camera for Wireless Streaming

by partsandcrafts , bmela , kgradow1 , warren , wmacfarl | December 03, 2017 02:55 03 Dec 02:55 | #15289 | #15289

partsandcrafts was awarded the Basic Barnstar by stevie for their work in this research note.


The Raspberry Pi Zero is an amazingly powerful and cheap device, and since it behaves more or less like the kinds of desktop computers most people are familiar with it is, in a lot of ways, relatively user-friendly. Here we'll show you how to set it up with the Raspberry Pi Camera module (v1 or v2) and connect to it to take photographs from your laptop.

(For a full overview of this project, go to Raspberry Pi Microscope Build.)

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

The biggest hurdle that I've found for actually succeeding in doing anything with the Raspberry Pi is actually just getting it plugged in and turned on and attached to some kind of keyboard and display. This is how you'd use it in the traditional way, with all the cables:

image description

If you don't have exactly the right set of peripherals and cords and dongles getting the Pi up and running can feel extremely daunting, and getting all of the required components, if you don't happen to have them lying around, quickly adds up and stops being cheap.

image description

Above: three separate monitors plus a LOT of cables.

Instead, and because of these two factors -- the difficulty that I've seen people outside of tech/computer hobbyists circles have setting up the Raspberry Pi, and the additional cost of getting all of the required components from scratch, I wanted a way for people to use the Raspberry Pi camera as a digital camera without really having to interact with the Raspberry Pi as a computer.

The solution I've come up with is to use the Raspberry Pi Zero W over your local WiFi network, so any computer on your WiFi network can see through the camera using a web browser. The whole camera interface is available on a web page, as long as you're on the same WiFi network. (IMPORTANT: We're using the Raspberry Pi Zero W, not the regular Raspberry Pi Zero, which does not have WiFi built in.)

How We've Set It Up

image description

In a perfect world, our Raspberry Pi Zero W would hook up to the camera, connect to the wifi, and then seamlessly know to display a live image on a website.

If you just plug in your Pi and go to http://raspberrypi.local, nothing will happen. Before we get started, we'll need to:

  1. Install the operating system on the Raspberry Pi's SD card
  2. Set up the WiFi info on the card
  3. Plug everything in and start it up

image description

Prepare the SD card

Following these steps, we have prepared an SD card image with the software already set up. You can get this disk image here:

https://archive.org/details/raspbian_preload.img

Download it (it's very big -- ~8 gigabytes!) and write it to your microSD card using Etcher -- https://etcher.io/

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 text file to provide their WiFi login and password. 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.

Set up the WiFi

You'll be connecting to the microscope over WiFi, so it needs to be connected to your network first.

Once you've written the SD card it will probably show up as two different drives on your computer. If you're using Windows you will see a "boot" partition (in my case, E:) and then an unreadable partition with a file system that Windows does not understand (in my case F:). Windows will throw some errors about this second partition and say that you need to reformat this second partition to use it. Ignore these errors.

If you open up the "boot" partition you'll see a file called "wpa_supplicant.conf" Open it in any text editor and you'll see something like this:

image description

The only thing you need to do is replace "SSID_NAME" with your wifi network's SSID (the name of the network as it is displayed when you try to connect to it) and "PASSWORD" with your network's password.

If there's no password on your WiFi network, see the comments for how to set this file up.

After you make these changes, save the file and eject the SD card.

(If you've done this once and want to change the WiFi information, you may find that the file has disappeared. Download a new file here: wpa_supplicant.conf)

Plug it in and start it up!

Now you're ready to boot it up. Put the SD card in your Raspberry Pi and plug it in with the USB power cable where you see the circular power symbol (not the USB port, which looks similar!).

It will take a little while to boot, but after it does you should be able to visit http://raspberrypi.local on your laptop's web browser and -- connected wirelessly to the camera -- see a live image.

image description

Note for Windows Users

If you are using Windows, your computer might not be configured to find the Raspberry Pi on your network using the http://raspberrypi.local address. Newer updates of Windows 10 seem to support this feature, but older Windows installations may not.

The simplest way to enable this functionality is to install Apple's Bonjour print services, either the older version 2.02 as a standalone program -- https://support.apple.com/kb/dl999?locale=en_US -- or the newest version, bundled with iTunes -- https://www.apple.com/itunes/download/ (although it may seem strange, the utility comes with iTunes!)

More information is available here -- https://learn.adafruit.com/bonjour-zeroconf-networking-for-windows-and-linux/overview


I did this Help out by offering feedback!


People who did this (0)

None yet. Be the first to post one!


7 Comments

@stevie awards a barnstar to partsandcrafts for their awesome contribution!

Reply to this comment...


Oh! The docs say "Clicking on the image will toggle between normal and full screen mode." Awesome!

Reply to this comment...


Hi, @partsandcrafts @wmacfarl @kgradow1 @bmela - i'd be happy to do some formatting work on this post if you want to add my username as a coauthor -- with:warren -- thanks!

Reply to this comment...


Awesome -- i used the image and it worked perfectly!

Reply to this comment...


Reply to this comment...


We found that for WiFi networks with no password, you can get it to log into any open network with:

network={ key_mgmt=NONE priority=-999 }

in wpa_supplicant.conf

https://raspberrypi.stackexchange.com/questions/15393/connect-to-unsecured-wireless-network

And also, that once you've set the wifi network, you can re-set it by editing /etc/wpa_supplicant/wpa_supplicant.conf

Reply to this comment...


Hi @partsandcrafts @bmela @wmacfarl @kgradow1 - I broke out the "install on an SD card" steps into a separate activity:

https://publiclab.org/notes/warren/04-20-2018/prepare-an-sd-card-for-a-raspberry-pi-camera-from-scratch

That made it possible to simplify this one a lot. What do you think?

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

Reply to this comment...


Login to comment.