For my second real project for the Raspberry Pi I needed it to be something that took advantage of the recently released Raspberry Pi Camera Board. My idea was to make an extremely simple “point and shoot” camera. I wanted it to be able to run on batteries, connect over Wifi and have as much of the project inside of the original box as I could.
The connection to the button is done with a little proto-board from Radioshack (I like the ones with the square pads). It is basically using the schematic form this Adafruit tutorial on using buttons with the RPi. It just has a pullup resistor and a GPIO pin for each button you need. I just cut the RPi ribbon from Adafruit to make the attachment to the Raspberry Pi. I only have one button wired in, but you could do more or have LED indicator lights using the GPIO pins.
I will do more detailed instructions this weekend but to run this you will need to do the minimum:
Install Camera with raspi-config
Update Upgrade your Raspberry Pi
Install FTP (for external access to images, not required)
The Python file that is just loops waiting looking for a button press, the simple file is here (as a google drive file for save viewing):
(the simple camera version, with no display)
I also made an updated version that uses a TFT screen and displays each picture after it is taken. The Updated version is available on GitHub here:
(requires that PyGame is installed on the RPi)
It needs to be running in order for the camera to fire, so you may need to have your Pi boot right into it.
The final piece was making the ultra tiny USB cable using a slice from normal sized cable and some careful soldering and glue gun usage. This way it locks in nicely and the Enercell battery lasts about 3.5 hours.
Parts needed for this Project:
Raspberry Pi – Camera Board – $25
Ribbon Cable – $3
Button Board and button from Radioshack -$10
Not required but extremely helpful when learning the Raspberry Pi:
Getting started with the Raspberry Pi – by Matt Richardson ($12)
Button Shield using GPIO and Ribbon Cable
This is a ribbon cable that was cut and systematically wired into the proto-board. I wired in all the pins even though in this case I am only using a few. This was because in the future I may want to add additional buttons or use other pins and this sort of setup means that the project can grow without having to start from scratch.
NOTE: You can see that I actually have 2 pull-up resistors wired to pins 23 and 24, but I am only using GPIO pin 24 right now but pin 23 is ready for an additional button as is. I was thinking of adding the second button for taking a video but have not yet had a chance to work that out.
The way that the pins need to be wired to the Raspberry Pi is like this:
(from the Adafruit example on wiring buttons to the RPi here)
Then you can test to see if they are pressed in python like this:
This line of code looks to see if the GPIO pin 24 is currently grounded (i.e. pressed), The pull-up resistor prevents this pin from appearing grounded unless the button has been pressed.
Mini USB cable
The USB cable can be easily made by cutting and shortenting any USB micro cable or done by purchasing these components from adafruit:
but if you buy these make sure that the wire you are using is thick enough to carry the current needed to power the RPi (my first attempt failed because I was using very small ribbon cable).
Autostart the camera.py file
Another thing I needed in case I had to switch batteries without connecting back to a screen was to make sure that it started the application on every boot. To do that I added a single line of code to the LXDE autostart file. I chose this file instead of a few other options because I wanted it to boot into LXDE and run the application in a terminal window from there so that I could see the button presses on the desktop. The file I edited is here:
and the additional command I placed at the end of the autostart file was this:
@lxterminal -e “sudo python /home/pi/camera/camera.py”
This basically starts an LXTerminal window and asks it to execute the command that starts the camera.py application
More Pics of the Camera
If you want to see the kinds of photos that can be taken on the RPI I put and album up showing a set of pictures I captured after making the first version of the Camera. That Album is here (ignore the first pic, that was the older prototype):
Next Steps: The Screen
Right now I am working on getting the screen (image above) working using just the 5v power from the Raspberry Pi GPIO header. To do this I plan on using a buck booster to convert the 5v to a 9v to keep in the 6-15v required by the screen. I may see if I can lower the voltage to 6v or see what the minimum the screen will work at in order to keep power waste to a minimum.