links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Last updated at 12:13 am UTC on 23 May 2017

Why did I do this?

I signed up for a KickStarter for some weather station hardware for a Pi. Because you do.
For the record it was this package - http://store.switchdoc.com/ourweather-complete-weather-kit/
and it's fairly decent hardware. The Grove connectors system is a nice way of quickly assembling electronics without too much fuss. In fact it is such nice stuff that I decided to keep it for other usages and hardwired the sensors instead. Since the 'weather pi' is in a tupperware box in the peak of my garage it doesn't matter a lot if it doesn't look cute.

The hardware

The installed box, high in the peak of the workshop roof-
It looks pretty cool at night, little glowing lamps of computational effort lighting up the dark.

With the lid opened to see the magic inside -
WeatherPi interior.png
Power and ethernet come in at the bottom via the POE link - which means I can reboot by going to my server room and just unplugging it and plugging it back in. The power lead goes straight to a 40 pin header on the Pi model A+. Ethernet goes via a very cheap and tacky lan->usb dongle/hub that I mangled a fair bit to a) make work and b) cut the cable down to a sensible length.
Also connected via the 40 pin header is the power and i2c link for the SDL Weather Board. Attached to said board are

Wiring connections

The simplest option for wiring is to use a 40 pin header that fits on the Pi and make just seven connections. The pin numbering on a Pi can be a bit confusing since the physical order is unrelated to the GPIO number and the various power and ground pins do no have GPIO numbers. The best thing is to take a look at https://pinout.xyz/pinout/i2c. For details of the weather board (including a map of where the assorted connections are) see http://www.switchdoc.com/wp-content/uploads/2016/07/WeatherBoard_CurrentSpecification.pdf
Pin Connect to
5v 5v power in from your PSU - in my case the POE dongle.
3v3 3.3v power from Pi to the weather board connector JP4/3; we probably ought not use this but it seems to handle the minor power needs to the sensors ok thus far.
Gnd ground from the PSU/POE and to the weather board connector JP4/4
GPIO 2 i2c clock, SCL on weatherboard connector JP4/1
GPIO 3 i2c data, SDA on the weather board connector JP4/2
GPIO 20 rain bucket 'tick' pin, connects to weather board pin JP2/2
GPIO26 anemometer 'tick' pin, connects to weather board pin JP2/3

The last two are set in the Python code as 'anemometerPin' and 'rainPin' shortly before they are used to initialise the weather board object with
weatherStation = SDL_Pi_WeatherRack.SDL_Pi_WeatherRack(anemometerPin, rainPin, 0,0, SDL_MODE_I2C_ADS1015)

The ADS1115 breakout board I got happens to have pins that exactly align with the weather board connector JP5. You could easily just use a strip of header pins to mount the ADS straight onto the weather board; I used short wires since I'd already soldered the pins on in a manner that made it a bit tricky. All the other connections for the rain/wind and AM2315 sensors are covered in the weather board doc referred to above.


Of course once I had the hardware I had to do something about software for it. Sadly the software offered as part of the kit was a bit naff to say the least; written in Python, cryptic, not really set up to report any data to anyone. After a lot of messing about I settled on using MQTT to send the data out for any interested subscribers, which of course meant writing an MQTT client for Squeak. A small advantage of the sample weatherboard software being in Python is that there was a downloadable mqtt client available that made it simple to publish the data. I was also able to leverage a fair bit of AdaFruit python code to read the sensors. Working with Python for this made me really, really, happy that I get to use Smalltalk most of the time. The code is available here -
You'll obviously (I hope!) need to edit the name of the MQTT broker you want to publish data to.

A side issue of some importance is making the weather pi run the sensor software on boot; whilst it is trivial to use RDP to connect to the pi and open a terminal and start it up, it isn't really how it ought to work. This requires getting to know a (tiny) bit about systems and 'unit files', which has to count as some of the most bogglingly over complicated time wasting I've ever had to tolerate. There's some detail in LinuxSystemdUnitFiles for the bored and curious.

Indoor sensors too

To add some extra fun I wanted indoor sensors for temperature and humidity to place around the house. You don't really want to use Raspberry Pi boards for this sort of thing since they are after all real computers and not microcontrollers. Most people would probably start jumping up and down chanting "Arduino! Arduino!" like fans at a feet ball joust but there is actually a rather better answer these days in the ESP8266 which provides a surprisingly high performance 32bit cpu, a modicum of RAM, some flash storage and built in wifi at prices in the USD$5 range. They can be programmed in a variety of ways but I used the Arduino IDE with suitable support modules loaded; this makes it really simple to install drivers for the assorted sensors and an mqtt client. Adding sensors is remarkably easy and indeed, the WeMOs.cc mini D1 pro version has nice simple to attach daughter boards with suitable sensors. They are a little more expensive than run of the mill AliExpress clones but seem to be a bit better built and still cost less than USD$60 for 6 each of the main board and sensor shield, delivered quickly. It wouldn't be at all hard to add other sensors to the mix; passive IR body-heat detectors, door-open switches, infra-red remote stuff, all the usual 'Smart House' stuff. At the price it isn't ridiculous to imagine dedicating one to telling you if a door is open. Slightly out of scope for my interests is the observation that a friend at my local MakerSpace has been able to send mp3 streams to an ESP and output the audio with good quality. Maybe a baby monitor?

My software for driving the ESP boards is here -
ESP8266-sensorsplus MQTT-tpr.zip
This includes versions for DHT22, SHT30, BMP280 & BME280 sensors.
Again, edit the WiFi network credentials and MQTT broker address. Substituting other kinds of sensor in the code is pretty simple. Note that this version makes the ESP go into deep sleep after completing a publish cycle; this requires connecting the D0 pin to the RST pin in order to actually wake up after the requested delay. It save power and perhaps more importantly stops the warmth of the cpu distorting the reported temperature.

Displaying the data

Once we have all this data we need to do something with it. Most interesting weather info is nicely graphable so I use the PlotMorph package (with some recent updates to provide time-range updating) to show the last X hours of data. This is what the last three days of temperature data looks like -
Notice how the dark grey line at the bottom occasionally bounces wildly off-track - that's the AM2315 outdoor unit, which is legendarily awkward to live with. Some days it gives 0 or infinite results half the time, some days it behaves perfectly. The next (red) line up is the temp in my garage as reported from the on-board BMP280, so it is buffer by the insulation of the garage walls. The cluster of lines above that are my various indoor sensors. It's pretty obvious when the heating kicks on!
Sharp-eyed observers will note that the graph lacks data at the left. This is because I managed to lose my prior data during experimenting with something. Never mind, weather is always with us.
Another nice way to display current weather info is with traditional styled (almost skeuomorphic) graphics mimicking a barometer or thermometer. For that I am using the RotaryDialMorph package. Opps, looks like the barometer is falling, get out the umbrella!


Currently the weather station code is not a well-formed package. You would need to load the rotarydialmorphs, plotmorph, mqttclient, json, and printf packages first. It will get cleaned up.
ESP8266-sensorsplus MQTT-tpr.zip
ESP8266-sensorsplus MQTT-tpr.zip