Zack Scholl

Raspberry Pi as an aurora alarm.

 / #raspberrypi 

I make a Raspberry Pi powered alarm clock for alerting about auroras.

Auroras (or northern lights) are amazing – a beautiful display of ionization of the disturbed magnetosphere. Auroras often happen in the dark of the night and their occurrence is random. The best predictions usually only provide an hour’s notice. To make sure I can get to see the latest Canadian auroras, I made a Raspberry Pi Aurora Alarm.

There is a simple way of determining if there is an Aurora in Canada, you just go to There you will see a graph like this:

When the bar is red, there may be an Aurora!

From that graph you can see that the Aurora on September 1st, 2017 did not occur until about 11pm. And, even though I was asleep at the time, I was awaken to see the aurora!

My setup is very simple. I have a Raspberry Pi that probes the Aurora with a simple Python function:

import requests
from bs4 import BeautifulSoup

def percent_aurora_right_now():
    r = requests.get('')
    soup = BeautifulSoup(r.text, 'html.parser')
    percent_aurora = 0
    for span in soup.find_all('span'):
        if '%' == span.text[-1]:
                percent_aurora = float(span.text.replace('%', ''))
    return percent_aurora

and then I have a for-loop that periodically checks if an Aurora has occurred:

import time 

while True:
    if percent_aurora_right_now() > 70:

The alarm() function may have to be changed for yourself. You can do whatever alarm is best – push notifications, ringing buzzers, etc. Since I am a heavy sleeper, sound usually doesn’t wake me up so I made a light alarm. That is, my lights will periodically flash when the Aurora occurs:

My Aurora light alarm in action

I have two PIR sensors at the side of my bed so I can also turn on/off the lights manually. For light automation I’m using Philips Hue Lights.

Here’s another picture from the last aurora I saw:

An Aurora in the middle of the night in the middle of Alberta, CA

Here’s my full code: