Connecting an led matrix to the pi using a ribbon cable |
Then make sure that spi is enabled ( ls /dev/spi*) and should see spidev 0.0 and 0.1) , otherwise get the required modules. Recent versions of raspbmc has spi enabled by default, so no need to change anything.
To show the weather data, a python script is used which goes to weather underground and get the weather forecast for the current location. Signup for an api key and use it in the script at "YOURapikeyHERE" (else it fails to work). Replace the zmw:00000.XXXXX.json with the value for your location ( just visit weather underground website and see the value for your place)
A cronjob can be used to automate the updates. An example script is shown below followed by a video
nano weather_update.py
To execute, sudo python weather_update.py
#!/usr/bin/env python
import urllib2
import json
import requests
import max7219.led as led
import max7219.canvas as canvas
import max7219.transitions as transitions
r = requests.get("http://api.wunderground.com/api/YOURapikeyHERE/forecast/q/zmw:00000.1.01257.json")
data = r.json()
day = data['forecast']['simpleforecast']['forecastday']
message1 = day[0]['date']['weekday']+' is '+day[0]['conditions']+' & temperature range is '+ day[0]['low']['celsius']+'-'+ day[0]['high']['celsius']
message2 = day[1]['date']['weekday']+' is '+day[1]['conditions']+' & temperature range is '+ day[1]['low']['celsius']+'-'+ day[1]['high']['celsius']
led.init()
led.brightness(1)
#show the weather report for some time , so loop 100 times
for x in range (100):
# led.show_message(message1+" " + message2, transition = transitions.left_scroll)
led.show_message(message1+" " + message2, transition = transitions.up_scroll)
And here is a demo
and more
Adding more led matrix display can make it easy to read
No comments:
Post a Comment