mrrrk.net

Yet another narcissistic load of old cobblers that no-one will ever read.

Chacmool Pi

Here's a quick and general precis of the computer hardware and software I intend to use for my weather project.

The Actual Computer

I want a computer that consumes little power and that I can connect lots of interesting little weather sensors to.  An Arduino board might work but I want to serve web pages from it and that might be asking too much from one of those.  At this point, the choice of a Raspberry Pi seems pretty much of a no-brainer.  There are other similar tiny computers (Beaglebone, etc.) but the Pi is well known, well supported and to top it off, it's British.  It's even made in Britain.

So that's easy.  The next choice is what operating system and programming framework I should use. 

Operating System and Programming

The basic requirements are:

  • Needs to poll data from several sensors
  • Needs to support a database of some form to store these readings
  • Needs to serve up web pages

My usual weapon of choice at work is Microsoft's ASP.NET with SQL Server.  As it happens, there is a version of Windows 10 that runs on the Pi: the Windows 10 IOT (Internet of Things) Edition - and it's free.  However it's not entirely clear that you can run ASP.NET on it.  I think it's possible - but not what the OS is intended for.  Also, polling the sensors with C# code would be tricky (but possible.)  And I'm pretty sure running SQL Server will be asking too much.  So in the end, I've decided on the default Raspbian operating system, which is a version of Linux designed specifically for the Pi.

With Raspbian, I could have still gone for Microsoft's ASP.NET because the new ASP.NET Core version will run on Mac OS and Linux - including the Pi - but I'm doing this for fun so I might as well chose a language and framework I don't use at work!  So I'll be doing the programming in Python.

There seem to be a number of options when it comes to Python libraries for serving up web pages and in the end I settled on something called Flask.  It looks pretty similar to the ASP.NET MVC way I know.

Fun fact:  Python is named after Monty Python's Flying Circus.  Written by a Dutch bloke who I suppose was (is) a fan.  And in turn, the Raspberry Pi is so named because of Python (it seems to me it should really be Raspberry Py on that basis, but that's quibbling).

Database

I'm also going to use Sqlite to store all the good stuff coming from my sensors.  Sqlite was apparently designed originally as a light-weight SQL database for use on US Navy guided missile destroyers!  It's used pretty much everywhere now, from storing browser settings in Firefox to storing who-knows-what on your smartphone.


Web Front-End

As mentioned, I'm using Python + Flask for the back end and as well as the usual HTML5 for the web stuff, I'll be using Typescript to do the programming around that.  I'll be using a similar approach to the one I use at work where the HTML is essentially a static shell and the clever stuff happens via client-side scripts which call APIs on the back-end and manipulate the browser view.  I'll also be using Knockout.JS to do data-binding.

Typescipt was designed by Anders Hejlsberg, the American Dane that the geeks out there will know for things such as Turbo Pascal, Delphi and C#.  He's genius but he pronounces Delphi as "delf-eye" and everyone knows it's "delf-ee" - so he's also an idiot.  No, sorry, he's not a real idiot - he's just lives in the US.

Displaying it All

The idea is to use a 7" (Nexus 7) tablet I've got (and rarely use) to display the weather data in the house.  Maybe I'll need to write an app to show the page that the Pi is sending out in "kiosk mode".  Or maybe not.  More on that later.


Add comment