Adafruit has a tutorial on how to diy a wireless camera with touch screen. There are also instructions on how to build a time-lapse camera.

This project mixs these two features, and aim to build a wireless time-lapse camera using Raspberry Pi, which is much eaiser than a wireless time-lapse camera in Arduino.

Hardware

Development evironment

  • Raspian (OS for Raspberry Pi)
  • Python
  • PHP

Tutorials

1. Initialize Raspian

2. Setup Wifi

3. Setup remote server

I use a regular LAMP on my server.

Here is the PHP file that I ues to receive photos from Raspberry Pi:
Camera.php

Upload this HTML file, browse it in your browser to make sure your upload feature work properly.
Up.html

4. Camera test

Make sure your camera work properly before you proceed:

raspistill -o cam.jpg  
            

You should see a photo captured in your home dir.

Implement python script

Instal python setup tool:

sudo apt-get install python-pip  
            

Install required python packages:

pip install picamera  
            pip install PIL  
            pip install requests  
            pip install urllib2  
            

Upload python files to your home dir on your Pi:
Camera.py
Upload.py

Camera.py simply takes one photo every 20s.

Here is what upload.py about to execute:

Indicate the remote server:

url = 'http://SERVER/camera.php'  
            

Upload.py use internet_on() to test the Ineretnet connection first. If the Internet connection is avaiable, weather or not it is WLAN or LAN, it uploads photos in the pic dir, and moves uploaded photos to uploaded.

It assumes that all photos are JPEG files:

file.endswith('.jpg')  
            

And removes all file with 0 size in case photo files created mistakenly:

filesize = os.stat(path).st_size  
                if filesize > 0:
                    pics.append(file)
                else:
                    os.remove(path)
            

Comment out these lines if you don't have a rotation problem as I encountered, c

    im = Image.open(current_name)
                out = im.rotate(180)
                out.save(current_name)
            

Then upload.py post it to the remote server:

r = requests.post(url, files=current_file)  
            

Comment out these line if you don't need any thumbnail images:

#save a thumbnail
            out = im.resize((128, 77))  
            out.save('/home/pi/thumbnail/' +filename)  
            

5. Test wifi upload

Make sure your wifi network work properly.
Execute each python scripts:

python camera.py  
            
python upload.py  
            

You should see the latest photo appears on your sever side. Or error info to debug.

6. Setup crontab script

Create a startcamera.sh file:

nohup python /home/pi/camera/camera.py > log &  
            

Make it executeable:

chmod +x startcamera.sh  
            

Lanuch camera on start:

sudo vim /etc/rc.local  
            

Add line at its beginning (do not add it in any IF-ELSE block):

/usr/bin/python /home/pi/camera/camera.py >/tmp/camlog 2>/tmp/camerr &
            

Create a upload.sh file:

python /home/pi/camera/upload.py  
            

Make it executeable:

chmod +x upload.sh  
            

Run upload script on start:

sudo crontab -e  
            

Add line:

*/1 * * * * /home/pi/upload.sh >/tmp/upload 2>/tmp/upload.err
            

Setup autostart when device boot

Restart the device to test:

sudo reboot  
            

Appreciate:
http://weibo.com/huangdong