Weather Station

Post Create 27th February 2020

Build a Weather Station

So for a few years I have been dreaming of building a weather station at home.

  • A programmable one that I can control
  • if I log to a file
  • to a database
  • to mqtt
  • or to WeatherUnderground.

So I decided to do ALL of them.

I started with a few links to other people doing the same thing. Oracle Weather Station. It was then further expanded on by the guys at Raspberry Pi.org. It then caught my eye again on the core-electronics web site. Core Electronics being the Retail Seller for Raspberry Pi's

Use the links at the side for my updates.

Check it out on Weather Underground

or the Current readings: Outside Temperature:

Outside Humidity:

Diagrams

All mounted on the wall now ( Chose to keep the breadboard installed so far )

Pihat 1

Found a use for the Foxtel mount.. Removed the dish and will mount the Weather Station ( when it stops raining )

Pihat 2

Parts List

This was the original Parts List I started with for the Weather Station

  • Raspberry Pi 4 Gb This was one I had reserved for my Retro Pi Install, but alas time to test all those roms has gotten away from me and I will use this one as the Weather Station instead.
  • BME280 Temperature Sensor
  • DS18B20 with 3m Cable Ground Temperature Sensor
  • Weatherproof Case for Raspberry Pi
  • Weatherproof Case for Temperature Humidity and Pressure Sensors
  • Pi Hat for Chips and Sensor Connectors
  • MCP3008 Analog to Digital IC
  • Lightning Detector Sensor
  • Power Supply for POE
  • Splitter for POE to Micro USB
  • Weather Station, Weather Vain, Water Detector
  • RJ11 / RJ12 Socket Connectors
  • Cabling for POE connection

WeatherUnderground

Join Weather Underground

The Weather Underground is described as such :

Weather Underground has challenged the conventions around how weather information is shared with the public since 1993. We’re immensely proud of the unique products that our community and meteorologists have created to improve people’s access to meaningful weather data from around the globe. As the Internet’s 1st weather service, we consider ourselves pioneers within our field and we’re constantly seeking new data sets and the next technologies that will help us share more data with more people.

You can register on this site as an independant uploader of weather data and allow other people to use your data for local weather patterns.

As I waited for my parts to arrive I decided to register ready for uploading my Temperature Data.

Scripting

It was as simple as adding a few lines to POST the data to the WeatherUnderground API

#!/usr/bin/python3


import requests


humidity = 55.998
ambient_temp = 23.456
pressure_in_hpa = 1067.890
ground_temp = 16.345
wind_speed = 5.6129
wind_gust = 12.9030
wind_average = 180
rainfall = 1.270


# create a string to hold the first part of the URL
WUurl = "https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?"
WU_station_id = "IBRISB930" # Replace XXXX with your PWS ID
WU_station_pwd = "password" # Replace YYYY with your Password
WUcreds = "ID=" + WU_station_id + "&PASSWORD="+ WU_station_pwd
date_str = "&dateutc=now"
action_str = "&action=updateraw"

humidity_str = "{0:.2f}".format(humidity)


def hpa_to_inches(pressure_in_hpa):
    pressure_in_inches_of_m = pressure_in_hpa * 0.02953
    return pressure_in_inches_of_m

print(hpa_to_inches(100))

def mm_to_inches(rainfall_inmm):
    rainfall_in_inches = rainfall_in_mm * 0.0393701
    return rainfall_in_inches

def degc_to_degf(temperature_in_c):
    temperature_in_f = (temperature_in_c * (9/5.0)) + 32
    return temperature_in_f

def kmh_to_mph(speed_in_kmh):
    speed_in_mph = speed_in_kmh * 0.621371
    return speed_in_mph


pressure = hpa_to_inches(pressure_in_hpa)
pressure_str = "{0:.2f}".format(hpa_to_inches(pressure))

r= requests.get(
    WUurl +
    WUcreds +
    date_str +
    "&humidity=" + humidity_str +
    "&baromin=" + pressure_str +
    action_str)

print("Received " + str(r.status_code) + " " + str(r.text))