Surprise surprise another post from the Average Man using the ProtoCam board!
Today I’m using my ProtoCam board to make a PiCamera with a small LCD unit attached, that I will be using as a camera menu interface. It will be used to select the camera mode, give a nice message before and after the shot, and show the number of images taken.
In fact it can be used for anything you want really, LCD units are fun like that! I will look to turn this into a timelapse image & storage space display at some point.
In this project I’m using an 8×2 LCD unit from Hobbytronics, as its small size means it fits on my new ProtoCam camera module prototyping board – and it also uses the HD44780 controller that I’m familiar with from other displays.
What you need
If you want to try this project, or make something similar, you’ll need the following:
– A Raspberry Pi (Model A works better for this project as it leaves even more space under the add-on board)
– A Raspberry Pi Camera Module
– A ProtoCam board
– An 8×2 LCD display (HD44780)
– A Breadboard
– Jumper Wires (mixed ends)
– 2x 8-pin male headers for the display
– 2x Potentiometer (I’m using 10k, you may wish to adjust)
– 2x Tactile Switches
– 2x 10k Resistors
– An LED
– A suitable resistor for your specific LED
– Thin wire
– Soldering Iron
– Safety Glasses (no one likes solder spit in the eye)
– Wire Cutters/snips
Read through this post before ordering anything, to get an idea of the amount of wire and other things you may need. There are lots of other tools/helpers you may want to make use of.
Prototype the Project
It’s always best to try things out as a ‘dry run’ as such, before soldering permanently and regretting any potential mistakes (we all make mistakes).
Solder the LCD pins
To use the LCD unit in both the prototype and the ProtoCam board, we need to give it some header pins.
Solder the 8-pin headers into the LCD holes so that the longest pin side is at the rear of the board, like this:
Once you’ve done that, we can get cracking on the breadboard.
Assemble parts to the breadboard
Now we assemble the parts on to the breadboard, after which we will hook it all up to the Pi and cross our fingers!
The LCD is obviously the main piece here. Unfortunately the arrangement of the pins in this little 8×2 LCD module means it’s not possible to push it straight into a breadboard (not any breadboards I have anyway), so what we need to do is kind of ‘break out’ the pins using female-to-male jumper wires.
Here’s a picture to show you what I mean – each pin is attached to the female end of a jumper wire, which kind of makes an exploded version on our breadboard which we will then hook up to the Pi.
The pins match the common 16×2 LCD units you see everywhere, which use a HD47880 controller. There are usually 16 pins in a straight line with these displays, but as the 8×2 display pins are across 2 rows, I’ve drawn up the pin mapping from the perspective of looking at the rear of the unit:
Connect each pin as instructed above – use a labelled breakout board or Port Labels Board to help you get the pins in the right place.
You then need to add a couple of switches to the side which we will hook up to GPIO pins – this will allow us to select things on the menu we make with the code. I’m using 2 small tactile ‘momentary’ switches. Each one needs to be hooked up to a separate GPIO pin (I’m using 25 and 4), and will be wired up like this:
A little hint here – don’t fall into the same trap as me. These little switches seem simple but you must consider how their internals work – I ended up wiring mine up wrong as I didn’t realise how the ‘insides’ worked.
Here’s a picture that Jason Barnett shared with me on Twitter to explain the internals of the switches. In a nutshell – the GPIO and GND should be on one side, and the 5V/3.3V on the other – click the switch and power joins the circuit, shoots into the GPIO pin and sets it high. Thank you Jason!
Push the 2 potentiometers in to your breadboard with plenty of space around them. Pin 15 and 3 from the LCD unit need to be connected to one of these each (15 in one, 3 in another), wired as follows:
Wire it up!
Now connect all of these parts together as instructed above, being careful to get the GPIO pins in the right place.
The images above should give you everything you need. You can get messy with jumper wires like me, or do it the tidy way and get some of those flat ones that make much more sense.
Create The Python Script
This project was a little easier to code for me as I have used this kind of display previously with my Internet Radio. All of the displays with the HD44780 controller seem to work the same way, with just a tweak here and there depending on the size of the display being used.
My code gives you an initial display showing the number of images in the camera image save directory, and gives you an option to go to a camera selection menu.
The menu offers you the option to take a still shot or shoot a video:
Either option will humour you with some nice messages before/after the image/video is taken, and the LED will light up when the camera is on.
I’ve added notes to my script to guide you on what the various sections of code do, so that you can learn how it works and make changes to create your own spin of my creation. All part of the fun!
The script is over on PasteBin at the link below:
This is just a little fun program to test it all works – I think this would be great as a timelapse monitor to show you the % of space left in the SD card, and/or the number of images taken. Maybe even the time running. Endless possibilities!
Soldering The ProtoCam
How To Solder
Before we begin, if you’re a little unsure about your soldering skills, RaspberryPiSpy has written a great post listing a collection of soldering guides, so you should find everything you need over on his blog:
The thing to remember here is you’re not looking for professional factory-standard joints, just a simple soldered connection. Don’t worry if it isn’t very pretty, the important thing is that it works (just look at some of my examples in this post, not the best!).
Plan Plan Plan!
The important thing with boards like my ProtoCam is to take a good amount of time planning the layout before even reaching for the soldering iron. As these boards are usually Pi-sized, there’s only so much space to play with, however if you’re clever you can get quite a lot on them.
So…start off with pushing the various parts into the board. You’ll need to consider how to make use of the connected ‘lanes’ to help your soldering, space between parts, distance from the GPIO section and practicality of the finished product.
I guarantee you’ll go through at least 5 versions of your layout before you’re happy with it – but take your time and make sure it’s right!
Solder The Parts
You’ve planned your layout, checked that it will all solder without any issues and have your soldering iron heated up ready – time to do the serious stuff!
You might think that soldering the individual components to the board first is the sensible option, however you might be wrong. Depending on your layout it’s sometimes easier to solder the connecting wires first, or a mixture of the two.
It’s very difficult to do a point by point soldering guide for this specific project, and part of the fun is working it out for yourself and making changes to create your own design, so here’s some progress shots of my soldering to give you some ideas:
One thing I would definitely recommend is not buying the same cheap wires that I have used. The coating melts when soldering and leaves a lot of exposed wires. There are better alternatives with a more heat-resistant coating that make life a lot easier.
After soldering the parts and connecting wires, you should end up with something like this:
What a fun little project we have here! A great way to practice soldering and learn about new components/LCD displays, whilst creating something that can be re-coded again and again, making different menus and display text for the LCD, and different button commands including controlling the Camera Module.
Yes the ProtoCam is my design so naturally I think it’s brilliant, but I do really think it gives you great flexibility for projects like this. We could have easily swapped out that display for a PIR or ultrasonic sensor, an LED matrix, Infra Red LEDs and much more.
If you want to get yourself a ProtoCam to make a project like this, they’re currently for sale at ModMyPi.
This wasn’t the simplest blog post I’ve written, so if you get stuck or need any help just shout – comment below, Tweet me, find me on Facebook or send me an email.