With the recent explosion of the Bitcoin value, I decided to do to build a display with the current value shown in Dollar and Euros.
euro = float(json.loads(urllib2.urlopen('https://mtgox.com/api/1/BTCEUR/ticker').read())['return']['last']['value'])
Now we need to get it on the screen. I noticed a directory “python_games” on the Raspberry: a collection of simple games that appeared to use pygame, a really easy to use SDL based module mainly intended to write games. This makes it possible to create a full screen application without the need of an X Server and more complicated graphical toolkits.
So, all I need to do is create a scheduler which triggers the retrieval of the BTC value, format string and blit them on the screen.
Finally, I added a line to /etc/rc.local, so the application starts automatically after booting:
python /home/pi/btctracker/btc.py &> /dev/null &
The decision to use python and pygames was definitely right for this application. Any other tool I could think of would have taken me much more time and lines of code.
Is it useful? It definitely triggered some interesting discussions on Bitcoins and it current valuation. Shops accepting Bitcoins could use the ticker to display the current exchange rate, but in for that use case I would add the possibility to pay (camera to scan the wallet QR, numeric keypad to enter the amount).