The feed picks up the headlines from the BBC news service and then runs continuously on the SenseHat display. Any other valid newsfeed could be substituted for the BBC feed.
RSS feed running on the Raspberry Pi with SenseHat. I couldn't get a much better photo then this. |
Step 1
I used feedparser for the RSS feeds. This can be installed on your Pi using the following command:
sudo pip install feedparser
Step 2
The following Python 2 code runs an infinite loop which loads the first twenty articles from the BBC website and displays them continuously on the SenseHat display.
#Sense Hat RSS reader #For Python 2 from sense_hat import SenseHat import feedparser import time sense = SenseHat() sense.set_rotation(270) ARTICLE_LIMIT = 20 print "Ticker running on SenseHat" while True: for i in range(ARTICLE_LIMIT): time.sleep(0.5) d = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml?edition=uk') sense.show_message(d.entries[i].description, back_colour=[255,0,0], text_colour=[255,255,255], scroll_speed=0.07) time.sleep(2.5)
If you liked this article, then you might like my other SenseHat posts, or my other Raspberry Pi posts.