ADVERTISEMENT
Raspberry pi provide a simple solution for internet connected projects. Here i am going to use a simple led matrix display ( 8*8 with an option to daisy chain several of them) to display the weather forecast data from weather underground
led matrix is based on max7219, so the data can be send serially, saving gpio pins. It uses the spi pins on the raspberry pi and the entire matrix is controlled using a python script. Details on setting up the matrix can be read here. GPIO pin connections are described here. To install the libraries you may need to install python-development packages and build essentials (sudo apt-get install build-essential python-dev )
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
And here is a demo
and more
Adding more led matrix display can make it easy to read
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