Scroll the embedded Google Sheet to see additional data.

About this project

Whenever I’m away from Maine’s midcoast I wonder what I’m missing. What’s the weather? When does the sun set and the moon rise? Is the tide coming in or going out?

No single app that displays that data at a glance, so I made it a project to learn enough Python to make the necessary API calls, crunch the necessary calculations, and publish them to a Google Sheet that can be accessed on anywhere on almost any device. I’m constantly tweaking the project, and eventually I hope to archive the data in a database so it’s possible to create charts and graphs.

The Python scripts I use to populate this page are available on GitHub.

The components

A survey of available data sources led me to the US Naval Observatory’s APIs because they would provide the bulk of the data I wanted to aggregate. This would be easy, and it was until I took the bold step of attempting to access the APIs. The USNO API site is offline until April 2020.


  • delivers what its name suggests, and not much more. It’s free and doesn’t require an API key.
  • Moonrise and moonset are supplied by An API key is required, but it’s free for light usage.
  • I couldn’t find a free API for the moon phase, so I opted to calculate within the code. There are numerous tutorials online. In the end, I lifted some code from here to calculate the percentage of the journey from one new moon to the next has been completed. Fifty percent lunation is the full moon. I wrote my own translation table to convert lunation to a phase. I’m certain an undergrad astronomy student can poke holes in my approach, but what my script reports represents what’s in the sky.


  • Current conditions are supplied by Dark Sky, again my needs keep me comfortably in the free tier. It requires an API key, and like the sun and moon data sources, it delivers a sparkling clean JSON file that’s easy to parse.

Nautical data

  • Tidal data is easily gathered from NOAA. This JSON thing is starting to click for me.
  • Additional nautical data includes wave height and frequency, water temperature, air temperature (often significantly different than air temperature on land), wind speed and direction are from the National Data Buoy Center in Rockland, ME. The information is published as RSS – more of challenge to parse, but not a blocker. Compared to JSON, RSS is can be a hot, poorly structured mess. The code is messy, but it works.

I will clean up the code, but first I will see what the updated USNO site provides.

Storing the data

Initially I was going to build a simple MySQL database, but then I came across a life changing Medium article. It seems every Medium article purports be life changing – You aren’t winning the Nobel Prize because you don’t do this one thing, This simple trick licked my procrastination habit in a week, etc… But this Medium article really was a game changer. I didn’t need a database, a simple spreadsheet would do.

Updating the data

Each task was given its own script, so that I could schedule it to run as often or infrequently as necessary. It would be good practice to call each service only as needed. Air temperature might change several times a day, but the sunrise is only needs to be updated once a day. A $35 Rasberry Pi could handle these tasks, but I happened to have an old MacBook Pro Linux server. It does double duty as a weather aggregator and family server. All tasks are scheduled to run as cron jobs.

The Google Sheet approach is so easy that I’ve already incorporated it into an smart home project where I have a Rasberry Pi with a temperature sensor monitor an outbuilding’s temperature and text me if there’s a danger of pipes freezing.


It turns out this was a great project to let me hone my Python skills while learning how to integrate different technologies and approaches. It’s a nice real world project. Not all data is immaculate. Sometimes the simple solution is best. Some of the skills used:

  • Parsing RSS/XML
  • Storing API credentials securely
  • Using OAuth 2
  • Crontab configuration
  • GitHub