About the Project

This weather station project started out as an Electrical Engineering thesis project. The goal of the weather station was to provide accurate weather readings using low-cost hardware. The original project consisted only of an FPGA based board interfaced with two temperature sensors, a humidity sensor and rain gauge. Since then additional sensors have been added as well as creation of a website with database functionality.

The weather station now consists of an FPGA based main board, a raspberry pi, weather sensors and a web server. The system diagram below shows the interconnections of all the main components as well as the data protocols and programming languages used:

Figure 1: System Schematic

The Main Board

The main board contains a Lattice Semiconductor MachXO FPGA chip which has been programmed with the VHDL language. The chip reads temperature and humidity readings from a digital sensor via a 2-wire bus similar to I2C. The rain gauge also interfaces with the main board and FPGA as a digital input. The rain, temperature and humidity readings are latched to a serial data module which transfers the readings to a raspberry pi via 3.3V RS232. The main board also contains a LCD display which is updated with live readings.

Figure 2: The Main Board

Raspberry Pi

The main purpose of the Raspberry Pi is to perform the complex scaling calculations on the weather readings from the main board and to update the web server. These calculations cannot be performed on the FPGA chip due to resource limitations and complexity of operations. The Raspberry Pi is also used to collect data from the barometric pressure sensor via the I2C bus and capture images from a USB webcam. A Python script is used to perform the Raspberry Pi operations.

The python script receives a string of characters from the serial port as shown below. The string is then processed and converted to weather readings. An average is taken over 5 minutes in order to smooth out fluctuations. The data is then uploaded to the web server if an internet connection is available, otherwise it is stored locally for upload when the connection is active again.

Figure 3: Raspberry Pi Python Script

Web Server

Data from the Raspberry Pi is transferred to a web server using a HTTP POST to a PHP page. The page will then save the posted data into a database using SQL. The readings stored in the database are displayed in graph form using the Google Charts API. The graphs page also contains JavaScript code which populates select boxes with the days that have available data. When a date is selected the relevant graph is then displayed.

There are two databases on the server, one which stores daily weather readings and one which stores weather trend data such as minimum and maximum temperatures. A CRON script runs at midnight every night to append the current day's data to the database. The advantage of storing the data in a separate database is that no large database searches need to be performed when displaying the trend data.

The website also has a mobile version which is displayed when a mobile browser is detected. The user is automatically redirected to the m.wilstonweather.com subdomain.