sunwait is a [very] old and simple application for calculating sun rise & set times for a given location. It is designed to be used with cron but can be used as a standalone application. There are newer versions around, but these instructions refer to the original, last updated in 2004 version.
There are various instructions on how to install it on a raspberrypi, I struggled to find all the stages in one place, so through it would be helpful to list them [ thanks to carrotjuice , B.Goode and scruss for the source information ] – link to relevant Pi forum .
wget http://www.risacher.org/sunwait/sunwait-20041208.tar.gz tar xvzf sunwait-20041208.tar.gz cd sunwait-20041208/ ls make sudo cp sunwait /usr/local/bin
You can then check it is installed ok with
To run it for your location add the relevant lat and lon as shown below;
sunwait -p 51.4826N 0W
This is roughly the position of the Greenwich Meridian line in London giving the following output
You can find some simple code on my git hub in the RC-433 stuff folder to see how I extract the sunrise / set time within a Python application [ look for suntest.py ], it is a little crude but seems to work reliably.