Raspberry Pi weather forecaster

In my ongoing struggle to overcome chemo-brain, I’ve recently created a rudimentary (*) weather forecaster. It’s based on a Raspberry Pi Zero W that came as part of a gift subscription to the MagPi. It incorporates a BME280 sensor (for reporting pressure, temperature and humidity) and a LCD display.

The current prototype

Not pretty, but functional. It requires just 3 hours of historical data before it makes a forecast! Somehow I don’t think anyone will claim that professional weather forecasters are no longer needed … unless you’re someone who still believes in unicorns. (+)

Prototype Raspberry Pi weather forecaster
Prototype Raspberry Pi weather forecaster. The Pi is hidden under the multiplexing board.
The technical stuff

The LCD display and BME280 sensor are both connected to the Pi using the I2C bus exposed by GPIO (physical) pins 3 (data) and 5 (clock). Power to the LCD is provided through a 5v pin (2 or 4) and to the BME280 through a 3.3v pin (1 or 17). The final wire to each component is the ground. Any of GPIO pins 6, 9, 14, 20, 25, 30, 34 or 39 will do.

The coding tasks (in C and FORTRAN) were greatly simplified by the use of the excellent wiringPi library.

Release 1.0 of the code is available on github should anyone want to enjoy a good laugh at my legacy coding skills.


BME280 – £5.45 (I bought two for £10.90, just in case my soldering skills let me down).

LCD display – £7.99

Raspberry Pi Zero W – free as part of the current MagPi subscription offer, or around £10-£15 if you need to buy one and a 40 pin GPIO header.

Next steps

Finding a suitably sized waterproof project box with a transparent lid to house the electronics (sadly far harder than it used to be with the demise of Maplins earlier on this year).

Tidying up the wiring by using a piece of Veroboard (other brands are available) so I don’t need to use my only multiplexing board (by far the most expensive component in the current build).

Creating a better forecasting model. In FORTRAN, naturally. I acknowledge that it could take me some time to become as good as the Met Office …



(*) “Rudimentary” makes it sound better than it is. Here’s the current forecasting model it uses for those who don’t want to wade through all the code on github.

C                                                                      C
C                                                                      C
C     CIND  - CHANGE INDICATOR STRING                                  C
C     CFORE - FORECAST STRING                                          C
C                                                                      C
C     AUTHOR: TJH 26-07-2018                                           C
C                                                                      C
      IF (PDIFF.LE.-0.5 .AND. PDIFF.GE.-3.0) THEN
         CIND="v "
         CFORE=" Some rain possible "
      ELSE IF (PDIFF.LT.-3.0 .AND. PDIFF.GE.-6.0) THEN
         CFORE="Wind,rain;fine later"
      ELSE IF (PDIFF.LT.-6.0) THEN
         CFORE="    ** STORMY **    "
         CIND="^ "
         CFORE="Fine, becoming drier"
         CFORE="Becoming dry & windy"
         CFORE="No change in weather"
      END IF


(+) For example, someone who still believes that Brexit is a really good idea. So maybe I should approach the disgraced former defence secretary, Liam Fox, to promote it for me.

The ethical crisis in software development

I’ve been following the news on the scandal surrounding Volkswagen with keen interest. It appears that at the heart of the matter is a piece of software, written for or by Volkswagen, that forms part of their engine management system. As a software professional of more than 30 years standing, it angers me that an apparently reputable organisation (of which I was a customer of for many years) thinks that it is acceptable to misuse code in this way. While there’s clearly a need for those in charge of VW to take responsibility, there is also a need for the individual software professionals involved to examine their conduct. So I’ve been pleased to see that the British Computer Society CEO, Paul Fletcher, has published a blog article on this topic today.

Software is no longer confined to large computers in purpose-built rooms – it’s everywhere

