Recently I built a time-lapse camera with a Raspberry Pi. Here’s how:
Bill of Materials
- Raspberry Pi 3
- Power Supply
- Camera Mount
- This ended up having a slightly different mounting hole pattern than the Arducam.
- Arducam Camera
During initial setup, you’ll also want to have a HDMI Cable, Keyboard, Mouse, and Monitor for your Pi.
- Fasten the Arducam to the camera mount.
- Connect the Arducam ribbon cable to the Pi’s CSI port.
- Download the python code.
- Update start time, end time, and sleep interval as desired.
- (Optional) Update rc.local as mentioned below.
from time import sleep from picamera import PiCamera from datetime import datetime MORNING_START_HOUR=7 EVENING_END_HOUR=19 def day_or_night(datetime): hour=datetime.hour if hour>=MORNING_START_HOUR and hour<EVENING_END_HOUR: return 'day' else: return 'night' def take_picture(): camera.start_preview() sleep(2) now=datetime.now().strftime("%Y-%m-%d-%H-%M") label='timelapse_' + now + '.jpg' camera.capture('/home/pi/Pictures/'+label) camera.stop_preview() print('Image captured at '+now) if __name__=='__main__': camera = PiCamera() while True: now=datetime.now() if day_or_night(now) is 'day': try: take_picture() except: pass sleep(900) #15 minutes
The images are saved in /home/pi/Pictures/ on the Pi. I used ImageMagick to create the GIF of the plant shown above.
- Saving the files to Google Drive to avoid file storage limitations. Also, you can view the images without disturbing the camera system. Looks like this article points us in the right direction.
- Utilizing a portable power supply.