I was lucky enough to get a Raspberry Pi 2b with the 7” display for Christmas and I already had a plan for it.
I wanted to make a home dashboard to show some useful information that was readable from around the living room. Here is some of the information I wanted to show:
- Current temperature and weather forecast in my area
- Next buses due at the local bus stops
- The news headlines
- The Tube status
- My fuzzed location e.g. at work, travelling
Writing the dashboard in python3 and using the flask framework seemed like the obvious choice. I wanted to build up my python3 skills, and it allowed me to do everything I wanted with the dashboard.
I also wanted to be able to play with NFC tags and see what they could do :].
NFC tag concept
The concept behind the use of NFC tags was to allow me to place tags in various locations, touch my phone on them and the NFC reader app would in turn update my dashboard at home. Of course you need a phone which has NFC enabled to allow you to play with the tags, but I luckily had a Nexus4 that did just that. I programmed the tags to launch a HTTP GET request to the endpoint running on my OpenShift application. This GET request has a few uses, the first, to send a signal for my fuzzed location or to feedback information e.g. how many coffees I’ve had from Pret that day.
Ya but how does it work? Show me!
Here’s a little diagram which is hopefully of more use than a giant wall of text.
- /coffeecount/plusone - increments the coffee count (in the mongodb) which is readable via another endpoint with a simple get request, the mongodb collection is wiped every 24 hours overnight
- /location/one /location/two etc. - sets the fuzzed location, again stored in the mongodb and retrievable via another endpoint
Here are the pieces of hardware I needed for my project
- Raspberry Pi 2b, 7” official pi display, wifi adapter and pi power supply
- Cheap NFC tags [NTAG213] available from Amazon
- An NFC capable phone with an appropriate android version to run the software below.
Software and services
The APIs and data services that I chose for my information sources are all free of charge to use (as long as you abide by the limits and rules of course :])
Reading and writing the NFC tags:
- NFC tools pro for Android (a cheap handy application that allows you to program/reprogram actions onto your NFC tags, including HTTP GET,POST requests).
For the weather forecast:
- MetOffice weather API
For my status information:
- My pi running Raspbian Wheezy, a simple python requests and flask app to poll the APIs and display the information on the screen.
- A python and mongo app running on the RedHat OpenShift platform (free for my usage :]!!) to allow me to send and retrieve my information from a web endpoint from my phone.
For the travel information:
- TFL Tube status API
- TFL Bus status API (using local bus stop IDs to get arrival Times)
For the news headlines:
- BBC RSS feed
The OpenShift service is a bit like a container service that can run up to three simple apps ( plus DB etc ) using a free account. This free service isn’t really suitable for production type applications of course as the instance goes to sleep after a period of disuse.
To get your application up and running create an OpenShift account and basically follow the simple instructions which will tell you how to configure keys, app name etc. You then need to install the SDK on your local machine, write your code and push it up to the OpenShift server on the internet, it will then take the code dependencies e.g. mongodb and start it all up. Of course if you want it to be accessible via http you have to define a web server e.g. a flask web app. It was pretty pain free to develop on the platform once I got over the initial issue of debugging, my code of course worked locally but not in OpenShift, the debugging solution solved this though
My OpenShift application
My application running in OpenShift is quite simple, it’s a python3 app using flask and mongodb, and by now you’ve seen how most of it works. It’s an authenticated endpoint that receives the GET requests from my phone and increments values/alters values based on the target endpoint.
Results and the future
Here is a screenshot of the result, as you can see it’s pretty low resolution as the Pi screen is 800 x 480. It’s not very pretty, but I like it :]
Next I would like to make a little space in my drywall and fit the pi display right in there. Water, electricity, drills and pain, maybe some day :].
As always if you have any comments, questions or feedback please don’t hesitate to get in touch