Raspberry Pi Timelapse Camera for Backyard Garden
In this article
- Why Use a Raspberry Pi for Garden Timelapses
- Hardware You'll Need
- Setting Up the Software
- Take a photo every 60 seconds for 12 hours
- Choosing the Right Interval and Duration
- Assembling the Timelapse Video
- Common Problems and How to Avoid Them
- Comparing the Pi to Other Options
- Cost Breakdown
- Safety and Reliability Tips
- Frequently Asked Questions
Yes, a Raspberry Pi can be turned into an excellent timelapse camera for your backyard garden, capturing plant growth, weather changes, and visiting wildlife with minimal effort and cost. By pairing a Raspberry Pi with a camera module and a few lines of Python code, you can automate daily photos for weeks or months without manual intervention.
Why Use a Raspberry Pi for Garden Timelapses
Commercial timelapse cameras are often expensive and locked to proprietary software. A Raspberry Pi offers a flexible, low-cost alternative that you can customize to your exact needs. The Pi's GPIO pins let you add sensors (temperature, humidity, soil moisture) and control external lighting or a motorized slider. You also have full control over image resolution, interval, and storage, and you can easily adjust settings on the fly via SSH.
The most common use case is documenting plant growth—from seedling to harvest—over several weeks. A fixed camera pointed at a raised bed or a single plant can produce a satisfying video that reveals daily changes invisible to the naked eye. You can also use it to monitor bloom cycles, track frost damage, or record the comings and goings of pollinators.
Hardware You'll Need
To build a basic timelapse rig, you need the following components:
- Raspberry Pi board (any model with a camera connector; Pi Zero W, Pi 3, or Pi 4 all work)
- Raspberry Pi Camera Module (standard or HQ version; the HQ allows interchangeable lenses)
- MicroSD card (at least 16 GB, Class 10)
- Power supply (official 5V USB supply; a portable battery bank works for outdoor setups)
- Weatherproof enclosure (a simple plastic project box with a clear window, or a 3D-printed case)
- Mounting hardware (a small tripod, clamp, or a wooden stake)
For outdoor use, you'll also want a waterproof enclosure with a clear acrylic or glass window. Ensure the lens has a clear view and that the enclosure is sealed against rain and humidity. If you live in a region with extreme temperatures, consider adding a small fan or ventilation to prevent overheating or condensation.
Setting Up the Software
The easiest way to get started is to use the official Raspberry Pi OS (previously called Raspbian) with the desktop environment. After flashing the OS to the microSD card, boot the Pi, connect to Wi-Fi, and enable the camera interface via raspi-config.
For timelapse capture, you have two main options:
- Command line with
raspistill(orlibcamera-stillon newer OS versions) – simple one-liner that takes a photo after a specified interval. - Python script with
picameralibrary – gives you more control, such as adding timestamps, adjusting exposure, and handling errors.
A basic Python script using picamera might look like this:
from picamera import PiCamera
from time import sleep
from datetime import datetime
camera = PiCamera()
camera.resolution = (1920, 1080)
Take a photo every 60 seconds for 12 hours
for i in range(720):
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
camera.capture(f'/home/pi/timelapse/{timestamp}.jpg')
sleep(60)
This script saves a JPEG file with a timestamped filename every minute. You can run it as a background process using nohup or schedule it with cron to start at sunrise and stop at sunset.
Choosing the Right Interval and Duration
The interval between photos depends on what you're trying to capture:
- Plant growth – one photo every 10–30 minutes is sufficient; growth is slow.
- Cloud movement or shadows – every 5–10 seconds creates a smooth, fast-moving effect.
- Bees and butterflies – every 2–5 seconds to catch their motion, but you'll need a lot of storage.
- Full season – one photo per day at the same time works for a year-long compilation.
For a typical garden timelapse over a week, a 5-minute interval gives you 2,016 photos (7 days × 24 hours × 12 photos/hour). At 1080p, each JPEG is about 2–3 MB, so you'll need roughly 6 GB of storage. A 32 GB card is plenty.
If you want to capture only daylight hours, you can use a Python script that checks the current time and only takes photos between, say, 6 AM and 8 PM. This saves storage and avoids wasted dark frames.
Assembling the Timelapse Video
Once you have a folder of JPEGs, you can turn them into a video using ffmpeg on the Pi itself or on your computer. The command is:
ffmpeg -framerate 30 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p timelapse.mp4
Here, -framerate 30 sets the output video to 30 frames per second. If you took a photo every 5 minutes, then 30 frames per second means 1 second of video equals 2.5 hours of real time (30 × 5 minutes = 150 minutes). Adjust the framerate to get the desired speed.
If you want to add a timestamp overlay, you can use ffmpeg with the drawtext filter, or you can embed the timestamp in the filename and use a tool like exiftool to write it into the metadata.
Common Problems and How to Avoid Them
Several issues can ruin a timelapse project, but most have simple fixes:
- Battery drain – The Pi is not power-efficient. Use a power supply rated for at least 2.5A, or a large battery bank if you're off-grid. A solar panel and battery combo can keep it running indefinitely.
- Overheating – In direct sun, the Pi can overheat and throttle, causing missed shots. Use a heatsink, a fan, or place the enclosure in a shaded spot.
- Condensation – Moisture inside the enclosure can fog the lens. Add silica gel packets and ensure the enclosure is sealed.
- Storage full – If you run out of space, the script will crash. Set up a cron job to delete photos older than a week, or use a USB drive.
- Time drift – If the Pi loses time, timestamps will be wrong. Use a GPS module or connect to the internet to sync via NTP.
Comparing the Pi to Other Options
You might wonder if a Raspberry Pi is the best tool compared to alternatives:
- DSLR or mirrorless camera – Better image quality and interchangeable lenses, but much more expensive and not weatherproof without a special housing.
- Action camera (GoPro) – Compact and rugged, but limited interval settings and battery life; also more expensive than a Pi.
- Smartphone – Convenient, but not designed for long-term unattended use; battery and overheating issues.
- Webcam – Cheap, but low resolution and not weatherproof.
The Raspberry Pi wins on cost, flexibility, and programmability. You can add sensors, upload images to the cloud, or even create a live-streaming timelapse. The trade-off is a steeper learning curve and the need for some basic technical skills.
Cost Breakdown
A complete setup costs roughly $60–$100, depending on the Pi model and camera module:
- Raspberry Pi Zero W – $15
- Camera module v2 – $25
- MicroSD card – $10
- Power supply – $10
- Enclosure and mounting – $10–$20
If you already own a Pi, the only extra cost is the camera module. This is far cheaper than a dedicated timelapse camera, which can cost $200 or more.
Safety and Reliability Tips
When placing electronics outdoors, safety matters:
- Use a weatherproof enclosure rated for outdoor use, and seal all cable entry points.
- Ensure the power supply is rated for outdoor use or is protected from rain.
- Keep cables away from foot traffic and pets to avoid tripping hazards.
- If using a lithium battery, do not expose it to extreme heat or direct sunlight.
- Set up a way to check that the Pi is still running, such as a daily email report or a simple LED indicator.
With proper preparation, a Raspberry Pi timelapse camera can run for months unattended, giving you a beautiful record of your garden's life.
Frequently Asked Questions
Can I use a Raspberry Pi without a camera module?
No, the camera module is essential for capturing images. However, you can use a USB webcam as a lower-quality alternative, but the official camera module offers better resolution and control.
How long can the Pi run on a battery?
It depends on the battery capacity and the Pi model. A Pi Zero W draws about 0.5W, so a 10,000mAh battery (at 5V) can last roughly 20 hours. A Pi 4 draws more, around 3W, so the same battery lasts only about 3–4 hours. For long-term outdoor use, a solar panel and battery combo is recommended.
What is the best resolution for a garden timelapse?
1080p (1920×1080) is a good balance between quality and file size. If you want to zoom into details later, use 4K (3840×2160), but be aware that file sizes are much larger and the Pi may struggle with encoding.
Can I view the timelapse live on my phone?
Yes, you can set up a simple web server on the Pi that serves the latest photo, or use a tool like Motion to stream a live video feed. However, this adds complexity and may require port forwarding if you want remote access.
How do I protect the Pi from extreme weather?
Use a waterproof enclosure with a clear window, add silica gel to absorb moisture, and place it in a shaded area to avoid overheating. For freezing temperatures, the Pi can generally operate down to -20°C, but condensation can be a problem, so ensure good sealing.
What if I miss a few photos due to power outage?
If the Pi loses power, it will stop taking photos. To recover, you can set up a cron job that runs the timelapse script at boot, so it automatically restarts after a power outage. You can also use a UPS (uninterruptible power supply) for short outages.