In it, Paul calls for all technologists to work to a strong professional code of conduct. Naturally, the BCS has a code of conduct that it expects its members to conform to. However, in my opinion, it’s not as strongly worded or as visible as it needs to be, particularly when you compare it to those of other professional bodies, such as the British Psychological Society’s code of ethics and conduct. Professional qualifications and membership really mean something in psychology – but despite rising membership numbers and the BCS’s best efforts, the equivalent professional qualifications and membership for software professionals carry a fraction of the weight that they ought to.

Sadly, even if the code of conduct was stronger and more visible, the BCS would need far more clout than it has today to promote it more widely. Even more importantly, a government-backed regulatory framework, to ensure that the BCS can support its members put under undue pressure to act unethically, is absent.

I believe we should be just as interested in ensuring that people who write and implement software are as well-regulated and ethically aware as professional psychologists. After all, unethical behaviour in software development can have potentially devastating effects on the environment, health, wealth … in fact, on any aspect of society touched by software.

Which, as society is becoming increasingly aware, is all of it.

The best thing that could come out of the VW scandal is that we all start to pay far more attention to ensuring that technologists, especially software developers, understand their ethical duty to society and that they have the necessary professional and regulatory backing to be able to stand up to rogue employers.

Never auto-renew your car insurance with Allianz (or with anyone else, probably)

Martin Lewis over at moneysavingexpert.com offers this excellent advice when it comes to car insurance:

Never auto-renew. Loyalty is expensive

Nothing better illustrates car insurers preying on loyal customers than Sarah Cooper’s tweet. “My car insurance renewal is £1,200. New policy with same company is £690. How do they justify this?” They don’t. They just do it.

I’ve had my car insurance renewal notice from Allianz today. Comparing it with last year’s premium, they want an additional 51%! Nothing has changed – except that I’ve had another claim free year, bringing my total to 10. A quick check of a couple of price comparison websites showed that for the same cover the cheapest quotation was around £15 less than I’d paid this year, with 10s of quotations clustered around £10-£20 more expensive than last year. There were three or four (out of a hundred or so) that were more expensive than the Allianz renewal, but they were offering free unicorns as well. (OK, I’m fibbing about the unicorns).

I rang Allianz up. I was calm. I politely explained the situation. I was reasonable and persuasive. I asked that they considered renewing my policy at around the same price as last year, or perhaps on or around the median quotation I’d found for this year.

Their call handler was lovely, but her response was:

We don’t price match sir. I could re-quote you, but the result would be the same.

They wouldn’t budge by even a penny. I hate being taken for a fool and her excuses became less and less convincing as I suggested that they were guilty of sharp practice. I’ve cancelled my policy with them and I’ll do everything I possibly can do to make sure that I don’t use Allianz again any time soon.

So if customer loyalty is as worthless as it appears to be from this example, I wonder why so many software companies are marketing customer experience management and customer loyalty solutions?

Perhaps they’d be better off trying to sell customer disloyalty solutions instead.

A bad day for “open” fanbois

In software:

Public urged to reset all passwords – due to the critical two-year old flaw in OpenSSL.

One of the many unsubstantiated claims surrounding open source approaches to software development is that they are inherently less prone to errors than closed source development because there are more eyes able to inspect the underlying code. It’s an irrational claim, as it’s not the number of eyes that matter, but the quality of the brain(s) behind them and whether they’re looking in the first place. It’s not the case that any particular software business model has a monopoly on talent, so it has never been a credible claim that open source is somehow likely to be better in this respect.

In education:

Nothing like as serious as the OpenSSL flaw of course,  but it’s rather amusing that a venture set up to promote learning and understanding ends up adding to the myth that this is definitely something that Einstein said or wrote. A quick trawl through the various (paid for) Oxford Dictionaries of Quotations turns up a blank and in a reassuring fightback for the “open” camp, Wikiquotes notes that this is one of many sayings (mis)attributed to the physicist without a contemporaneous source.

David Cameron talks about the benefits of digital technologies

More from CeBIT – David Cameron talks to CEO Karl-Heinz Streibich and Chancellor Angela Merkel about the benefits of digital technologies such as those provided by Software AG.

