RaspberryPi/Timelapse2: Difference between revisions
From charlesreid1
| Line 38: | Line 38: | ||
</pre> | </pre> | ||
But that's ok, because we can use pip instead! | But that's ok, because we can use pip instead! | ||
First, install screen so we can install all this stuff in the background, without having to keep a terminal window open: | |||
<pre> | |||
sudo apt-get install -y screen | |||
</pre> | |||
Then install tools onto the Pi: | |||
<pre> | |||
sudo apt-get install -y vim aptitude python build-essential | |||
</pre> | |||
Now we shouold have pip and be able to install the Pi camera API: | |||
<pre> | <pre> | ||
pip install python-picamera | pip install python-picamera | ||
</pre> | </pre> | ||
Revision as of 10:18, 29 July 2016
Outline
For this project, I was replicating the Raspberry Pi timelapse setup from the RaspberryPi/Timelapse page.
Hardware
- Raspberry Pi
- Pi camera
- Camera case
- Network cable
- Power cable
Setting up the Pi
To begin with, I installed a fresh Kali Linux arm image. I wanted to make sure I had installed the operating system correctly and that I could reach the Pi just fine. I connected the Pi directly to my laptop using a crossover cable. After connecting the two, I restarted both machines. They automatically picked link-local addresses at 169.254.X.Y, which I was able to use to SSH directly into the Pi.
This confirmed that I had everything working ok on the Pi.
Connecting to the Pi
The next step was to connect to the Pi over a network, so that the Pi would be able to download and install any necessary libraries. I started by modifying cmdline.txt on the SD card to manually set the Pi's IP address to 192.168.0.111. I then plugged the Pi into the network router, and was able to SSH into the machine at 192.168.0.111.
Installing Libraries
Once on the Pi, I needed to install some libraries. From my previous adventure at RaspberryPi/Timelapse I knew I needed a few libraries:
- python-picamera
- python-picamera-docs
These packages were not, however, in the aptitude repositories for this OS:
# sudo apt-get install -y python-picamera python-picamera-docs Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python-picamera E: Unable to locate package python-picamera-docs
But that's ok, because we can use pip instead!
First, install screen so we can install all this stuff in the background, without having to keep a terminal window open:
sudo apt-get install -y screen
Then install tools onto the Pi:
sudo apt-get install -y vim aptitude python build-essential
Now we shouold have pip and be able to install the Pi camera API:
pip install python-picamera
Scripting
To script taking a picture, use the following code, which loops forever, taking photos and marking them with timestamps:
# pic.py
import picamera
from datetime import datetime
import time
camera = picamera.PiCamera()
while True:
prefix = datetime.strftime(datetime.now(),"photo_%Y%m%d-%H%M%S")
filename = prefix+".jpg"
camera.capture(filename)
print "Saving photo to %s"%(filename)
time.sleep(2)
Flags