Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (55 sloc) 2.09 KB
Aurora Alert for Blinky Tape
To run on default (Raspberry Pi) USB serial port: python &
This script works by turning off the tape when there is no Aurora.
You need to save one of the images to the tape with pattern paint first.
(C) 2015 James Singleton (
MIT Licensed
from BlinkyTape import BlinkyTape
from time import sleep
from xml.etree import ElementTree
import urllib2
import optparse
# Default Blinky Tape port on Raspberry Pi is /dev/ttyACM0
parser = optparse.OptionParser()
parser.add_option("-p", "--port", dest="portname",
help="serial port (ex: /dev/ttyACM0)", default="/dev/ttyACM0")
(options, args) = parser.parse_args()
if options.portname is not None:
port = options.portname
print "Usage: python -p <port name>"
print "(ex.: python -p /dev/ttyACM0)"
# Documentation:
# Code and spec:
url = ''
bt = BlinkyTape(port)
request = urllib2.Request(url)
request.add_header('User-Agent', 'BlinkyTape Aurora Alert')
opener = urllib2.build_opener()
# Some visual indication that it works, for headless setups (green tape)
bt.displayColor(0, 100, 0)
while True:
print "GET %s" % (url)
rawXml =
tree = ElementTree.fromstring(rawXml)
if not len(tree) or tree is None:
raise Exception("Error loading data")
currentStateName = tree.find('current').find('state').get('name')
print currentStateName
if currentStateName != "red":
for x in xrange(300):
bt.displayColor(0, 0, 0)
# Tape resets to stored pattern after a few seconds of inactivity
sleep(300) # Wait 5min
# Blue indicates an error
bt.displayColor(0, 0, 100)
sleep(300) # Wait 5min