This is very important for the future of Europe, because we need to be more competitive, we need to be more productive, we need to keep our costs down and digital technology can be a very big part of that. We shouldn’t just talk about it, we need to make sure that Angela and I at the European Union, that we make sure we complete the digital single market – that must be one of the tasks for the next Commission, for the next Council. It’s something that we’ve dedicated ourselves to doing and we will make sure that happens. It will benefit your company and these sorts of technologies. Thank you very much.

An appeal: PAFEC DOGS is worthy of conservation

Recently, there’s been quite a bit of banter in the comments of a post I wrote a couple of years ago about my first employer, PAFEC Ltd.

It’s got me thinking. It would be great to try to re-create a working copy of their most famous software package, DOGS (Design Office Graphics System) on (say) a modern Linux platform such as the Raspberry Pi, for conservation reasons.

As one of the first general purpose CAD packages on the market (it was first released around 1979 if my memory serves me correctly) that didn’t require specialist CAD hardware to operate it, as well as being the leading British CAD software package of the 1980s, it would be a shame not to try I think.

I’ve no idea who owns the rights to the software today, but if they’d like to get in touch I’d be very interested in putting together a small team together to start a conservation effort – assuming that they still have access to its source code.

Iron Man 2 – what was all that about then?

Much against my better judgement, I was persuaded to take a trip to the cinema this afternoon to see Iron Man 2.  I was obviously at a disadvantage, having not seen Iron Man (1), but it had a plot that made no sense whatsoever and had no characters in it that were even slightly likeable. The action was so obviously faked through the over-use of CGI that it fooled no-one over five years old – a shame really as the BBFC certificate is a 12A. Even Gwyneth Paltrow and Scarlett Johansson couldn’t rescue it with their virtuoso performances in pouting.

It also has to feature probably the most ill-advised piece of product placement for a large American software company that I’ve ever seen. I’m not going to name them, because I’m sure they’re regretting their decision to be a part of the film (and if they aren’t, then they should be.)

Their clumsy piece of product placement was just about the only moment of the film that raised a smile for me, when the large American software company in question had their fictional ‘grid’ used to track down the location of a telephone call. This is something you see in Spooks every week as a matter of routine, and for once the British obviously have better kit, because in Spooks it always works. The so-called ‘grid’ in Iron Man 2 took ages to locate even the vague area of the call and then, just as you thought it was finally going to find the villain, the ‘grid’ failed to locate him. Not a good advertisement at all.

4/10. Go and see it only if you’ve really got nothing better to do.

DD303 – Week 8: Context is everything

One of the stories I like to tell about working in the software industry is from the dot-com bubble. At the time, I was working for a company selling web content management software.

On one occasion, we had a day-long meeting with a dozen or so business people from a potential client. The salesperson and I started at around 10am, kicking off with a demonstration of the software to show how you could publish news articles and other content to your website and how you put that content through an approval process before it went live. All without having to have a webmaster handy to do it or for you to have any need to learn nasty ‘techie’ things like html.

As we were selling this software to many different types of businesses, the demonstration website we used to show how to publish stuff was an imaginary CD retailer. After all, people would understand what a CD was, wouldn’t they? And they’d realise we weren’t suggesting that they should be in the business of selling CDs?

At about 4pm we finished and asked the attendees if they had any questions.

One person, who’d been very quiet throughout the day, asked about the very first thing they’d seen at 10.02 that morning.

“Tim, you know when you published that press release, you typed in a paragraph about a CD. As you know, we don’t sell CDs, we sell widgets*. So, would your software still work if you typed in something about a widget instead?”

And the worst thing about that moment was that 2 or 3 other people sat around the table all said words to the effect “Good question – would it be able to do that?”

We didn’t make a sale that day.

We did, however, learn an important lesson. From then on, we dumped the lovingly crafted demonstration CD retailer website and instead used graphics and text from each potential customer’s website. I remember doing a splendid session to the OU on that basis a few weeks later … but we didn’t win their business, either! We did get other business, simply because we were able to put our software into a context they were familiar with.

