Pi Sliced Day Photos

README-Fossil.md
Login

README-Fossil.md

File README-Fossil.md from the latest check-in


Pi Sliced Day Photos

This is a small .NET Core (C#) program designed to be run on a Raspberry Pi that takes photographs at Sunrise, Sunset, a number intervals in-between and at custom times specified either by clock time or minutes +/- from sunrise/sunset.

The sunrise/sunset times for the program must be provided as a CSV file - this requires some extra work to setup but leaves you free to use any times you want. A great is way to use this is generating sunrise/sunset times based on the topography around the camera site (see the notes below) - in many cases the sunrise time on an imagined horizon is not photographically useful or interesting, the sunrise time when the sun emerges from behind a mountain peak is much more interesting!

This program can also take photographs at a number of intervals between the input sunrise/sunset times. Because the intervals are calculated based on the input sunrise/sunset, which may take topography or other factors into account, the photographs might not be at the same sun angle each day, but will be at the same relative time between sunrise/sunset.

While the scheduling has some flexibility and a number of options the core inspiration for this program is living in the mountains. The flexible sunrise/sunset times allow us to input times that match when the sun comes over the ridge to the east and when it sets over the various mountains on the skyline to the west. With the sunrise/sunset times so influenced by topography 'halfway thru the available sunlight for the day' becomes much more interesting than a photo taken at a certain clock time or sun angle.

One possible final output for the photographs from this program is as a timelapse. The files from the Pi Sliced Day Photos program have names that are easy to sort and filter - a good start to producing a timelapse - but you might find that you want additional options like combining images from multiple cameras, getting a set of files in a single directory with simple sequential file names or automating creating a timelapse via a command line app... See the Pi Sliced Day Timelapse Helper for help!

The image below was created in Photoshop by combining the output of this program from 3 Raspberry Pi 3 A+ computers with Wide Angle Camera Module 3 cameras - the cameras face, approximately, west, north and east

OutputExample

Program Requirements

Sunrise and Sunset are always photographed - you can also specify:

SunriseAndSunset.csv

This program uses a file of Sunrise/Sunset times to allow you to input any sunrise/sunset times that you want - a strong use case for this is generating topography compensated Sunrise/Sunset times for your location. For example, today at my house we didn't see the sun come over the mountains to the east until 40+ minutes after the sunrise time calculated for the 'true' (imagined) horizon...

The SunriseAndSunset.csv file should be formatted like the sample file included with the program:

DAY, SUNRISE, SUNSET
2023-01-01,08:15:00-0700,17:23:00-0700
2023-01-02,08:15:00-0700,17:24:00-0700

If you are interested in generating Topography compensated Sunrise/Sunset times for your location try:

Settings File

DaySlices - Takes an integer and determines the number of photos taken between sunrise and sunset.

NightSlices - Takes an integer and determines the number of photos taken between sunset and sunrise.

PhotoStorageDirectory - The path to where the photos are written.

SunriseSunsetCsvFile - The name (including extension) of the csv file of Sunrise and Sunset times.

PhotoSeriesName - Postfix for the photo name - this defaults to the machine name if not present.

LogFullExceptionsToImages - The assumption is that this program will run largely unattended and that most of the time the only thing you will see is the photographs. The program will try to alert you of errors by writing exception information to an image file in the PhotoStorageDirectory. This setting determines whether the program writes all of the exception information or only an abbreviated message. This option exists because writing full exception information may leak information about your setup!

LibCameraParameters - Day/Night/Sunset/Sunrise - command line parameters for libcamera-still.

CustomTimes - Custom times can be specified either as clock times (3:45 pm) or as minutes before/after sunset (sunset +10). Each custom time also gets LibCamera parameters.

"CustomTimes": [
    {
      "Time": "Sunset+10",
      "LibCameraParameters": "--autofocus-mode manual --lens-position 0 --awb auto --metering average --denoise cdn_hq"
    },
    {
      "Time": "Sunrise-10",
      "LibCameraParameters": "--autofocus-mode manual --lens-position 0 --awb auto --metering average --denoise cdn_hq"
    }
  ]

Setup Notes

Suggested setup on the Pi - this is here for convenience and was last updated July 2024. As OS and Pi details change some/most/all of this might become irrelevant, or even harmful, and this by no means covers all the details needed to run a Pi securely and appropriately. The setup below is pretty basic, but use at your own risk!

I like to disable the LEDs to make sure that the glass covering the lens opening won't pick up any light from the LEDS - How To Easily Disable Status LEDs On RaspberryTips

  sudo nano /boot/firmware/config.txt
Add the following lines to the end of the file:
  #Disable Power LED (Red)
  dtparam=pwr_led_activelow=off
  #Disable Activity LED (Green)
  dtparam=act_led_trigger=none
  dtparam=act_led_activelow=off
  #Disable LAN LEDs
  dtparam=eth_led0=14
  dtparam=eth_led1=14

My preference is for Automatic/Unattended Upgrades - do this long enough and something unexpected will break, but I would rather stay up to date and have something break sooner rather than later. Secure your Raspberry Pi by enabling automatic software updates – Sean Carney and UnattendedUpgrades - Debian Wiki

  sudo apt-get update
  sudo apt-get install unattended-upgrades
  sudo dpkg-reconfigure --priority=low unattended-upgrades

If you've worked in years gone by with the Pi Camera and C# you might know the very useful techyian/MMALSharp: C# wrapper to Broadcom's MMAL with an API to the Raspberry Pi camera - unfortunately without choosing an older version of Raspberry Pi OS that library no longer works. The Pi has moved on to libcamera. I didn't find a C# wrapper for libcamera and since I didn't need to do anything other than write stills to the Pi's storage calling libcamera-still 'command line style' seemed to be the best option.

I didn't find a single great place for libcamera-still documentation - frustrating until I figured out that (beyond 'getting started' content) running 'libcamera-still --help' was really the best single source of information.

July 2024 Update

I have been running 3 Raspberry Pi 3 A+ computers with the Wide Angle Camera Module 3 cameras for over 6 months now - the PiSlicedDayPhotos program and Pis have run without issues or attention needed! However, a few things have come up:

Backstory

For a number of years my wife and I used a previous (now-archived) project - cmiles/PiDropLapse - and a Raspberry Pi 4 Model B to take periodic photographs and sensor readings to monitor an area inside our house.

Since moving to a more rural property I have wanted to do a similar project but outside and solar powered - Raspberry Pi shortages, never quite finding an in-stock dedicated Pi solar setup that I loved and other house projects delayed that idea...

Recently we installed a 24V/100aH solar system near our parking area. The main purpose of this system is to power the rodent deterrent lights for our trucks - but luckily it has more than enough power to also power several Pis for photo purposes!

EnclosureExample

My Setup with Notes

Most of the gear below was purchased mid-2023, but I have added a few mid-2024 updates. I hope to keep my current setup running for a very long time so I won't be constantly updating this list with the latest and greatest gear - but I will try to update with improvements, notes, failures and successes.

Other Projects

Fundamentally this project is just taking photographs with the Raspberry Pi which is not hard to do and you can find other great free projects and code to take stills, timelapses and more! One of my favorites is GitHub - thomasjacquin's allsky: A Raspberry Pi operated Wireless Allsky Camera - I hope to build on of these in the future... Also see Roll Your Own All-Sky, Raspberry Pi Camera - IEEE Spectrum and the Hacker News discussion.

Tools and Libraries

This program would not be possible without the amazing resources available for creating Free software! Used in this project:

Tools:

Core Technologies:

Libraries: