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.


Chacmool Power

Today, I installed a solar panel on the shed.  It's rated 100 W but will generate but a fraction of that because of next-door's tree.



My initial idea was that I ought to be able to get, say, 10% of the quoted 100 W on a dull day, possibly for a third of the 24h period during winter, giving an average of 10 W x (8 h / 24 h) = 3 W, give or take.  As long as my panel pumps out 10 W during daylight hours and my Pi (plus all the weather gubbins) uses 3 W or less on average, I'll be fine!

According to this, https://www.pidramble.com/wiki/benchmarks/power-consumption, 2.5 W sounds about right - plus whatever my sensors consume.  Actually, thinking about it, my charge controller must consume a fair bit by itself.  Hmmm...

So anyway, I've attached the solar panel (as you can see above) and wired it up to the aforementioned, rather fancy charging controller I'd bought for a previous project:

And to an old, knackered (possibly) car battery I rescued from the garage:

All the wiring's a bit temporary for now.  I just wanted to get it hooked up to see if the panel and charger would work.  And they do!  The panel showed 20 V across its terminals, open circuit.  When connected up, that dropped to about 13 V.  As you can see, the panel is supplying a tidy charging current of about an Amp here:

That's about 12 W.  It's a bit sunny, but the panel's not in direct sunlight.  And I'm not sure if the charging circuit is throttling things back a bit for my old, neglected and no-doubt shagged battery.

Time will tell if this will be good for keeping the Pi going through winter!

Later...

Okay, now it's about 15:44, it's cloudy and starting to get dark (sun sets in half an hour.)  The charging controller is reporting barely a tenth of an Amp now.  About one Watt.  Dunno if the battery having maybe charged up (I doubt it - but did I mention it's probably shagged) is having a bearing on that but that sounds a bit thin.  We'll see.

To do?

I need to test how much the Pi will draw and maybe run a test load in the shed that uses a similar or greater amount of power (e.g. a 12 V lamp or something) for a week or so to see if it works.  Or I could just install the Pi and see if it crashes...

Actually, sod that - the first thing I need to do first is disconnect this setup becuase, like an idiot,  I haven't used any fuses!!!  I'm pretty confident that my wiring is as sound as it could be - but still, the potential for a battery that can supply 100s of Amps to burn down a wooden shed should not be underestimated!  I think I also need to add a fuse for the solar panel - just in case.

Wind?

It's a couple of days since putting the panel up (and starting to write this post) and the average power capability of my solar panel has been weighing on my mind.  Since my over-specced charge controller includes wind-turbine capability, I've now ordered a little wind turbine!  It's coming from China so I'm not holding my breath.


Chacmool

Chacmool is the name of my new weather project.  This is to keep me off the streets since I'm not doing an Open University degree anymore.  The idea (long term) is to make automated weather observations and use "artificial intelligence" to try and predict the weather.

This project will live in the garden shed, run on solar power and be controlled using a Raspberry Pi computer.

I've already done a lot of the fun stuff, i.e., buying various parts off Ebay and Aliexpress but I intend to keep some sort of log of my progress from here on in.

Why is it called Chacmool?

I saw a chacmool statue in Merida, Mexico a few years ago and thought it was sort of cool.  And according to Wikipedia, "Aztec chacmools bore water imagery and were associated with Tlaloc, the rain god."  That's all the excuse I need.


Why an AI weather station?

I've read "Make Your Own Neural Network" by Tariq Rashid and it was an excellent book - I'd recommend it to anyone who wants to know how things like 'deep learning' (or whatever it's called this year) work.  That got me idly wondering what I could use a neural network for, other than reading hand-written digits (the classic 'hello world' application of AI).  On the hardware side, I'd already got some bits from an abandoned shed-based project to use a Raspberry Pi for "off-site backup".   That gave me the idea then that I could build a shed-bound neural network and feed it with sheddy weather data - and see what happens...


No Physics

I'm not writing anymore physics posts - probably!  At least for the foreseeable future.  I imagine.

Physics

"If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet."
Niels Bohr

I've been busy since 2008 working on an Open University physics degree and I'm currently awaiting the result (gulp...)

I did a project as part of the course (they call it a project, other universities might call it a dissertation) on quantum computing.  I can't publish it here as the OU won't let me - and unless you're up to speed with quantum physics it probably wouldn't mean much anyway.  However since I've got a little more time on my hands, it's my intention to write a bit about the subject here and aim it at non-physicists 'cos it's an interesting, hot topic.

I'll start by introducing a concept that is often referred to as "quantum weirdness".  It's about how things behave when the're small.  And I mean really small.

In the seventeenth century, a dude called Isaac Newton (you might have heard of him) theorised on the nature of light.  He thought it was composed of streams of tiny particles and this view stood for quite a while and it wasn't until the early 19th century that a bloke named Thomas Young 'proved' that light was actually a wave.  He demonstrated the wave-like nature of light by showing interference fringes in his famous 'double slit' experiment:

A similar effect can be seen if you drop two small pebbles into water at the same time - as the waves spread out, they impinge on each other and in places where there are two crests you get a double height crest, two troughs create a double-depth trough and a crest and a trough cancel out when they coincide.  it's useful to note that the above image is an apt illustration for water-waves and for light waves but the scales differ by quite a bit. In Young's experiment, there would be a screen set up at the right hand side in the image above and you would be able to see visible fringes of light where the waves reinforce each other and dark areas where the waves cancel.  It takes a bit of seeing, but there are sort of channels or rays of uninterrupted green stillness that you can follow out from the right hand side - and these correspond to the dark areas you'd see on the screen.  If it were water, these dark bits would be where you'd be getting splashed less.

So light is a wave and all is well and good.  Until we get to the beginning of the 20th century.

Another chap you might have heard of called Albert Einstein published a paper in 1905 in which he explained something called the photo-electric effect.  I won't go into details but this was really the start of quantum physics.  People often credit Max Planck as being the guy who brought quantum physics into the world but I think Albert's 1905 bombshell was the more significant event.  The essence of it for our purposes is that the photo-electric effect can only be explained if light is treated as individual packets (or 'quanta') of energy and not waves.  These quanta of light are known as photons these days.  But hang on, Young proved light was a wave and clever guys such as James Clerk-Maxwell and Heinrich Hertz have built a lot of phyics on that wavey foundation.  There can be no doubt about it - light behaves like a wave.

And so this is where the weirdness begins - it turns out that light can be a particle or a wave.  At the same time.  If you look for a wave, you find a wave.  If you look for a particle, you find a particle.  

Digressing only slightly and coming at this from another direction, you might remember from chemistry lessons at school what an atom is supposed to 'look' like.  Actually it doesn't look like anything because it's far too small to look at but at school you were probably taught to think of an atom as a central nucleus with tiny little spherical electrons whizzing around it like little planets.  This is pretty much utter bollocks but the point is, electrons are supposed to be tiny particles but it turns out that they can also behave like waves too - depending on how you measure them.

So light and tiny bits of stuff like electrons can be particles and waves at the same time.  That's fairly weird but it does get weirder.


Image credit: Lookang many thanks to Fu-Kwun Hwang and author of Easy Java Simulation = Francisco Esquembre - Own work, CC BY-SA 3.0, Link

Plymouth Nov 2016

Some pics from last weekend's diving including some Grey Triggerfish (off the stern of the James Egan Layne) which aren't normally seen in the UK!

We don't normally dive this late in the year because of the risk of the weather being bad but the sun shone and the water was a toasty (for the UK) 15°C and good visibility (5 to 6m, again for the UK!). The air was bloody cold though.

The other pics include:

  • Divers getting ready for first dive
  • Loo on the HMS Scylla!
  • Elspeth on the HMS Scylla
  • A spiny lobster (James Egan Layne)
  • Edible crab (James Egan Layne)
  • Blenny (James Egan Layne)
  • Conger eel (James Egan Layne)
  • Being picked up by the Seeker
  • Some structural steelwork on SS Persier
  • Shoal of bib on SS Persier
  • Rudder (SS Persier)
  • Steering mechanism? (SS Persier)
  • John Dory (SS Persier)
  • Thornback ray (Glen Strathallen)

As an added bonus, there were Saturday evening fireworks on the Hoe. An excellent weekend!

thumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnailthumbnail

Replacing the starter button on my Lotus Elise

My car has a natty looking start button on the dashboard.  Obviously it's much easier to use than turning the ignition key one step further!  And it saves weight.  Well it must somehow 'cos that's Lotus' prime motivation for most of their design decisions, right?


(Note - see update at bottom!)

Anyway, it's a nice, racy sort of button and it lights up and everything.  Or at least it did light up until the bulb went.  Why they chose to use an incandescent bulb in these days of cheap, near-enough-everlasting LEDs is beyond me.  Actually, no it isn't.  Blown bulbs get people back to the garage where we customers can be relieved of some more of that pesky hard-earned cash.  Anyway, I didn't relish the thought of forking out for a new Lotus switch or being able to source the right bulb and replace it so I thought I'd get a different starter button with an LED from eBay:

http://www.ebay.co.uk/itm/201400632180

So here, in the greatest tradition of Blue Peter-style how-tos, is how I fitted it...

An online article I found provided a wiring diagram with wire colours and also the author's comments provided me with more reason to replace the original:

http://www.sandsmuseum.com/cars/exigespecific/experience/maintenance/startproblem/

The thing to note from the wiring diagram is that there are four wires on the Lotus switch but there are only three terminals on the eBay item!  However, on the lotus wiring there are two (green) wires that both go live when the ignition is on - one for the bulb and one for the switch - and we only need one so the other can be taped up.

Anyway off with the panel.  To remove the panel, undo the two screws inside the cubby hole under the panel.


To remove the existing switch you need to obviously undo the plastic nut - but you also have to remove the rectangular switch body from the cylindrical assembly by pushing in the little tab.  Only then will the assembly come out through the hole.

It turns out that the eBay switch doesn't actually fit properly in the hole - the retaining nut has a flange on it whose diameter is smaller than the hole it's pressing against - so the switch will just fall out.  Bummer.  The old switch came with an aluminium spacer though - and this provides just the adapter I need for the nut to bear against.  Except it would if the thread went far enough along the barrel of the new switch to reach past the spacer, which is too wide.  I got round this by inverting the nut so the flange was pointing outwards and the body of the nut could go inside the spacer some way and access enough thread to get a good enough purchase:


When I was preparing the terminals for the new switch, I noticed the silver bezel starting to unscrew.  A primitive instinct from my childhood took me over and I could not resist unscrewing it all the way.  I used to love taking stuff apart when I was little and was usually utterly incapable of reassembling the item before parental vengeance descended.  Anyway, my childish instincts won over against my better judgement this time and before I knew it, there were tiny springs an contacts all over the place.  With adult dexterity, resourcefulness and patience however, I was able to effect a re-assembly using a dab of silicone grease to hold springs straight while I replaced the button and bezel.  I now know what the innards look like - but it wasn't worth it.  You should definitely skip this step.

Anyway, to make the connections, I severed the old switch from its connector with scissors, leaving enough wire on both halves so I could re-connect later if it all went horribly wrong.

For some reason known only to Lotus, the wires from the connector to the switch are all black except for one red wire whereas the colours on the main wiring loom are not.  They match up as follows:

Ref. Connection Wiring Loom colour Connector colour New switch terminal (number)
A Bulb feed green red not used
B Bulb ground black black 3
C To starter via immobiliser white + red black 2
D From ignition switch green black 1


I connected the severed wires to the new switch using crimped eyelet connectors.  You can secure bare wires under the screw terminals of the new switch but I opted for a safer connection.  I was going to solder the wires into the eyelets - but in the end I couldn't be arsed so I just crimped them:


I taped the terminals up after this - just in case.

And then I tried it out.  The light came on when I turned on the ignition - yayyy!  But when I pressed the button, nothing.  I got my multimeter out and that told me the switch was fine and groovy.  And then it came to me: the immobiliser!  So I clicked that off with the alarm remote and bingo!

Here is the result:


I was not much of a fan of the original button - despite it's excitingly turned aluminium parts, it still seemed a bit plasticky.  However, I'm not 100% convinced this button is much of an improvement!  It looks a bit cheap (well, it was) and that light is very bright.  I could put an in-line resistor in to dim it a bit, I suppose.

Anyway, the jury is still out...

¯\_(ツ)_/¯

Update...

Turns out the 'bulb' in the original switch is an LED!  And it's blown.  Shows you what I know.

I'm going to see if I can figure out what bulb is the correct replacement.  My plan B is to dim the LED in the new button - but it may not be a simple as reducing the voltage because LEDs have a minimum forward voltage below which they just don't work.  The usual way to dim an LED is by turning it off for a short period and back on - but really fast so the eye doesn't notice. I could probably rig that sort of thing up (Arduino board?) but that's far too much trouble.  More later...

Disclaimer

If you try any of this yourself and blow up your car, yourself or incur any other undesirable outcome as a result of this folly then it's your own daft fault for following instructions from the webpage of some idiot you've never met - and not mine!  I'm not an expert and don't profess to be.  Enjoy! :o)

Seals at the Farne Islands

The grey seals are breeding around this time of year so there are plenty to be seen. Here are some photos from our dive trip last weekend.

thumbnailthumbnailthumbnailthumbnailthumbnailthumbnail

Weymouth - Sept 2015

A week or so ago, Elspeth and I grabbed a couple of spaces for the weekend on Phil Corbin's Tango boat in Weymouth.  We dived the wrecks of the HMS M2 submarine, the SS Gertrude, the SS Frogner (allegedly) and the HMS James Fennel.

The M2 was amazing.  We've dived this before but this time the visibility was excellent (for the UK), the tide was perfectly slack, the sun was shining and the wreck was covered in life: conger eels (E counted 12 of them!), lobsters and shoals of bib.  Top dive!

The SS Gertrude was another excellent dive which subjected us to a bit more current this time but it was still possible to stay over the wreck without too much effort.  The propeller was still present on this wreck which is unusual since they're usually made of bronze and salvaged.  We also saw remnants of the engine and a big old boiler.  Toward the end of the dive we saw not one, not two but three cuttlefish!

The next day, our dive on the wreck of the SS Frogner was frankly crap.  It was fairly deep for us air-breathers at 37m, due in part to the super-moon induced spring tides. Also, it  was really dark down there.  I was unable to read my wrist-mounted dive computer without using a torch.  We missed the wreck having found nothing obviously wreck-like at the bottom of the shot-line and spent the dive swimming around aimlessly over an almost featureless sea bed (although we did see a lobster!)  This unrewarding dive still required us to do about 8 minutes of decompression - which was about as interesting as the dive itself.

The following, shallower dive on the wreck of the HMS James Fennel turned out to be much nicer!

Anyway, here are some pics...

photophotophotophotophotophotophotophotophotophotophotophotophotophotophoto

Boots D10

Elspeth and I visited amongst other places the Boots D10 building as part of the recent Beeston Heritage Open Days event.

It's a fairly enormous factory building built around 1930 and the first (in the UK at least) to be constructed of concrete and glass.  It's a seriously impressive site and looks modern and forward-thinking, even now.  D10 has a large, central atrium with a concrete and glass roof that allows light to enter and fill the four-storey factory space, which is criss-crossed with bridges connecting the gallery-like floors in a very exciting, almost sci-fi way...

thumbnailthumbnailthumbnailthumbnailthumbnailthumbnail

Interesting facts about D10

It is (or was) known as the "Wets Factory".  The idea being that all products requiring similar handling and process requirements would be in the same place.  So potions, lotions or other runny pharmaceuticals along with shampoo, perfume, toothpaste, etc. would all be made and packaged here.  Pills, powders and other dry stuff, elsewhere.

These days, it's the Boots Contact Manufacturing building.  They make toothpaste and all sorts of other stuff for the likes of Colgmithsodyneodent or whoever.  I made the name up obviously and they were cagey about who they make stuff for and keen we didn't take photos of products or trademarks on the line. 

From Boots' fact sheet on the day:

  • D is for Dunkirk - the Nottingham area it's officially in - not Beeston! 
  • more to come...