Pi Outdoor Timelapse Server

by MakrToolbox in Circuits > Cameras

30826 Views, 264 Favorites, 0 Comments

Pi Outdoor Timelapse Server

58b73fa97a76df8bb2000e63.jpeg
IMG_1964.jpg
outdoor Timelapse  camera test

So to preface the story let me explain. I own a Computer store where I repair computers, and other electronics and sell electronics. I also do Commisions for many custom electronics. This story documents one of those Commisions,

The Commision

I received a phone call from the local business in my town. The director and the head of maintenance wanted to photograph the progression of construction that was happening throughout the winter. They requested a time-lapse camera that would take a picture every so often (like once a minute), then when the construction is complete the photos would be gathered and compiled into a video showing the construction. Unfortunately the construction has been underway for several months already so the the time-lapse camera will miss the beginning of the construction. That was the extent of the conversation, and that is the way I like it, give me and end goal, a budget, and minimum desired output, and let me build.

Initial Thoughts and Ideas

The end product needs to meet these requirements.

Must have

  1. Needs to be able to access the "camera" remotely and Start / Stop / change settings / retrieve photos.
  2. Needs to be cost effective, ie ; cheap, this company is a non-profit and I need to respect that they have a small budget.
  3. Needs to be able to access the internet (see point #1) , most likely through wireless
  4. Needs to be waterproof, as the "camera" will be installed outside.

Would Like

  1. I would like to be able to integrate the photos into a web site easily.
  2. I would like some external notification when a photo is taken (like an LED blinking when the photo is taken)

Ideas

I Immediately thought of building it out of a Raspberry Pi, I have built a Raspberry Pi time lapse camera before. That is what I use to document progression on my instructables. I wanted to do this one a little bit differently so that I could Integrate the camera into a web site.

Parts and Software Used

IMG_1923.jpg
IMG_1930.jpg
IMG_1922.jpg

This is a list of the parts that I will use to make the Time - Lapse Camera system.

Parts

  1. Raspberry Pi 3 -- Here is a Link to it on Amazon
  2. Pi Power adaptor -- Here is a Link to it on Amazon
  3. Raspberry Pi Camera -- Here is a Link to it on Amazon
  4. Waterproof project box that fits the Pi. -- Here is a Link to it on Amazon
  5. Waterproof cable boot for cables -- Here is a Link to it on Amazon
  6. 25ft Extension cable -- Here is a Link to it on Amazon
  7. Chunk of 1/4 Lexan -- Leftover from a previous project
  8. Flexible Tripod -- Here is a Link to it on Amazon
  9. Window and Door Sealant -- I got this at my local Ace Hardware
  10. Heat Shrink -- Here is a Link to it on Amazon
  11. PCB Mounting Legs -- Here is a Link to it on Amazon
  12. 3d printed Pi camera frame -- found it on thingaverse, not my design

Software

  1. Cayenne installed on Pi (easy way to remotely restart and monitor Pi)
  2. Apache Web server
  3. Teamviewer Installed on Pi (used in setup)
  4. I found some code on Adafruit that helped me go in the right direction Here is a link to it if you want to check it out.

Beginning of the Pi Software

Capture2.PNG
  • Install NOOBS to SD card
    • NOOBS is an easy operating system installer which contains Raspbian. It also provides a selection of alternative operating systems which are then downloaded from the internet and installed. Download it here and install it to your SD Card
  • Install Raspian jessie "Pixel"
  • Install cayenne for remote monitoring
    • This is optional but it is very helpful, It allows you to restart and shut down form your phone, or any computer. It also has a remote desktop program that can be helpful as well.
    • Here is the link to setup an Account.
  • install teamviewer for Raspberry Pi

Installing Apache Webserver

visuno2.png
visuno.png
Capture3.PNG
Capture4.PNG
Capture5.PNG

OK there is a lot of information so I am going to get right to it.

Go to the Command Line on the raspberry Pi, I used Teamviewer and RDP so that I did not have to be right in front of it.

Type the following Followed by Enter

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install -y apache2 apache2-utils

sudo a2enmod cgi 

sudo mv /var/www/html/index.html to /var/www/html/index.html.org

For this next step you need to make sure you have downloaded the apache.tar file listed below onto the raspberry pi and moved it to home/pi/

cd /
sudo tar xvf home/pi/apache.tar 
sudo service apache2 start

sudo -i
visudo

add the line:

 www-data ALL=(ALL) NOPASSWD: ALL 

below the line starting with "root"

Then

Control-X and then Y to save.

Then you are done.

If everything worked right you should be able to open a browser and type "localhost" and it should open your Camera page.

Also from any computer on your network you can open a browser and type the ip address (another handy reason for installing cayenne is easely finding IP addresses of your Pi's) and it should open this same web page. From the web page you can start the camera and check out the pictures that it has taken.

Downloads

Editable Settings

Capture.PNG

There are editable settings that are contained in the timelapse.sh file. To edit the settings go to the command Line and type.

sudo nano /var/www/html/cgi-bin/timelapse.sh

From here you can edit the script.

Interval =60        

(this is the number of seconds between pictures, if you want a picture every 30 seconds enter 30 and so on)

The other one that is important is the destination directory, by default it is,

DEST = /var/www/html/images

but you could change it if you wanted.

The web site was designed so that you can click on the "review images" link and download the pictures form there, but I am going to show you an easier way.

Easy Way to Retrieve a Large Amount of Images

Capture7.PNG

Ok, so say you have like several thousand images taken and you want to download them, an easy way to do that is to install Filezilla FTP Client. Download is available on www.ninite.com if you need it. From here it is easy to add your ip address of your camera into the "site manager" and log into it. Then simply navigate to /var/www/html/images and highlight the images you want to download. Then right click and click "download" to download them. Easy peasy.

But What If I Want to Look at It From Work (or Anywhere Not on Your Network)

Capture9.PNG
58b74b8b45571465a5001a52.jpeg

Ok if you want to be able to find this from outside your network you will need to lock down the IP address that it will use and set up port forwarding and possibly DDNS. I will quickly walk you through it.

What is my IP address (how do I find it?)

So your IP address is your unique identifying address that each device is given from your router. There are internal IP addresses (the ones given from your router, usually 192.168.___.___.) and there are external IP addresses. The external IP address is to differentiate you from everyone else in the world. think of the router as the bridge that takes external IP addresses and routes it to the internal IP address where each packet goes. In Raspberry Pi you can tell your IP address by hovering your mouse above the network interface icon on the top-right of the desktop. I included a picture above to demonstrate.

So now you know what IP address on your network it is but what can we do with this handy dandy information. Well this is where it could be tricky. There are steps you can take to ensure that the raspberry pi would use a static IP address so that it would always stay at that adress, but I use a different method which I will show you using my TP-link router as a demonstration. So we are going to log into your router, first step is to determine what the address of your router is. You already know what subset you are using because you know your Pi's IP address, so if your Pi's address is 192.168.1.123, then your routers address is going to be 192.168.1.1. If your Pi's address is 192.168.10.237 then your routers address is 192.168.10.1 (*in most cases), get it, its easy.

Workaround to make the IP Address Static

My Pi's address is 192.168.1.123 so if I open a browser and go to 192.168.1.1 I will be greeted with a logon screen. If you set up your router then I hope you know your password, or a quick google search and you can find the default password if you never changed it, sometimes they are written on the bottom of the physical router. Ok so skip the inevitable 37 hours of cursing and calling AT&T to find your password and you should be logged into your router(luckly I remember my password).

You should be able to find a "DHCP client list" that will list everything connected to your router and the IP address and Mac address. I included a picture above so you have an idea of what to look for. Anyhow now that you are there, we want to write down that mac address. Then find the area that says something to the effect of "address Reservation". Enter the IP address of the Pi and the mac address and click "save". Now it will not change IP addresses on you.

In the next step I will explain Port forwarding

Port Forwarding

58b74f74471e3c6a1b002dcc.jpeg
Capture13.PNG
Capture14.PNG
58b75b7545571465a5001a96.jpeg

Port Forwarding

So now I will explain how to set up port forwarding, since we are continuing from or last step we should already be logged into the router and should know the address of the raspberry pi. We also have locked the Pi into that IP address so it will not change. Now we are going to tell the router that when we ask to see it from outside the network it will direct us to the correct place.

I want to pause for a moment and make sure that everyone realizes the implications of setting up port forwarding. I am showing the easiest and most direct route which is port 80 outside to port 80 inside. This is also the most insecure. you might want to set it up to use an obscure port and then transfer to the correct port using the port forwarding on the router. but in this tutorial I am going to demonstrate a easy port 80 forwarding sequence.

So you should be able to find something in your router menu that says port forwarding, or virtual servers. Click on the port forwarding and find the "new" button, under port type "80" for both internal and external or "service port". For IP address type the IP address of your Pi. Then under status change to enable. Your set up. You may have to reboot your router but that is all there is to it.

Find your External IP Address

Finding your external Ip address is easy, just open a browser and navigate to www.whatismyIP.com and it will tell you your external IP address. As a side-note, your external IP address will change unless it is static, you can call your internet provider and request a static IP address or you can set up something called Dynamic DNS, which is essentially a static web name that routes to your changing IP address. I included a picture of me using my phone to demonstrate using the camera off of the network.

The Enclosure for the Camera

IMG_1926.jpg
IMG_1927.jpg
IMG_1928.jpg
IMG_1929.jpg
IMG_1931.jpg
IMG_1932.jpg
IMG_1934.jpg
IMG_1936.jpg
IMG_1937.jpg
IMG_1939.jpg
IMG_1941.jpg
IMG_1944.jpg
IMG_1940.jpg
IMG_1942.jpg
IMG_1943.jpg
IMG_1946.jpg
IMG_1947.jpg
IMG_1948.jpg
IMG_1949.jpg
IMG_1951.jpg
IMG_1952.jpg
IMG_1953.jpg
IMG_1954.jpg
IMG_1957.jpg
IMG_1955.jpg

I started with an enclosure that would fit the raspberry pi but still allow enough room for the heat that the pi will create. I also wanted to be able to adjust the camera after the box has been mounted.

First I mounted the pi into the box, to do this I used the PCB mounting that I used in several of my other projects. These work well for mounting PCB's into enclosures. Once the pi was mounted I shortened the cable for the power to the pi and put it into the box. Then I drilled the hole for the waterproof boot for the extension cord. I used a 3/4in chisel bit to do this. Then I installed the waterproof boot and ran the cut extension cord through the boot, next I made the cord whole again with the help of a little solder and some heat shrink.

I wanted to be able to adjust the camera while the case was mounted outside, so what I did was use a leg from a flexible tripod and mount it to the box. Then I 3d printed a small frame that will hold the camera in place. I modified part of one of the leg segments so that I could mount the camera the way I wanted to. Now once I get the window installed in the enclosure I will be able to adjust the camera to pinpoint what I want it to be focused on.

I marked and cut the hole for the window using a dremel tool with a cutoff wheel. Ignore the photo above that shows me about to cut it using a wood saw in my dewalt drywall rotary tool. about 3 seconds later when I turned it on it spun up so fast that it broke the axle holding the blade in half and darn near cut me in half (Lesson: use tools as intended). So, I used the dremel tool, cut the hole, and cleaned the edges with a file. Next I cut a chunk of the lexan off using a fine blade on a miter saw. Then I put a bead of window and door seal around the window area and stuck the lexan chunk to it. I also put some window and door seal around the bolt on top to make sure it does not leak.

Installing the LED

IMG_1958.jpg
IMG_1959.jpg
IMG_1960.jpg
IMG_1961.jpg
camera_GPIO-Diagram.png

ok, if we are being honest, I forgot to install the LED when I was putting it all together. I wanted to have an LED that would blink when it takes a picture. It is already in the software, I just need to hook it up. I took an LED (I used Blue) and soldered a resistor onto the positive side, and soldered that to some jumper wires. I made sure to cover all exposed wire with heat shrink. Then I drilled the hole in the front of the enclosure the same size as the LED. and pushed it through and put a small puddle of hot glue over it to seal it. The positive side of the LED goes to GPIO 5 and the gnd to , you guessed it, ground.

Finished

outdoor Timelapse  camera test

I have used this for a couple weeks now and it works great. I ended up making several of them. I will be using these for years to come. Above is a test video that I did over a weekend. Thank you for taking the time to check out this project. I hope I explained everything good enough.

Special Thanks to

Ernie Garner for helping me code and for all of your help.

Don't forget to Favorite, Comment, Follow and Vote.