We made a Raspberry Pi camera that captures GIF files and optionally tweets them over WiFi! It's built around a Raspberry Pi Zero W and a Pi Camera module. The camera connects to a pre-programmed WiFi network to tweet the gifs, but you can also retrieve them from a shared folder if you have another computer on that network.
Gidday, welcome to the lab, my name’s Michael and today I’m going to be showing you my Raspberry Pi Zero W Gif Camera.
So this is a camera based around the new Raspberry Pi Zero W and it doesn’t snap photos - it actually snaps moving images as Gifs. Now because it’s a Raspberry Pi Zero W it also has the option to tweet the gif that you snap to a twitter account of your choice. So lets take a quick tour of the camera.
On the front we have the protrusion for the camera module and you can see the cameras light shining through there, we have this nice analogue view finder. On the side we have our power switch and USB charging port and you can charge this like any modern device off a USB port and on the top we have an illuminated shutter button. There’s a few redundant holes in the case like this one in the bottom which was originally for a USB drive and this one here which I think was originally for the power switch. That is our complete camera!
We also have a little status LED peeking through here. So, let’s quickly snap a GIF. Lets just place this on top of our studio camera - alright and GO!!! Ah, I think I just got into the back of that. So it takes about 5 seconds to capture the GIF and while it’s capturing this yellow light is strobing. Once its finished capturing the GIF we have this processing light to tell us that the Raspberry Pi is stitching the single images into a GIF. Now that the processing is complete we can actually jump on the computer and take a look at the GIF that was created.
So i’ll open up my file explorer and if i go to backslash, backslash, GIFcam you can see that the Raspberry Pi is hosting a shared folder that we can access over the network So not only can it tweet the GIF but we can also retrieve them directly from it . I can go into the GIFs folder and there is the GIF that I just took. I’m going to copy that onto my desktop and we’ll see if I got into the frame in time. Alright, lets take a look, here we go and look, I just get in! So you can see the GIF is actually playing forwards to the end point and then its coming back to the start. So it’s kind of running forwards then backwards repeatedly.
The camera is driven by a single Python script. I’ll show you how we can modify the behaviour of the camera by just tweaking a few variables within that Python script. I’ve opened up PuTTy and I’ll be able to SSH to my camera because its already on the same network by using its host name which I have set as GIFcam and i can log in. OK, so now we’re in the GIF camera and you can that in the home directory all I have is the GIFCAM directory so I can change into that and we have the gif cam.py script. This is the script that is running the camera. I’m going to open that up with nano and now we’re inside the script, and the behaviour of the camera is controlled by these so called behaviour variables and this block near the top. This is where we can change the number of frames that are in the GIF, the millisecond count that the frame is displayed - so intros case each frame is displayed for 15 milliseconds, rebound which determines whether the GIF plays from the start to the end or if it plays from the start to the end and back repeatedly. It kind of changes the looping behaviour. Then there is the tweet variable which is currently false, that allows the camera to tweet or not tweet. To have it actually tweet you need to come down here and populate these twitter authorisation tokens for your twitter app that you need to create. So clearly I’m going to have to now reset the authorisation tokens for my twitter app but that’s just these top two sections - so you’ve got this twitter section beneath this behaviour variable section. So those are the two key areas of the script if you want to modify the cameras behaviour.
So, let’s actually snap a gif, we can see that the yellow light is on which is indicating the ready status so if I were to press the yellow button we can see now that it is strobing which is indicating that it is capturing a GIF and that takes about 5 seconds on the settings that I have. Now once the GIF is captured we have the red processing light blink and this light will blink while the still images that were captured are being stitched into a moving GIF and also the blinking behaviour changes if you have the GIF then uploading to your twitter account. So that is completed now - ok enough of playing around, let’s actually see what’s inside this thing!
I’m going to turn it off and let’s tear it down a little bit. There we have it, I’ll just zoom in a little bit - so this is the internals of the camera and the first thing you might notice is I’ve been pretty liberal with the use of hot glue and there is good reasoner that I promise. Let’s just have a look at the topology first, so we have our Raspberry Pi right in the middle here, and I’ve actually wrapped that in Kapton tape which is an insulating tape. Just because it’s crammed right in there, there’s a lot of wires, you can see that there is some connections here so I’ve just wrapped the whole thing up to keep it nice and safe. It’s connected to a Lithium battery that’s in the case. We have our shutter button coming in here, our status LED nestled in this little nook right here. This circuit board is our charge controller so it’s actually both a battery charger and boost circuit so we can run the entire show which operates on 5 volts off a 3.7 v Lithium battery and charge it through that USB port. So that’s all built in, that’s an Adafruit PowerBoost 1000C and that’s the model that gives you that very convenient USB socket. This is just the power switch, it’s connected to the enable/disable line of the PowerBoost and then everything just comes together to power the Pi. So, the Pi is connected - it’s a bit hard to see - it’s actually impossible to see the Pi is connected to the camera module using a Pi camera ribbon cable and at the time of building I only had access to a very short cable so that the Pi couldn’t actually mount to where it was originally intended to when the case was designed. So that is just a quick run down of the internals of the camera and you can see there is definitely room for perhaps a larger battery or more batteries. So, you could roll your own battery pack using Nickel Metal hydrides and use a different charging controller no worries.
If you’re interested in building your own version of this Tweeting GIF Camera you can find a full write up in the project section of our website - so over on coreelectronics.com.au you can navigate to the projects tab and find the Tweeting GIF Camera. So let’s take a quick look through this page and you can see we’ve got some basic installation instructions on how to set up the appropriate software to get the camera to run as you want it to. I’ve also done a bit of a write up on the 3D printing, there’s a circuit diagram here for you and then just a few instruction steps on how to modify the battery if you need to and just how to general assemble the camera. This is the shot that we got a closer look at just before.
So there you have it - the Tweeting Raspberry Pi Zero W GIF Camera. Now if you have any questions about anything specific to do with building the camera or if you have any suggestions for improvements we can make to the project we’d love to hear from you on the forums - I’ll catch you later :-)