Pi Cam Assembly

I have wanted to build a motion activated and time lapse capable raspberry pi camera for a while now but never really found a case I like. I found this nice case for a raspberry pi and camera on thingiverse. It was designed for a specific fisheye camera but looking at the model it appeared that one of the cheap Chinese fish eye cell phone lenses I have would fit nicely in the hole.

I fired up tinkercad and used my calipers to measure the space inside the camera case and the thickness of the RaspiCam board and created a model to mount the official RaspiCam. I used two small pieces of gaffers tape to attach the camera to the support piece, snapped the lens into the hole in the case and slid the camera into the case. You can find my camera part here

This is really a nice simple project, any raspberry pi and camera case will work, you will also need:

  • Raspberry Pi Model B or B+, 2 or 3
  • Raspberry Pi Camera Board
  • Raspberry Pi Camera Cable
  • Button - I used on of these
  • 2 Female Jumper wires
  • Cell Phone Fisheye lens
  • SD Card

Halt Button

I soldered a couple of female jumper wires to a small momentary switch to use to halt the pi for both the surveillance and timelapse setups. For the timelapse software I am using the code from this Adafruit project which includes code for a halt button.

I have stripped this script of the time lapse features for use on the surveillance camera. Because I wanted both of these camera projects to automatically start on boot I have chosen to have two SD cards set up with raspbian lite that automatically boot into either the surveillance or timelapse camera mode. The button is connected to gpio 21 and ground on the pi, the last two pins next to the usb ports.

Motion Camera Software Setup

Since I didn't need a desktop OS for this project I downloaded the Raspbian Jessie Lite image and installed it on a SD card using Disk Image Writer in Ubuntu.

Once I booted up the raspberry pi I used raspi-config to expand the file system, set internationalization options for keyboard, time and wifi, enabled the camera, overclocked the CPU and enabled SSH.

The next thing I did was to disable the camera LED since I didn't want the camera to indicate that it was on.

// Edit the config.txt file
sudo nano /boot/config.txt

// Add the following line

The standard version of motion from apt does not work with the RaspiCam module, but there is a community supported version that has been compiled for use with the RaspiCam. There is more information on a wiki here.

Below are the commands I used to install the custom motion binary for the RaspiCam with the latest version of Raspbian Jessie Lite.

Pi Cam Assembly

// Install the motion prerequisites
sudo apt-get install -y libjpeg-dev libavformat56 libavformat-dev libavcodec56 libavcodec-dev libavutil54 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev 

// Download and unzip the raspberry pi specific motion binary
wget https://www.dropbox.com/s/6ruqgv1h65zufr6/motion-mmal-lowflyerUK-20151114.tar.gz
tar -zxvf motion-mmal-lowflyerUK-20151114.tar.gz

// Test out the results
$ ./motion -c motion-mmalcam-both.conf

If you see success messages logged in the terminal after running motion, point your web browser to the ip of the raspberry pi port 8081 and you should see your camera streaming.

Timelapse Camera Software Setup

I downloaded the pre-build SD card image from Adafruit I used raspi-config to expand the file system, set internationalization options for keyboard, time and wifi, overclock the CPU and enabled SSH.

The pre-built card just works, boot up the pi and it starts taking timelapse images, hold down the switch and it shuts down the pi. I want to build the pi zero wearable version of this project but don’t yet have all the parts.

Once I had a bunch of images I made a video using FFMPEG

ffmpeg -f image2 -i img%06d.jpg time-lapse.mp4

These are both a couple of nice raspberry pi camera projects that don’t require many parts..

Linux, Ubuntu edit

When I started using Linux printers eluded me a bit, my Canon multifunction printer did not have good linux drivers for quite some time and initially I could not find any software to run my small Brother label printer. Eventually Canon improved their driver and I found a program called blabel for my brother label printer.

I have been shipping enough 3D printed objects on 3DHubs that I became annoyed with printing out labels with my inkjet and then tapeing them to padded envelopes. A long time ago I worked with some commercial thermal printers and figured that was the way I wanted to go since they don’t smudge or use any ink. I looked a couple of different times but the printers were still pretty expensive. Eventually there was a sale and I purchased a Dymo LabelWriter 450 Bundle for $49. Before purchasing I checked and there were linux cup drivers available since I only have windows running in a VM.

Once you have downloaded the drivers, unpack them and then install.

    cd dymo-cups-drivers-
    sudo ./configure
    sudo make
    sudo make install

Once the drivers were installed I added the printer using the built in Ubuntu add printer wizard and installed glabels. The bundle I bought came with 4 different types of labels that I was able to create custom templates for in glabels and print some stickers for my friend’s company.

HG Logo

And some warning labels for their trailer:

HG Logo

The bundle did not include the right labels for printing USPS Shipping labels so I purchased these labels. I set up the shipping labels in the preferences for the printer and then went into my paypal multi order shipping options and adjusted the following settings.

Paypal Setup

Now I can easily print shipping labels for 5 cents each and don’t have to mess with cutting and taping anymore.

Linux, Ubuntu edit

Print one at a time settings

I have been dual booting with Windows 8.1 & 10 and Ubuntu for a couple of years now. For much of that time I mostly used windows for day to day tasks and used Ubuntu to play with git, node and ruby applications which generally work much more easily on linux. I have a MSI Nightblade gaming pc with an I5 a NVIDIA 980 Graphics card and 16GB of ram. I am currently running Ubuntu 15.10 desktop.

When I started with Ubuntu most but not all of my hardware worked. Since I was still dual booting with windows I didn’t spend a ton of time trying to find solutions but over time updates to Ubuntu fixed some printer annoyances with my Canon WiFi printer and NVIDIA improved the drivers for my graphics card. Dual monitor support is now great and I am pretty happy with the ambiance theme I have been using.

I use Libre Office when I need to open an office file, and Remmina Remote Desktop Client to connect to my office computer running windows via RDP. Both of these are built into ubuntu. There are also nice built in utilities for tasks like CD/DVD burning, making bootable USB keys, unzipping files and viewing PDF’s as well as a host of other things. Often searching the dash surfaces a program already installed for doing what I need. I installed the gimp for image editing and it works pretty nicely despite requiring you to “export” everything to save it in a useful format.

I have a 3D printer and have found the USB Serial connection that 3D slicing software to print parts when connected to a computer seems to generally be more stable on linux. Once power management settings that could affect a print are off it just works. The two slicing programs I use Cura and Simplify3D are both cross platform and have linux versions available that work equally well as their windows counterparts.

For software development I have been using git in the command line and either Github Atom or Visual Studio Code as my editor. I enjoy Terminator for my terminal. Node jekyll ruby and python all work really well on ubuntu without all the tedious setup required on windows.

For a web browser I use google chrome as it can be set up to work with sites like netflix and amazon prime video. Once WebGL is working I was also able to use Onshape and Tinkercad in Chrome as well.

In November of 2015 a Windows update destroyed the network drivers for my desktop in Windows, I tried a number of things to get it fixed but could never get it connected to the internet again.

I kept the windows partition on and used it occasionally for the few remaining things that I could not do on linux. Over time I found linux based solutions for all of these issues. I have a small brother label maker that has a windows exe file embedded in the printer that you use to print the labels, I found a small linux program Blabel that does the same thing, and is easier to use than the brother software. The last piece of hardware I had not found a solution for was my USB microscope. My 6 year old daughter uses it to look a things, and I found a nice program called Guvcview that supports my microscope. I use Angry IP Scanner to find newly configured devices on the network.

Recently I found a good deal on two mSATA hard drives that I can configure as a primary and recovery disc on my Nightblade desktop. I backed up both my windows and ubuntu files and then did a fresh single boot install of ubuntu on the new hard drives. I thought about dual booting with windows again, but the install is so long I decided I just didn’t need it anymore.

I even wound up being able to keep both Windows 7 and Windows 10 available to me via VM’s in VirtualBox. I have 3 Windows 7 Ultimate keys that allow for virtualization so I made two Windows 7 VM’s and then upgraded one of them to 10. I used the windows 7 vm to upgrade the firmware on my router since only windows software was available.

Windows is gone from my home and my PC has never ran faster, Ubuntu may be a pretty heavyweight linux distro, but it is much slimmer than windows and I am very pleased with my new setup.