I wanted to rig up some way to automatically take a photo of every sunrise and sunset. New York City has spectacular sunsets, but I’ve always felt weird about taking photos of them because I experience an “observer effect” where I feel like the sunset doesn’t hit you as hard if you’re busy documenting it. Knowing that a camera will be capturing the sunset automatically is ne way to enjoy it without a lens while still knowing that if I want to return to savor it later, I can.
(I’d always assumed that part of reason we have good sunsets here is the poor air quality, but it turns out this isn’t true! Check out this comprehensive tour thru why clean skies lead to better sunsets from Stephen F. Corfidi at NOAA.)
To take the sunrise/sunset photos, I bought a Raspberry Pi Zero W, which is a cheap, small linux computer that has a camera attached and is small enough that it can be mounted to a window with suction cups.
The Raspberry Pi makes it easy to take a photo on demand with a command line utility called
raspistill. But I needed a way to take the photos at precisely sunrise and sunset. I’d always heard of the terms “civil twilight” or “nautical twilight”, and Wikipedia has a great illustration of the differences between these different types of light that occur at sunrise and sunset; the main difference between these is the angle of the sun. For my purposes, I wanted to take a photo when the top of the sun was at the horizon line.
To make this happen, I found a clever open source command line program called
sunwait. You give it your latitude/longitude, whether you’re interested in sunrise or sunset, and what kind of twilight you’re interested in (e.g.
daylight | civil | nautical | astronomical) and it very simply waits from now until the correct moment occurs. This makes it suitable for use in a program that runs on a schedule (e.g.
cron) — you can run your program at the same time every day and
sunwait will wait to do whatever you want to do afterwards until the correct sunrise/sunset moment.
Here’s what my script that I use to take the photo looks like:
# this halts the script until the sunrise/sunset event has happened, # at the "daylight" setting, which is when the top of the sun is at # zero degrees /home/pi/sunwait-master/sunwait wait $SUNTIME daylight $LATITUDE $LONGITUDE; # this takes the picture, with a watermark showing the date/time /usr/bin/raspistill --rotation 270 --height 2000 \ -ae 90,0xff,0x808000 --annotate "$(date)" \ --timeout 4000 --nopreview --output $FILENAME; # ...then I upload the jpeg to my web server automatically
And here’s an example of a sunrise on a day that started out cloudy and became dreamy:
In the longer term, I want to try to figure out how to use these images to divine further data about the current weather conditions (e.g. cloud identification), but for now I’m completely content looking at the day’s sunrise & sunset! You see them update daily near the bottom of the page on Big Boy Weather.
One thing I wish the weather station could be tracking, but currently isn’t, is whether or not it’s snowing.
Right now, I have a rain gauge that’s a “tipping bucket”, so-called because it collects rain in a tiny bucket, which tips periodically as it fills up. The rain rate is inferred from the number of bucket tips. This setup doesn’t work when it snows: snow isn’t liquid, so it doesn’t fill up the tiny bucket. You can attach a little heater to the rain gauge (here’s a classic forum-style post about how to do this), which would melt the snow and theoretically allow you to track it as liquid precipitation.
But this misses the whole point, in my opinion! The whole reason to track snow precipitation is not to measure the rate at which it’s snowing, interesting though that might be. It’s pretty simply to track the groud conditions of whether or not it’s snowing at all! e.g. ideally a sensor which emits a boolean condition IT’S SNOWING or IT’S NOT SNOWING.
Part of why this is worth knowing at all: the three main National Weather Service weather stations in New York City (where I live) are in the middle Central Park, JFK airport and LaGuardia airport. Not super representative, as NYC locations go! Plus: nearly everywhere in NYC has various exposure to different bodies of water, elevations, building heights, etc, all of which add up to local precipitation variability. I want to know whether or not it’s snowing, at any given time, at a real NYC neighborhood location!
It turns out there’s a name for a type of precipitation sensor that can distinguish between rain/snow: it’s a present weather sensor, sometimes called a disdrometer. They all measure the rate and size of falling droplets. Unlike the weather station, which was relatively cheap (~$100), most of the disdrometers are mega expensive… I’ve been trying to search Google & GitHub for disdrometers every few months, in the hope that eventually one of them “gets cheap” or someone comes up with something DIY. Here’s my February 2018 disdrometer report, in ascending order of cheapness:
This post consecrates this “log”, where I’m trying to record everything relevant to the humble weather station I run. Please picture me reading all of these in the Picard stardate voice.