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:
- Install the operating system on the Raspberry Pi
- Give the Raspberry Pi access to the network
- Enable the camera on the Raspberry Pi
- 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.
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.