So chapter 6, on language processing, has been a fascinating read when considering the role that context plays in how we recognise words and understand sentences, particularly when looking at the theories that abound when considering how we might resolve the ambiguities and vagaries in speech and writing. And it was good fun to see the opening sentence from Star Trek being used, along with colourless green ideas sleeping furiously and finding out that there are at least 50 grammatically valid interpretations of “time flies like an arrow”. Unless you’re read the chapter, you probably won’t understand what I’m writing about. Context is everything, you see …

(*) Obviously they didn’t sell widgets, but some details of this story have been changed to protect the innocent and guilty.

PAFEC – August 1991

I’m still looking for the photographs of the Warwick University Rent Strike of 1983. I’ve not managed to find them yet, as it involves going through a cabinet in a cupboard in my younger daughter’s bedroom to find them, which first of all involves tunneling through the masses of teenage detritus she keeps in what we laughingly term a bedroom. You can rarely see the bed (or the floor.)

But I did find these photographs, which are interesting historical documents in their own right. (OK, they’re interesting to me, and me only, probably.) They show the middle office of the 2nd floor of what was PAFEC’s Stapleford premises at 39 Nottingham Road in August 1991. At that time, I was the Product Services Manager and was in the process of building a team from the remnants of three others involved in porting the company’s software, as well as having been given the publications department.

One of the goals we wanted to achieve was to introduce more professionalism into what the company was doing. One means of  making sure this happened involved getting the Support Services Division (which my team was part of) through an ISO9001 audit against TickIT. As part of working through this, we realised (pretty quickly!) that we needed to be far, far better in how we organised our working environment. The first photograph shows the scale of the task we faced. The team covered the whole of the 2nd floor – so we had two other offices that didn’t look too dissimilar to this one.

PAFEC Product Services Office - August 1991

Key to photograph

  1. Back of two Sun ‘shoeboxes’ – at this point in time, they would have contained either 70 or 140 Mbyte SCSI disks and one of them would have had a cartridge tape unit.
  2. A PAFEC DOGS menu card – though probably for one of the options, like DOGS NC, from a superficial view of the colours used on it.
  3. Uncontrolled media – probably containing DOGS source and object code. You can also see piles of it in the open cabinet behind my desk. Part of the process of getting through the audit was to eliminate most of this from the offices (and keep it in a fire safe in the computer rooms in Strelley and Stapleford, where it belonged.)
  4. Our Sun SparcStation 1 workstation.
  5. Our Harris MCX workstation.
  6. The console for the Data General mini computer we had in the office, running the now long defunct AOS/VS operating system.
  7. A Tektronix graphics terminal – probably a 4111.
  8. A Prime PT200 terminal, connected to the customer support database and contact management system.
  9. Boxes containing various revisions of SunOS 2.x, 3.x and 4.x for Sun 3 and Sparcstation hardware.
  10. The back of one of the Sun 3/50 workstations we had in the office. Out of picture to the left would have been our second 3/50, a diskless 3/110, a Sun 386i and a Whitechapel MG-1.

The other offices would have had a number of Apollo workstations (DN3000s  and earlier models), Vaxstations, DECstations, an IBM PC RT (6150) and a HP9000/400 workstation. A range of graphics terminals (Tektronix, Sigma, Westward, Datapath)  would have been capable of working through a Gandalf switch with the “heavy lifting” minicomputers in the machine rooms at Stapleford and Strelley, including Prime, Vax, Data General, HP, Norsk Data, Bull and Harris.

The second photograph shows my desk (you can just about see it in the background of the first photograph) after we’d finished our clear-out. Neat and tidy – with not a piece of uncontrolled and unlabeled media in sight.

PAFEC Product Services Office - My desk, August 1991

We got through the audit later on that year, first time. The quality of the processes we were following improved beyond all recognition and we started to deliver software, not in jiffy bags, but in the type of packaging that the rest of the industry was capable of doing. Which meant that we started to get the right software to our customers, first time, rather than second, third or fourth time. Quality went up, costs went down and the company (after the false hopes we had for the 3D CAD market were past) started to recover with our later diversification into electronic document management software.