This is the software behind the second prototype of a personal weather station based around a raspberry pi zero w. This is a complete restart of the code from the first prototype. I was going to reuse that code but it was ugly, needed an overhaul, I didn't like the structure of it and I didn't want to mess with an existing repo. The weather station itself uses a few adafruit sensors along with a four channel ADC attached to external senors (which are sold as weather station spare parts). It has a custom case built around a water bottle and an embedded solar fan to negate heat fluctuations from direct sunlight. Its all very specific to my build, but would be a good starting point for reuse for others attempting to build something similar.
The code should be relatively well documented and easy to follow. The main funciton is to:
- Read all attached sensors
- Send the gathered data to
- weather underground
- Metoffice WOW service (UK)
- a remote database (I use this to generate a basic current conditions page).
- Adafruit_DHT
- Adafruit_Python_ADS1x15
- MySQLdb
- RPi.GPIO
- smbus
- urllib2
- WeatherSensors (in this repo)
The hardware used in this project, in no particular order:
- Adafruit MPL3115A2 Barometric Pressure, Altitude & Temperature
- ADS1015 ADC Module - 12 Bit I2C 4 Channel
- Generic UV sensor (analogue. ASIN: B00NL9XNN8)
- Maplin N96FY Wind Speed
- Rainfall (generic spare part)
- Raspberry pi Zero W
- Solar Powered Clip Fan - ripped apart and mounted into the housing cowel
- some snaps of the housing to get an idea of how it's setup
- Wind Direction (generic spare part)
- MPL3115A2 Generic temperature & Humidity sensor - from a bulk lot of sensors
Various design diagrams are in the DesignDocs directory, they may help someone. All sensor data passing is carried out using a custom data structure, SensorData. For consistency (and because data is uploaded to Wunderground), I use the labels set out in the Weather Underground PWS API when dealing with labeled sensor readings e.g. baromin
for barometric pressure. The units defined by the wunderground API are also used for consistency if nothing more (even though it feels wrong to be using imperial measurements it's easy enough to convert things to something more sensible on display).
Note that there are two temperature sensors in use here (not by design - the humidity and barometric pressure sensors came with extras). These are mounted in the enclosure with the rPi/rest of the internals. Although there is a fan and all endeavours have been made to equyalise the temperature inside the casing with the outside air (venting, painted white, fan etc), both readings are averaged and then normalised against the CPU temperature to try and get an actual air temperature.