Ambient Weather Indicator

ambient-weather

Another great use for BlinkyTape comes to us from our forum user Eric C. aka “revsin.” Like our last post this is an ambient information visualizer – but for a very different purpose. Eric is a motorcyclist and wants to know at a glance if it’s going to be dry for the next few hours – i.e. whether or not it’s a safe time for a ride.

In order to do this, he’s writing a python script that quickly scrapes a weather website for the next few hours of weather and then writes it out to his BlinkyTape – each LED corresponds to a few minutes.

Very awesome – click through to for the python!

Here’s the script:

[python]
def clocking():
while True:
bb = BlinkyTape(‘/dev/tty.usbmodem1441’)

url = ‘http://www.accuweather.com/en/us/madison-al/35757/minute-weather-forecast/15532_pc’

website = urllib2.urlopen(url)
html = website.read()

regex = ‘<span class="time">(.+?)</span>.*<span class="type">(.+?)</span>’
pattern = re.compile(regex)
clockandprecip = re.findall(pattern,html)
wlist = []

for i in clockandprecip: # [::5] limits to every 5 minutes
condition = i[1]
time = i[0]

if condition == ‘No Precipitation’:
rgb = 255,0,0
print rgb
wlist.append(rgb)
else:
rgb = 0,255,0 # green
print rgb
wlist.append(rgb)
for d in range(60):
for x in wlist[::2]: # limits to every other minute
bb.sendPixel(x[0],x[1],x[2])
bb.show()
sleep(1)

clocking()
[/python]

 

As an aside, these last two projects show that python is a great way to program for ambient installations – not only it python a great language, it runs on both PC hardware or embedded machines (i.e. Raspberry Pi or Beaglebone) with minimal changes!

Leave a Reply

Your email address will not be published. Required fields are marked *