A Zambretti weather forecaster

When I was recovering from my stem cell transplant last year, I built a weather forecaster. It uses a Raspberry Pi, a BME280 sensor and a 20×4 character LCD screen. The forecasting algorithm I’d written for it was rudimentary, to say the least. However, earlier on this year I came across a device known as a Zambretti forecaster. These were made by Negretti and Zambra for the UK market in the 1920s.

The Zambretti device uses air pressure, the direction of change, season and wind direction to make a forecast. Depending on what you believe on t’internet, a forecast accuracy of 90% is possible. You can buy replicas from a popular forest-based e-commerce site if you want to. I didn’t, but with the help of a search engine and a number of people who’ve been down this route before, wrote my own Zambretti forecasting algorithm. In FORTRAN 77 naturally.

The results so far have been encouraging. However, I’m of the opinion that the accuracy I’m perceiving may be due to the Forer effect, rather than the goodness of the algorithm. It’s true that different barometric conditions do produce different forecasts. However, I remain unsure as to the real difference between Fine : showers possible, Fair : showers likely and Fairly fine : showers. Not much I suspect.  

Anyway, it was producing good enough results to invest a few more pounds in a second LCD display. This retrieves the forecast made by the Raspberry Pi and sensor covered in cobwebs in the garage and displays it in more comfortable surroundings. This time I’ve stuck to C as my language of choice.

Raspberry Pi 4B plus a 20x4 LCD screen showing a Zambretti weather forecast
A Raspberry Pi 4B plus a 20×4 LCD screen, showing a Zambretti weather forecast all the way from my garage.

The current release of my Zambretti forecaster with remote display screen, with instructions, is available on github. Some (most) of the code could definitely do with improvement …

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.

Costs

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
      SUBROUTINE MFCAST(PDIFF,CIND,CFORE)
C----------------------------------------------------------------------C
C                                                                      C
C     MAKE FORECAST BASED ON 3 HOURLY PRESSURE DIFFERENCE              C
C                                                                      C
C     PDIFF - PRESSURE DIFFERENCE IN LAST THREE HOURS                  C
C     CIND  - CHANGE INDICATOR STRING                                  C
C     CFORE - FORECAST STRING                                          C
C                                                                      C
C     AUTHOR: TJH 26-07-2018                                           C
C                                                                      C
C----------------------------------------------------------------------C
      REAL PDIFF
      CHARACTER*2 CIND
      CHARACTER*20 CFORE
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
         CIND="vv"
         CFORE="Wind,rain;fine later"
      ELSE IF (PDIFF.LT.-6.0) THEN
         CIND="vv"
         CFORE="    ** STORMY **    "
      ELSE IF (PDIFF.GE.0.5 .AND. PDIFF.LE.6.0) THEN
         CIND="^ "
         CFORE="Fine, becoming drier"
      ELSE IF (PDIFF.GT.6.0) THEN
         CIND="^^"
         CFORE="Becoming dry & windy"
      ELSE
         CIND="--"
         CFORE="No change in weather"
      END IF
      RETURN
      END

 

(+) 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.