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.
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.
Above: 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
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).
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:
How do I set up an SD card myself?
If you don't have a pre-flashed SD card, and 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. Skip ahead to the next session if you have one, or can pre-flash your own card with an disk image. _
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:
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:
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:
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 and eject the SD card.
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.
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