Raspberry Pi Camera Board
Cameras are great. Cool, compact, and flashy (no pun intended), many cameras now have additional features and capabilities. While these features can be great, sometimes a simple, single-button camera is all that is needed. With this in mind, building a camera board with the Raspberry Pi provides several advantages. Cheap, relatively durable, customizable, and simple the Raspberry Pi Camera Board can function as an attendance recorder, mini photo-booth, or a stationary desk camera! Follow the instructions below, and bear witness to the video imaging capabilities of the Raspberry Pi.
Supplies
Computer Components
- Raspberry Pi with CircuitPython Installed (3 A+, 3B+, or 4)
- Camera Module (Raspberry Pi Camera Module v2, for this project)
- Pin-Socket Wires x2
- Button (2-Stand Button, for this project)
- Breadboard
- Power Source (Raspberry Pi Power Adapter, for this project)
- Adafruit Bluefruit CPB with CircuitPython Installed*
- HDMI Monitor*
- HDMI Cable*
- LED Light Strip*
- 3.7v Lithium Ion Battery with 2-pin connector*
*Optional
Physical Components
- Board-Type Surface, Dimensions Customizable (piece of laser-cut plywood, for this project)
- Raspberry Pi Case
- Hot Glue Gun (or other adhesive)
Configure Raspberry Pi
Once the necessary computer components have been collected, the Raspberry Pi needs to be configured to accommodate these components.
- First, upgrade and update the Raspberry Pi. The following link provides detailed instructions on how to do this: Raspberry Pi Update and Upgrade Info
- Now, navigate to the Raspberry Pi Configuration Menu, select the "Interface" option, and select the "enable camera" option (this might sometimes appear as "enable legacy camera").
Attach Computer Components & Set Up Physical Components
Now that the Raspberry Pi has been properly configured, the camera module itself needs to be set up.
- Open the camera module port on the Raspberry Pi (labeled "Camera") by lifting up the top, and gently hinging backwards. Insert the camera module's cable into the slot such that the metal pins are facing each other, and re-insert the top of the port to secure the camera module in place.
- Attach the button to your breadboard, and insert the pin ends of the pin-socket wires adjacent to the button stands. Attach one of the socket sides to the Raspberry Pi GND (ground) pin, and the other to whatever connection pin the location of the button will be defined as.
- Now - the physical component set up. Place the Raspberry Pi (RPI) in its container (be sure to line up the USB ports with the holes in the container), connect it to a power source, and adhere the RPI to your board-type surface with an adhesive (hot glue, in this instance). Similarly, attach the breadboard and button to the board-type surface via the breadboard's adhesive back, securing the Raspberry Pi, breadboard, and button. Finally, carefully hot glue the edges of the camera module (or camera module case, if included with your camera module) to the surface to secure the final component of the board.
Set Up Code to Run
Of course, the Raspberry Pi cannot run CircuitPython by itself; you need to create a Python document for this! Here, I will go over the code to get your project up and running.
- Open up a CircuitPython file via the Raspberry Pi terminal or a third-party shell (Mu was used, for this project) and import the following libraries: os, board, digitalio, time, DigitalinOut (from digitalio), adafruit_debouncer, and Debouncer (from adafruit_debouncer).
- Define the button's location as "button_input"; in this specific project, the button input was located at address D23. Switch the button input to either UP or DOWN (depending on the type of button), and define a "button" variable as the "button_input" variable within the Debouncer function.
- Create a function to take a photo when the button is pressed. The photo is taken by passing the "raspistill -o DesiredLocation/image_name.jpg" command into the terminal via the "os.system()" function from imported module "os". The "raspistill..." command is passed directly in the terminal, and the Raspberry Pi instructs the attached camera module to write out a captured image, and save it to the specified directory.
- Set up a "while True" loop. When the button's value is detected (the button is pressed), call the photo-taking function, which will then capture the feedback from the camera module.
- Finally, in the Raspberry Pi Terminal, open the folder that your CircuitPython file is in, and call the code by passing the following command into the terminal: python3 filename.py (switch out the "filename" with your - you guessed it - file name).
The exact code used for the initial project is provided below (this code will not run as-is; it needs to be modified for your specific project needs and wants).
Downloads
Optional CPB Light Setup
What is more important than a photo? Looking good in a photo! The optional CPB-controlled light strip ensures that your Raspberry Pi Camera Board captures you in the best light.
- Attach the ends of the light strip to the CPB, and attach the CPB to a computer.
- In a CircuitPython script, define the light strip (location, connection, number of lights, etc.) and define two buttons (A and B) as the two buttons on the Bluefruit CPB.
- In a "while True" loop, set up the button responses such that an initial press to button A or B lights up the strip in Amber and White, respectively, while a second press from either button turns off the light strip.
- Attach the CPB and light strip to your camera board (via zipties, drilling holes, tape, etc.), and plug the rechargeable battery into the CPB to provide power.
Congratulations! You now have a rechargeable lightning strip attached to your Raspberry Pi Camera Board. Specific code is attached below, for a more detailed follow-through (note that there might be slight variations between the provided code and your final code, due to possible differences in components).
Downloads
Optional HDMI Monitor Connection
While the Raspberry Pi Camera Board will take and store photos with or without a monitor, a screen allows for a demo of the camera module image to appear when taking a photo. As everyone likes to see what they are taking a photo of, a monitor might be useful in some cases. Luckily, it could not be easier; simply insert a HDMI cable into your monitor, plug the monitor into its provided power course, and watch as the Raspberry Pi Interface lights up the screen. Press the camera button, and a 5-second demo of what the camera module is recording appears on the screen. While not necessary, a monitor allows for one to literally see through the "eyes" of the Raspberry Pi's camera module.
Using the Camera
Here is the fun part. Now that the setup is complete, the beauty of the Raspberry Pi Camera Board's simplicity is evident. Simply point your camera, press the button, and wait a second! There should be a new photo in the specified directory in the Raspberry Pi. The ability to save these photos into various folders makes the Camera Board quite useful. Whether you are collecting faces for a photo montage, taking visual attendance records, or simply want a camera with a computer-friendly interface, the Raspberry Pi Camera Board is for you!