Help save net neutrality! A free, open internet is once again at stakeā€”and we need your help. Learn more »

Public Lab Research note


  • 2

Setting up the Raspberry Pi Camera for Wireless Streaming

by partsandcrafts with bmela , kgradow1 , warren , wmacfarl |

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


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

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.

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.

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

Three separate monitors plus a LOT of cables.

**
**

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 part of a digital microscope without really having to interact with the Raspberry Pi.

The solution I've come up with is to use the Raspberry Pi Zero W (which has built in wifi and bluetooth) and have the Pi act as a local web server, streaming camera data to any computer on the local network through the web browser. IMPORTANT: We're using the Raspberry Pi Zero W, not the regular Raspberry Pi Zero, which does not have wifi enabled.

How It Works

image description

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.

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; and 4) Install RPICam Interface, which sends streaming image data to http://raspberrypi.local (which we will access to view the pictures).

image description

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.

image description

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:

image description

How do I set it up?

f 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.

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"

psk="PASSWORD"

}

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.

Skip a few steps: Use a pre-flashed SD card

You can skip most of those steps and just start with an SD card with the software already set up. You can get this disk image here -- http://partsandcrafts.org/pi_microscope/raspbian_preload. Download it and write it to your microSD card using Etcher -- https://etcher.io/

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.

After you make these replacements, save the file, put it in your Raspberry Pi and plug it in. It will take a little while to boot, but after it does you should be able to visit http://raspberrypi.local in your web browser and see your camera in action.

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 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 (called zeroconf networking) 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/

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


I did this 


People who did this (0)

None yet. Be the first to post one!



This is marked this as an activity for others to try.
Try it now   Click here to add some more details.


microscope pi-camera microscopes raspberry-pi-infragram raspberry-pi-spectrometer

barnstar:basic with:kgradow1 with:warren activity:microscopes activity:raspberry-pi-infragram with:wmacfarl activity:raspberry-pi-spectrometer activity:pi-camera with:bmela activity:basic-microscope activity:lego-spectrometer


7 Comments

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


Love this so much!

I was thinking you might have a note above or just below "How It Works" that could advise you to jump ahead to the "Skip a few steps" line if you have a card already set up? Then we can offer some preflashed SD cards in the store for this.

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


Hi! http://partsandcrafts.org/pi_microscope/raspbian_preload isn't working for me -- and how big is it? Do you think we could host that at GitHub or something? Either way I'd love to contribute some mods -- for example a full screen button for the viewer. Maybe I can contribute at https://elinux.org/RPi-Cam-Web-Interface

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


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


Update - image available here: http://publiclab.org/downloads/raspbian_preload.img.zip

Or to use the Internet Archive's bandwidth (thanks!) here: https://archive.org/details/raspbian_preload.img

Torrent here: https://archive.org/download/raspbian_preload.img/raspbian_preload.img_archive.torrent

what's the best way to version track a whole image?

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


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!


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


You must be logged in to comment.