Pi Outdoor Timelapse Server




Introduction: Pi Outdoor Timelapse Server

About: I am 37, I have a job that allows me to build and make daily. I love my job. I have 6 children, my oldest is also a maker and has written her own instructables. I own a computer repair shop, and I build a lot …

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,

Step 1: 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.

Step 2: 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)


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.

Step 3: Parts and Software Used

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


    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


    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.

    Step 4: Beginning of the Pi Software

      • 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

      Step 5: Installing Apache Webserver

      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

      add the line:

       www-data ALL=(ALL) NOPASSWD: ALL 

      below the line starting with "root"


      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.

      Step 6: Editable Settings

      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.

      Step 7: Easy Way to Retrieve a Large Amount of Images

      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.

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

      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, then your routers address is going to be If your Pi's address is then your routers address is (*in most cases), get it, its easy.

      Workaround to make the IP Address Static

      My Pi's address is so if I open a browser and go to 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

      Step 9: Port Forwarding

      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.

      Step 10: The Enclosure for the Camera

      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.

      Step 11: Installing the LED

      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.

      Step 12: Finished

      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.

      Microcontroller Contest 2017

      Participated in the
      Microcontroller Contest 2017

      Be the First to Share


        • CNC and 3D Printing Contest

          CNC and 3D Printing Contest
        • Puzzles Challenge

          Puzzles Challenge
        • Lamps Challenge

          Lamps Challenge



        5 years ago

        Nice article, I've had a similar setup pointing at my garden for the last 12 months. Instead of serving from the RPi though I write photos to cloud storage so I don't have to worry about physical storage running out, it also removes the need for port forwarding etc.

        The biggest challenge I have had is stitching thousands of files into a time lapse movie as so far all programs have crashed.

        My next phase is to power via solar but then I need to work out how I manage connectivity if it's remote, or I store everything locally.


        Reply 5 years ago

        Here's my script that converts all the pictures to an AVI file using mencoder. This is using my pogoplug and webcam using mjpeg_streamer, but you can modify it for use with RaspiStill... This bash script is run every two hours via Cron, it basically:

        1. Kills the current instance of mjpg_streamer (stops the timelapse recording)

        2. Renames the directory holding the timelapse pictures

        3. Creates a new directory (cam1)

        4. Runs a new instance of mjpg_streamer with output path to cam1 and output to port 80 (so you can browse to it via http). From step 1 to 4 it takes about half a second, so this new instance of timelapse files continues with a loss of at most 1 second footage.

        5. Creates the list of timelapse pictures (in our renamed directory) in a text file STRNAME1.txt

        6. Run Mencoder. This takes the list of files from STRNAME1.txt and generates the AVI file (with name pogoplug-2017.03.05.1000.avi if it ran in Mar 5, 2017 at 10AM)

        pkill mjpg_streamer
        STRNAME1=pogoplug-$(date +%Y.%m.%d.%H%M)
        STRDIR=/media/hdd/share/processed/$(date +%Y.%m)
        if [ ! -d "$STRDIR" ]; then
        mkdir $STRDIR
        mv /media/hdd/share/cam1 $STRPATH1
        mkdir /media/hdd/share/cam1
        /usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -d /dev/video0 -f 10 -r 1600x896"\
        -o "/usr/local/lib/output_http.so -p 80 -w /media/hdd/share"\
        -o "/usr/local/lib/output_file.so -f /media/hdd/share/cam1 -d 1000"\
        if [ -f STRNAME1.txt ]
        rm STRNAME1.txt
        ls $STRPATH1/*.jpg > STRNAME1.txt
        mencoder -nosound -mf fps=15 -o "$STRDIR/$STRNAME1.avi" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=8000 mf://@STRNAME1.txt
        rm -r $STRPATH1


        Reply 5 years ago



        5 years ago

        Any problem with ventilation? I'm concerned about putting a Raspberry Pi in a totally enclosed space without adequate air circulation...


        Reply 5 years ago

        I was conserned about it overheating, and I acually designed active cooling to be integrated into this design, but I ran it for 1 week enclosed and it stayed a consistent temperature without overheating. another advantige of using cayenne is temerature monitoring


        Reply 5 years ago

        I had issues with RPi overheating when I built a Magic Mirror and placed it inside the frame. There were lots big holes on top and bottom of the frame for air circulation and I had the mirror in the basement so room temperature was nice and cool, but my RPi almost always hangs/crashes after a few days. When I placed it outside the case, the problem went away. So in this case, I'm concerned that if I place it inside an airtight case like this, and use it during the summer, and I'm thinking of putting it in a tree with shade, I'll probably have to put some aluminum frame or something to dissipate the heat...

        Dustin Rogers
        Dustin Rogers

        5 years ago

        Nice project. I've always thought it would be neat to have this capability but with something with low power consumption that could be charged via solar so that it could run wirelessly. It'd be cool to mount to a post near some new construction and capture the whole build.


        Reply 5 years ago

        yep that is what I built it for, the company I built it for like it so much they have all kinds of ideas how they are going to use it in the future.


        5 years ago

        i have been looking for something like this. But would like to know how to set it up for autostart at bootup. and added a line for date and time inbeded in the file

        raspistill -n -w $WIDTH -h $HEIGHT -q $QUALITY -rot 180 -th none -t 250 -o $OUTFILE

        sudo convert $OUTFILE -pointsize 25 -fill black -annotate +1000+700 %[exif:DateTimeOriginal] $OUTFILE


        Reply 5 years ago

        It is all quite possible but will require some bash tinkering.

        You can launch a script on boot (see http://bit.ly/2m8Xd8l) but I don`t think it is the best option for this case - using cron would give you more control.

        With raspistill you can certainly set output dimension and quality (and what not) such as raspistill -w 1024 -h 768 -q 80 -o image.jpg - see http://bit.ly/2lM9eyK. If you, however, desire a variable in a file name, you better explore the bash - see the post I have just made, I believe it does exactly what you want and allows easier editing.


        Reply 5 years ago

        It does autostart by itself. I think apache is set to autostart from install. I could be wrong butI dont think I did anything extra to tell apache to autostart.


        5 years ago

        Thanks for the tut (I will definitely check your way of moving the apache to home folder), I am actually planning something similar, perhaps with a discrete fan powered by the GPIO pins added for the summer heat.

        Now, here are my two cents as for having the images immediately visible in a webpage (hosted on the Pi webserver):

        CASE: There is a public webcam shooting an image every 5 minutes that I occasionally check to see what the weather is like in the area. But could I have an automated record accessible by my friends?

        Yes - ad it is all done with a short bash script:

        date +"%Y-%m-%d_%H-%M-%S"
        timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
        cd /var/www/html/mycamfeed
        wget https://www.metronet.cz/img/kozakov.jpg
        mv kozakov.jpg kozakov-$timestamp.jpg
        echo '<li><a data-gallery="1" href="kozakov-'$timestamp'.jpg">
        <img src="kozakov-'$timestamp.jpg'"></a></li>' >> xxx.txt

        This is what it does:

        1. First define a date format and a timestamp variable (will use it later)

        date +"%Y-%m-%d_%H-%M-%S"
        timestamp=$(date +"%Y-%m-%d_%H-%M-%S")

        2. Then cd to a folder of your liking (if you don`t want your script stored directly on the webserver, which sounds reasonable):

        cd /var/www/html/mycamfeed

        3. Then download the current webcam image (nothing complicated as the new image always rewrites the old one):

        wget https://www.metronet.cz/img/kozakov.jpg

        4. Then rename the downloaded image - add the previously defined timestamp to its default name so as to easily track when a picture has been taken:

        mv kozakov.jpg kozakov-$timestamp.jpg

        Save the script as timelapse.sh and make it executable (sudo chmod +x timelapse.sh). If you now add a cron job (or use the Gnome-schedule on the RasPi) and make it run the script every 5 minutes every day between 7am and 7pm (why bother downloading night images, right?), you start gathering a set of neatly renamed images for your timelapse.

        5. Now, how to get the images to a html page running on the Pi? To me, Fancybox or lightbox gallery sounds as a good idea. That`s what the last line of the script is for:

        echo '<li><a data-gallery="1" href="kozakov-'$timestamp'.jpg"> <img src="kozakov-'$timestamp.jpg'"></a></li>' >> xxx.txt

        For every new image this essentially adds a new line to a text file xxx.txt. If it looks familiar to you, you are right, it is the fancybox gallery item.

        So, go ahead and grab a fancybox demo somewhere on the Internet. Keep the header with the default fancybox .js and CSS stuff and save it as timelapse.php in /var/www/html/mycamfeed. Open it in a text editor and add

        <?php include 'xxx.txt'; ?> <!--(replaces the default <li></li> stuff) -->

        inside the <body></body> (make sure the paths are okay).

        You have thus included that file xxx.txt with a formatted line for every new downloaded image to your fancybox gallery.

        Make sure you have php installed on the Pi and try opening it as http://raspi-ip-address/mycamfeed/timelapse.php. Voilà, gallery with images added every couple of minutes is there.

        For sure you can tinker further - the above uses full image also as a gallery thumbnail so you can add a line with something like

        convert kozakov-'$timelapse.jpg -resize 300x200 thumb_kozakov-'$timelapse.jpg

        to generate a resized gallery thumbnail and then alter the entire gallery entry to

        echo '<li><a data-gallery="1" href="kozakov-'$timestamp'.jpg"> <img
        src="thumb_kozakov-'$timestamp.jpg'"></a></li>' >> xxx.txt

        You can use ssh to monitor the Raspi temperature, control the cron job and vsftpd to download and archive the images in case the Raspi storage gets full or the entire thing gets broken/stolen. You can have every image automatically uploaded to another server for improved performance. Or you can even set another cron job to this automatically once every week. And it is easily applicable to whatever you do with Raspistill. ;o)

        It was quite fun, actually, hope it will be of value to you too.


        5 years ago

        Would Magic Lantern on an (expensive) full DSLR really be cheaper than the <$100 this probably cost? Plus added theft risk, plus waterproofing (very expensive scuba housing?), plus remote access was a requirement.

        Awesome job, great end result, and phenomenal documentation. Voted, thanks!


        5 years ago

        Agreed with Steve but this one yells custom made, and that too me makes more money off word of mouth then a little trick worth something pre made.


        5 years ago

        Neat, but you could have made more money, or charged the client less if you used Magic Lantern running on a Canon camera, out of the box, apart from remote access.


        5 years ago

        great project.

        i made something similar, so pay attention on sd card life. in one month my sd card was killed.
        i suggest you to add an external usb hdd where you can save all the pictures.
        on my project i made root fs read only and i upload all the pictures on a nas via nfs protocol.